Set installed storage and external image path when ManifestDirectInstall 54/147354/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 1 Sep 2017 10:40:23 +0000 (19:40 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 4 Sep 2017 05:35:58 +0000 (14:35 +0900)
Change-Id: I3bdeb3c825ef6a0fcb3cc8eb967871dbbd0dc364
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/step/configuration/step_parse_manifest.cc

index 512de30c5e4f1261cb7f52e824759b38c5b9b277..001127700f985aa1012d47463af95ad33bbe85f3 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <boost/tokenizer.hpp>
 
+#include <app2ext_interface.h>
 #include <pkgmgr/pkgmgr_parser.h>
 #include <pkgmgr-info.h>
 
@@ -50,6 +51,7 @@ namespace {
 
 const char kManifestFileName[] = "tizen-manifest.xml";
 const char kInstalledInternally[] = "installed_internal";
+const char kInstalledExternally[] = "installed_external";
 const char kPortraitOrientation[] = "portrait";
 const char kLandscapeOrientation[] = "landscape";
 const char kOperationEffectKey[] = "operation_effect";
@@ -240,6 +242,19 @@ bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
     manifest->type = strdup(pkg_info->type().c_str());
   }
 
+  // Set external path if the package is installed at external storage.
+  if (req_type == RequestType::ManifestDirectInstall ||
+      req_type == RequestType::ManifestDirectUpdate ||
+      req_type == RequestType::ManifestPartialInstall ||
+      req_type == RequestType::ManifestPartialUpdate) {
+    char* image_path = app2ext_usr_get_image_path(context_->pkgid.get().c_str(),
+        context_->uid.get());
+    if (image_path) {
+      manifest->external_path = image_path;
+      manifest->installed_storage = strdup(kInstalledExternally);
+    }
+  }
+
   for (auto& pair : pkg_info->labels()) {
     label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
     if (!label) {
@@ -267,18 +282,20 @@ bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
   // set installed_storage if package is installed
   // this is internal field in package manager but after reading configuration
   // we must know it
-  if (manifest_location_ == ManifestLocation::INSTALLED ||
-      manifest_location_ == ManifestLocation::RECOVERY) {
-    std::string storage = QueryStorageForPkgId(manifest->package,
-                                              context_->uid.get());
-    if (storage.empty()) {
+  if (!manifest->installed_storage) {
+    if (manifest_location_ == ManifestLocation::INSTALLED ||
+        manifest_location_ == ManifestLocation::RECOVERY) {
+      std::string storage = QueryStorageForPkgId(manifest->package,
+                                                context_->uid.get());
+      if (storage.empty()) {
         // Failed to query installation storage, assign internal
         manifest->installed_storage = strdup(kInstalledInternally);
-    } else {
+      } else {
         manifest->installed_storage = strdup(storage.c_str());
+      }
+    } else {
+      manifest->installed_storage = strdup(kInstalledInternally);
     }
-  } else {
-    manifest->installed_storage = strdup(kInstalledInternally);
   }
 
   return true;