Add routines for converting support-mode 46/98046/3
authorJunghyun Yeon <jungh.yeon@samsung.com>
Wed, 16 Nov 2016 04:44:37 +0000 (13:44 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Wed, 23 Nov 2016 01:12:41 +0000 (17:12 -0800)
- Add internal functions to be used to convert
  support-mode parsed from pkg's manifest

Related changes:
[pkgmgr-info]: https://review.tizen.org/gerrit/98045

Change-Id: Iae1de89f4e3c934019b3268aa8265ab444f2dc23
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/common/step/configuration/step_parse_manifest.cc
src/common/step/configuration/step_parse_manifest.h

index e8fb977..59279fd 100644 (file)
@@ -149,6 +149,25 @@ bool StepParseManifest::LocateConfigFile() {
   return true;
 }
 
+int StepParseManifest::GetSupportModeVal(std::string support_mode) {
+  int mode = 0;
+  std::size_t found = std::string::npos;
+
+  found = support_mode.find(APP_SUPPORT_MODE_ULTRA_POWER_SAVING_STR);
+  if (found != std::string::npos)
+    mode |= APP_SUPPORT_MODE_ULTRA_POWER_SAVING_VAL;
+
+  found = support_mode.find(APP_SUPPORT_MODE_COOL_DOWN_STR);
+  if (found != std::string::npos)
+    mode |= APP_SUPPORT_MODE_COOL_DOWN_VAL;
+
+  found = support_mode.find(APP_SUPPORT_MODE_SCREEN_READER_STR);
+  if (found != std::string::npos)
+    mode |= APP_SUPPORT_MODE_SCREEN_READER_VAL;
+
+  return mode;
+}
+
 bool StepParseManifest::FillInstallationInfo(manifest_x* manifest) {
   manifest->root_path = strdup(
       (context_->root_application_path.get() / manifest->package).c_str());
@@ -188,10 +207,12 @@ bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
     return false;
   }
 
+  int support_mode_val = GetSupportModeVal(pkg_info->support_mode());
+
   manifest->ns = strdup(pkg_info->xmlns().c_str());
   manifest->package = strdup(pkg_info->package().c_str());
   manifest->nodisplay_setting = strdup(pkg_info->nodisplay_setting().c_str());
-  manifest->support_mode = strdup(pkg_info->support_mode().c_str());
+  manifest->support_mode = strdup((std::to_string(support_mode_val)).c_str());
   manifest->appsetting = strdup("false");
   manifest->support_disable = strdup("false");
   manifest->version = strdup(pkg_info->version().c_str());
@@ -330,6 +351,10 @@ bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
     // if there is no app yet, set this app as mainapp
     bool main_app = manifest->application == nullptr;
 
+    int package_support_mode_val = atoi(manifest->support_mode);
+    int app_support_mode_val = package_support_mode_val |
+        GetSupportModeVal(application.app_info.support_mode());
+
     application_x* widget_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     widget_app->appid = strdup(application.app_info.appid().c_str());
@@ -338,7 +363,7 @@ bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
     widget_app->multiple = strdup("false");
     widget_app->nodisplay = strdup("true");
     widget_app->support_mode =
-        strdup(application.app_info.support_mode().c_str());
+        strdup((std::to_string(app_support_mode_val)).c_str());
     widget_app->taskmanage = strdup("false");
     widget_app->indicatordisplay = strdup("false");
     widget_app->type =
@@ -397,13 +422,17 @@ bool StepParseManifest::FillServiceApplication(manifest_x* manifest) {
     // if there is no app yet, set this app as mainapp
     bool main_app = manifest->application == nullptr;
 
+    int package_support_mode_val = atoi(manifest->support_mode);
+    int app_support_mode_val = package_support_mode_val |
+        GetSupportModeVal(application.app_info.support_mode());
+
     application_x* service_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     service_app->appid = strdup(application.app_info.appid().c_str());
     service_app->multiple = strdup(application.app_info.multiple().c_str());
     service_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
     service_app->support_mode =
-        strdup(application.app_info.support_mode().c_str());
+        strdup((std::to_string(app_support_mode_val)).c_str());
     service_app->autorestart =
         strdup(application.app_info.auto_restart().c_str());
     service_app->onboot = strdup(application.app_info.on_boot().c_str());
@@ -465,13 +494,18 @@ bool StepParseManifest::FillUIApplication(manifest_x* manifest) {
     // if there is no app yet, set this app as mainapp
     bool main_app = manifest->application == nullptr;
 
+    int package_support_mode_val = atoi(manifest->support_mode);
+    int app_support_mode_val = package_support_mode_val |
+        GetSupportModeVal(application.app_info.support_mode());
+
     application_x* ui_app =
         static_cast<application_x*>(calloc(1, sizeof(application_x)));
     ui_app->appid = strdup(application.app_info.appid().c_str());
     ui_app->launch_mode = strdup(application.app_info.launch_mode().c_str());
     ui_app->multiple = strdup(application.app_info.multiple().c_str());
     ui_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
-    ui_app->support_mode = strdup(application.app_info.support_mode().c_str());
+    ui_app->support_mode =
+        strdup((std::to_string(app_support_mode_val)).c_str());
     ui_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
     ui_app->type = strdup(application.app_info.type().c_str());
     ui_app->ui_gadget = strdup(application.app_info.uigadget().c_str());
@@ -549,6 +583,10 @@ bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
   for (const auto& watch_application : watch_application_list->items) {
     bool main_app = manifest->application == nullptr;
 
+    int package_support_mode_val = atoi(manifest->support_mode);
+    int app_support_mode_val = package_support_mode_val |
+        GetSupportModeVal(watch_application.app_info.support_mode());
+
     application_x* watch_app =
              static_cast<application_x*>(calloc(1, sizeof(application_x)));
     watch_app->appid = strdup(watch_application.app_info.appid().c_str());
@@ -582,7 +620,8 @@ bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
     watch_app->process_pool = strdup("false");
     watch_app->autorestart = strdup("false");
     watch_app->onboot = strdup("false");
-    watch_app->support_disable = strdup(manifest->support_disable);
+    watch_app->support_mode =
+        strdup((std::to_string(app_support_mode_val)).c_str());
     watch_app->ui_gadget = strdup("false");
     watch_app->launch_mode = strdup("single");
     watch_app->ambient_support =
index 1e8d7af..34c3cf2 100644 (file)
@@ -70,7 +70,7 @@ class StepParseManifest : public common_installer::Step {
   bool FillServiceApplication(manifest_x* manifest);
   bool FillUIApplication(manifest_x* manifest);
   bool FillWatchApplication(manifest_x* manifest);
-
+  int GetSupportModeVal(std::string support_mode);
   bool CheckFeatures();
 
   template <typename T>