Fix logic of 'update' and 'removable' attibutes 57/133657/1
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 24 May 2017 11:59:50 +0000 (20:59 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Tue, 13 Jun 2017 04:49:03 +0000 (04:49 +0000)
'update=true' means that updated 'preload=true' package by downloadable update.

RW global app can be 'preload=true'.
And, RW global app can be 'removalbe=false'.
Also, RW global app can be upgraded using downloaded package file.
After upgrade, the app should have 'update=true' and 'removable=true'.

About the logic to keep 'preload' attribute when 'preload' package is updated
by downloadble upate in StepParsePreload, we don't need to consider direct-update case
(includes partial-update)
Because, we should explicitly give the option to present 'preload' or not,
in direct-install/update request (--preload, --preload-rw or none).

Test:
1. Install as RW global app as not-removable package:
2. Update as download package

Change-Id: I864c348df806eea123b26f55114b24de897592c9
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
(cherry picked from commit 0e9f4f4950948e00443891a1ba6979f6f28b58ac)

src/common/pkgmgr_interface.cc
src/common/pkgmgr_query.cc
src/common/pkgmgr_query.h
src/common/step/configuration/step_configure.cc
src/common/step/configuration/step_parse_manifest.cc
src/common/step/configuration/step_parse_preload.cc

index 544e8752572c3c277962a6191959564cbc847f47..b3d0f95488d39ce753dd705901c3bb68d73c159b 100644 (file)
@@ -162,7 +162,7 @@ RequestType PkgMgrInterface::GetRequestType() const {
           uid_t uid = GetUid();
           if (!GetIsPreloadRequest() &&
               QueryIsReadonlyPackage(pkgid, uid) &&
-              !QueryIsUpdatedReadonlyPackage(pkgid, uid)) {
+              !QueryIsUpdatedPackage(pkgid, uid)) {
             return RequestType::ReadonlyUpdateInstall;
           } else if (CheckIfAppFilesExists(pkgid, uid,
                                            QueryIsReadonlyPackage(pkgid, uid)
@@ -178,8 +178,9 @@ RequestType PkgMgrInterface::GetRequestType() const {
     }
     case PKGMGR_REQ_UNINSTALL: {
       std::string pkgid = GetRequestInfo();
-      if (!GetIsPreloadRequest() &&
-          QueryIsUpdatedReadonlyPackage(pkgid, GetUid()))
+      uid_t uid = GetUid();
+      if (QueryIsReadonlyPackage(pkgid, uid) &&
+          QueryIsUpdatedPackage(pkgid, uid))
         return RequestType::ReadonlyUpdateUninstall;
       else if (GetIsPreloadRequest() && GetIsPartialRW())
         return RequestType::PartialUninstall;
index 059a939cb84ccbaf3479e1445ec2eac42d1213f2..22c9662ce3a0a9b9be938d6e6a6b97f50d1fe128 100644 (file)
@@ -275,7 +275,7 @@ bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid) {
   return true;
 }
 
-bool QueryIsUpdatedReadonlyPackage(const std::string& pkg_id, uid_t uid) {
+bool QueryIsUpdatedPackage(const std::string& pkg_id, uid_t uid) {
   pkgmgrinfo_pkginfo_h handle;
   int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id.c_str(), uid, &handle);
   if (ret != PMINFO_R_OK) {
index 8c77e5c37080464e16a19ea7e98aa6f171aae0a8..4038b4611fabc2cd52439080cbc14a7b639d7fb2 100644 (file)
@@ -142,14 +142,14 @@ bool QueryIsDisabledPackage(const std::string& pkg_id, uid_t uid);
 
 /**
  * \brief Adapter interface for external PkgMgr module used for checking
- *        if given package is updated readonly package
+ *        if given package is updated package
  *
  * \param pkg_id package id
  * \param uid user id
  *
  * \return true if package is updated
  */
-bool QueryIsUpdatedReadonlyPackage(const std::string& pkg_id, uid_t uid);
+bool QueryIsUpdatedPackage(const std::string& pkg_id, uid_t uid);
 
 /**
  * \brief Adapter interface for external PkgMgr module used for checking
index 7bf5ce6b9cd0fc4617cfaf9a60df460ddaece48f..226fb8eb9f6c4d75532f9a37f8a086885d6a1eda 100644 (file)
@@ -178,8 +178,6 @@ Step::Status StepConfigure::process() {
 Step::Status StepConfigure::precheck() {
   SetupIsPreloadRequest();
   SetupIsPreloadRWRequest();
-  if (context_->is_readonly_package.get())
-    SetupIsNoRemoval();
 
   bool is_readonly = context_->is_readonly_package.get();
   bool is_preload_rw = context_->is_preload_rw_package.get();
@@ -188,6 +186,9 @@ Step::Status StepConfigure::precheck() {
     return Status::ERROR;
   }
 
+  if (is_readonly || is_preload_rw)
+    SetupIsNoRemoval();
+
   uid_t uid = pkgmgr_->GetUid();
   context_->uid.set(uid);
   if (getuid() == 0)
index 5c37b4b1319b450d42e827d6e2f3cb8cde039f26..35f164fbaf4ed05a1d1081f40442beab9b97ab2e 100644 (file)
@@ -230,12 +230,13 @@ bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
 
   // set update true if package is updated preload package
   common_installer::RequestType req_type = context_->request_type.get();
-  if (req_type == RequestType::ReadonlyUpdateInstall)
+  if (QueryIsUpdatedPackage(pkg_info->package(), context_->uid.get()))
     manifest->update = strdup("true");
-  else if (req_type == RequestType::ReadonlyUpdateUninstall)
-    manifest->update = strdup("false");
-  else if (QueryIsUpdatedReadonlyPackage(pkg_info->package(),
-        context_->uid.get()))
+  else if (QueryIsPreloadPackage(pkg_info->package(), context_->uid.get()) &&
+      (req_type == RequestType::Update ||
+       req_type == RequestType::Delta ||
+       req_type == RequestType::MountUpdate ||
+       req_type == RequestType::ReadonlyUpdateInstall))
     manifest->update = strdup("true");
   else
     manifest->update = strdup("false");
index 8926e3e356f5866cb47b841cc62aaa37d8fed586..42095210fb13c67b782d4984120685aef3aca841 100644 (file)
@@ -47,8 +47,8 @@ ci::Step::Status StepParsePreload::process() {
       free(context_->manifest_data.get()->preload);
     RequestType req_type = context_->request_type.get();
     if (req_type == RequestType::Update ||
-        req_type == RequestType::ManifestDirectUpdate ||
-        req_type == RequestType::ManifestPartialUpdate ||
+        req_type == RequestType::Delta ||
+        req_type == RequestType::MountUpdate ||
         req_type == RequestType::ReadonlyUpdateInstall) {
       // In case of update, keep preload value
       bool is_preload = QueryIsPreloadPackage(context_->pkgid.get(),