Query installed storage for installed apps 34/74034/6 accepted/tizen/common/20160703.130824 accepted/tizen/ivi/20160701.034205 accepted/tizen/mobile/20160701.034338 accepted/tizen/tv/20160701.034057 accepted/tizen/wearable/20160701.034233 submit/tizen/20160630.141237 submit/tizen_common/20160701.180000
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 10 Jun 2016 11:31:50 +0000 (13:31 +0200)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Thu, 30 Jun 2016 12:06:39 +0000 (05:06 -0700)
Change in logic:
 - for installed apps query pkgmgr,
 - for new apps set internal storage by default;
   installed_storage value is overwriten in StepAcquireExternalStorage
   if initialization of sd card works well.

This is just some factoring. To verify:
 - run smoke tests for tpk,
 - check that move request is still working:
     tpk-backend -i ${package}
     tpk-backend -m ${pkgid} -t 1
     tpk-backend -m ${pkgid} -t 2

Change-Id: Id24ab0667e356917f2ed10dd36a6cef1e58edf95

src/common/pkgmgr_query.cc
src/common/step/configuration/step_parse_manifest.cc

index ef26262..27f2df5 100644 (file)
@@ -139,7 +139,7 @@ std::string QueryStorageForPkgId(const std::string& pkg_id, uid_t uid) {
   pkgmgrinfo_pkginfo_h package_info;
   if (pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &package_info)
       != PMINFO_R_OK) {
-    return installed_location;
+    return "";
   }
 
   pkgmgrinfo_installed_storage storage;
@@ -148,7 +148,7 @@ std::string QueryStorageForPkgId(const std::string& pkg_id, uid_t uid) {
   pkgmgrinfo_pkginfo_destroy_pkginfo(package_info);
 
   if (!ok)
-    return installed_location;
+    return "";
 
   if (storage == PMINFO_EXTERNAL_STORAGE)
     installed_location = "installed_external";
index 3170acd..7328639 100644 (file)
@@ -46,6 +46,7 @@ namespace bf = boost::filesystem;
 namespace {
 
 const char kManifestFileName[] = "tizen-manifest.xml";
+const char kInstalledInternally[] = "installed_internal";
 
 }  // namepsace
 
@@ -221,9 +222,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
-  std::string storage = QueryStorageForPkgId(manifest->package,
-                                            context_->uid.get());
-  manifest->installed_storage = strdup(storage.c_str());
+  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 for preloaded
+        // applications
+        manifest->installed_storage = strdup(kInstalledInternally);
+    } else {
+        manifest->installed_storage = strdup(storage.c_str());
+    }
+  } else {
+    manifest->installed_storage = strdup(kInstalledInternally);
+  }
 
   if (ui_application_list) {
     manifest->mainapp_id =