[Application] Fix ApplicationControl object construction and logs 31/192431/3
authorPawel Wasowski <p.wasowski2@partner.samsung.com>
Fri, 2 Nov 2018 14:39:33 +0000 (15:39 +0100)
committerPawel Wasowski <p.wasowski2@partner.samsung.com>
Mon, 19 Nov 2018 11:45:52 +0000 (12:45 +0100)
This commit fixes 2 issues of
ApplicationUtils::ServiceToApplicationControl function:
1. launchMode field of JS ApplicationControl object was not filled.
Now, this field is filled properly.
2. valid, empty values, obtained from app_control_h object were logged
as erroneous. Now they are logged as empty.

[Verification] TCT pass rate: 100%

Change-Id: I6589d73ccebc35fbede0c9fac6b663b376970174
Signed-off-by: Pawel Wasowski <p.wasowski2@partner.samsung.com>
src/application/application_utils.cc

index 596d292a96a9e63c30ae0fa70963beaf65bc66c8..4a0098af55d7f56d0d8f1d720f7e8cc05aa64c39 100644 (file)
@@ -295,39 +295,59 @@ void ApplicationUtils::ServiceToApplicationControl(app_control_h app_control,
   };
 
   ret = app_control_get_operation(app_control, &tmp_str);
-  if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
+  if (APP_CONTROL_ERROR_NONE != ret) {
+    LoggerE("Get operation failed: %d (%s)", ret, get_error_message(ret));
+  } else if (tmp_str) {
     LoggerD("operation: %s", tmp_str);
     app_control_obj->insert(std::make_pair("operation", picojson::value(std::string(tmp_str))));
   } else {
-    LoggerE("Get operation failed: %d (%s)", ret, get_error_message(ret));
+    LoggerD("operation field is empty");
   }
   clear(tmp_str);
 
   ret = app_control_get_uri(app_control, &tmp_str);
-  if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
+  if (APP_CONTROL_ERROR_NONE != ret) {
+    LoggerE("Get URI failed: %d (%s)", ret, get_error_message(ret));
+  } else if (tmp_str) {
     LoggerD("URI: %s", tmp_str);
     app_control_obj->insert(std::make_pair("uri", picojson::value(std::string(tmp_str))));
+  } else {
+    LoggerD("URI field is empty");
   }
   clear(tmp_str);
 
   ret = app_control_get_mime(app_control, &tmp_str);
-  if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
+  if (APP_CONTROL_ERROR_NONE != ret) {
+    LoggerE("Get MIME failed: %d (%s)", ret, get_error_message(ret));
+  } else if (tmp_str) {
     LoggerD("MIME: %s", tmp_str);
     app_control_obj->insert(std::make_pair("mime", picojson::value(std::string(tmp_str))));
   } else {
-    LoggerE("Get mime failed: %d (%s)", ret, get_error_message(ret));
+    LoggerD("MIME field is empty");
   }
   clear(tmp_str);
 
   ret = app_control_get_category(app_control, &tmp_str);
-  if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) {
+  if (APP_CONTROL_ERROR_NONE != ret) {
+    LoggerE("Get category failed: %d (%s)", ret, get_error_message(ret));
+  } else if (tmp_str) {
     LoggerD("category: %s", tmp_str);
     app_control_obj->insert(std::make_pair("category", picojson::value(std::string(tmp_str))));
   } else {
-    LoggerE("Get category failed: %d (%s)", ret, get_error_message(ret));
+    LoggerD("category field is empty");
   }
   clear(tmp_str);
 
+  app_control_launch_mode_e launch_mode = APP_CONTROL_LAUNCH_MODE_SINGLE;
+  ret = app_control_get_launch_mode(app_control, &launch_mode);
+  if (APP_CONTROL_ERROR_NONE != ret) {
+    LoggerE("Get launch mode failed: %d (%s)", ret, get_error_message(ret));
+  } else {
+    std::string launch_mode_str = launch_mode == APP_CONTROL_LAUNCH_MODE_SINGLE ? "SINGLE" : "GROUP";
+    LoggerD("launch mode: %s", launch_mode_str.c_str());
+    app_control_obj->insert(std::make_pair("launchMode", picojson::value(launch_mode_str)));
+  }
+
   app_control_obj->insert(std::make_pair("data", picojson::value(picojson::array())));
   ServiceToApplicationControlDataArray(
       app_control, &app_control_obj->find("data")->second.get<picojson::array>());