Fix a bug when recover preload-rw update 76/282776/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Mon, 18 Mar 2019 06:08:53 +0000 (15:08 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Tue, 11 Oct 2022 09:10:31 +0000 (18:10 +0900)
The preload-rw package should not be a system package.

Change-Id: Iba5d917105fbdbfc699cd9a55403097638446aa3
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
(cherry picked from commit 2dc179fa36bdef817cd30a5c60ab2fc7d5ad5cf1)

src/common/step/pkgmgr/step_recover_application.cc
src/common/step/pkgmgr/step_recover_application.h

index 8c6abd5b0b0b0725e186b84482facd94466f9118..9df6a220905b48da0ea7825f2e0680f14b82efe9 100644 (file)
@@ -27,8 +27,10 @@ Step::Status StepRecoverApplication::RecoveryUpdate() {
     LOG(ERROR) << "Some parameters are lacking";
     return Status::ERROR;
   }
-  if (QueryIsUpdatedPackage(context_->pkgid.get(), context_->uid.get()))
-    SetExtraAttributes(true);
+  if (QueryIsPreloadPackage(context_->pkgid.get(), context_->uid.get()))
+    SetExtAttrForPreloadPackage(
+        QueryIsUpdatedPackage(context_->pkgid.get(), context_->uid.get()),
+        QueryIsRemovablePackage(context_->pkgid.get(), context_->uid.get()));
   UnregisterApplication();
   if (!RegisterApplication()) {
     LOG(ERROR) << "Unsuccessful app registration";
@@ -42,7 +44,7 @@ Step::Status StepRecoverApplication::RecoveryReadonlyUpdateInstall() {
     LOG(ERROR) << "Some parameters are lacking";
     return Status::ERROR;
   }
-  SetExtraAttributes(false);
+  SetExtAttrForPreloadPackage(false, false);
   UnregisterApplication();
   if (!RegisterApplication()) {
     LOG(ERROR) << "Unsuccessful app registration";
@@ -64,18 +66,19 @@ bool StepRecoverApplication::SetXmlPaths() {
   return true;
 }
 
-void StepRecoverApplication::SetExtraAttributes(bool is_updated) {
+void StepRecoverApplication::SetExtAttrForPreloadPackage(
+    bool is_updated, bool is_removable) {
   manifest_x* manifest_data = context_->manifest_data.get();
-  free(manifest_data->system);
-  manifest_data->system = strdup("true");
   free(manifest_data->preload);
   manifest_data->preload = strdup("true");
   free(manifest_data->update);
   manifest_data->update = strdup(is_updated ? "true" : "false");
+  free(manifest_data->system);
+  manifest_data->system = strdup(is_removable ? "false" : "true");
   free(manifest_data->readonly);
-  manifest_data->readonly = strdup(is_updated ? "false" : "true");
+  manifest_data->readonly = strdup(is_removable ? "false" : "true");
   free(manifest_data->removable);
-  manifest_data->removable = strdup(is_updated ? "true" : "false");
+  manifest_data->removable = strdup(is_removable ? "true" : "false");
 }
 
 bool StepRecoverApplication::UnregisterApplication() {
index d9cc7fb2da358a6cafad357fc0963eb301bed804..6cd40e6be1275b0953608f33a9f8473d307c0a33 100644 (file)
@@ -29,7 +29,7 @@ class StepRecoverApplication : public recovery::StepRecovery {
 
  private:
   bool SetXmlPaths();
-  void SetExtraAttributes(bool is_updated);
+  void SetExtAttrForPreloadPackage(bool is_updated, bool is_removable);
   bool UnregisterApplication();
   bool RegisterApplication();