Fix ApplicationControlData creation 71/196171/1
authorPawel Wasowski <p.wasowski2@partner.samsung.com>
Fri, 21 Dec 2018 13:16:04 +0000 (14:16 +0100)
committerPawel Wasowski <p.wasowski2@partner.samsung.com>
Mon, 24 Dec 2018 09:04:12 +0000 (10:04 +0100)
Verification: 100% TCT pass rate

Signed-off-by: Pawel Wasowski <p.wasowski2@partner.samsung.com>
Change-Id: I3dc0a7eba685a0ec7e1e111350f9a68ae3f3296d

src/application/application_utils.cc

index 5b46388b51df7fe41490bb4a83aa2ec5d862443c..3fbeeba5ca21b26dde1c66b70dfeb8fe260a24f1 100644 (file)
@@ -389,8 +389,17 @@ PlatformResult ApplicationUtils::ApplicationControlDataToServiceExtraData(
     value_data.push_back(v.get<std::string>().c_str());
   }
 
-  auto result = app_control_add_extra_data_array(app_control, key.c_str(), value_data.data(),
-                                                 value_data.size());
+  int result = APP_CONTROL_ERROR_NONE;
+  /*
+   * Native applications handle single extra data objects and arrays in a different ways,
+   * hence they have to be packed with different native API functions.
+   */
+  if (1 == value_data.size()) {
+    result = app_control_add_extra_data(app_control, key.c_str(), value_data[0]);
+  } else {
+    result = app_control_add_extra_data_array(app_control, key.c_str(), value_data.data(), value_data.size());
+  }
+
   if (APP_CONTROL_ERROR_INVALID_PARAMETER == result) {
     if (0 == key.length()) {
       LoggerD("app_control_add_extra_data_array failed: zero-length key");