Fix logic to store api version at application structure 84/160484/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 7 Nov 2017 00:45:22 +0000 (09:45 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 16 Nov 2017 08:28:20 +0000 (17:28 +0900)
- Each application could have different api version based on
  pkg which it belongs to, such as hybrid pkg.
- Store api version of each application into application structure
  to deliver it to security-manager.

Related changes:
[app-installers] :  https://review.tizen.org/gerrit/159061

Change-Id: I80c0faa909d25d23bb152d6a715ebe3e7e832f70
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/wgt/step/configuration/step_parse.cc

index 05a3b5d..353cf28 100644 (file)
@@ -412,6 +412,7 @@ bool StepParse::FillMainApplicationInfo(manifest_x* manifest) {
   application->autorestart = strdup("false");
 
   application->launch_mode = strdup(app_info->launch_mode().c_str());
+  application->api_version = strdup(manifest->api_version);
   for (auto& icon : GListRange<icon_x*>(manifest->icon)) {
     icon_x* app_icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
     if (!app_icon) {
@@ -460,7 +461,7 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) {
     SetApplicationXDefaults(application);
     application->support_ambient = strdup("false");
     application->package = strdup(manifest->package);
-
+    application->api_version = strdup(manifest->api_version);
     for (auto& pair : service_info.names()) {
       AppendLabel(application, pair.second, pair.first);
     }
@@ -527,7 +528,7 @@ bool StepParse::FillWidgetApplicationInfo(manifest_x* manifest) {
     SetApplicationXDefaults(application);
     application->support_ambient = strdup("false");
     application->package = strdup(manifest->package);
-
+    application->api_version = strdup(manifest->api_version);
     if (!app_widget.label.default_value.empty()) {
       AppendLabel(application, app_widget.label.default_value, std::string());
     }
@@ -903,18 +904,6 @@ common_installer::Step::Status StepParse::process() {
       backend_data->service_list.set(*service_list);
   }
 
-  manifest_x* manifest =
-      static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
-  if (!manifest) {
-    LOG(ERROR) << "Out of memory";
-    return common_installer::Step::Status::ERROR;
-  }
-  if (!FillManifestX(manifest)) {
-    LOG(ERROR) << "[Parse] Storing manifest_x failed. "
-               <<  parser_->GetErrorMessage();
-    return common_installer::Step::Status::PARSE_ERROR;
-  }
-
   // Copy data from ManifestData to InstallerContext
   auto info =
       GetManifestDataForKey<const wgt::parse::TizenApplicationInfo>(
@@ -940,8 +929,20 @@ common_installer::Step::Status StepParse::process() {
   const std::string& package_version = wgt_info->version();
   const std::string& required_api_version = info->required_version();
 
+  manifest_x* manifest =
+      static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
+  if (!manifest) {
+    LOG(ERROR) << "Out of memory";
+    return common_installer::Step::Status::ERROR;
+  }
   manifest->api_version = strdup(required_api_version.c_str());
 
+  if (!FillManifestX(manifest)) {
+    LOG(ERROR) << "[Parse] Storing manifest_x failed. "
+               <<  parser_->GetErrorMessage();
+    return common_installer::Step::Status::PARSE_ERROR;
+  }
+
   context_->pkgid.set(manifest->package);
 
   // write pkgid for recovery file