Implement PKGMGR_REQUEST_TYPE_CLEARDATA for tpk-backend 47/58247/6
authorTomasz Iwanek <t.iwanek@samsung.com>
Thu, 28 Jan 2016 13:11:05 +0000 (14:11 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Wed, 3 Feb 2016 09:18:58 +0000 (01:18 -0800)
Verify by running: pkgcmd -t tpk -c -n $pkgid_of_installed_package
and check if all content of apps_rw/$pkgid/data/ was removed.

Requires:
 - https://review.tizen.org/gerrit/58245

Change-Id: Ia68cf1269f46b4a5306eed43ecc7f8673aa00f7e

src/tpk/step/step_tpk_patch_icons.cc
src/tpk/tpk_installer.cc
src/tpk/tpk_installer.h

index e28dfc3e0914bf14a7a0dba934f7af3bbcc03b69..b62d46253a30ab093236410f87a7fbf1f1b904e7 100644 (file)
@@ -41,6 +41,10 @@ bf::path LocateIcon(const bf::path& filename, const std::string& pkgid,
   return {};
 }
 
+bool IsTpkApp(application_x* app) {
+  return strcmp(app->type, "capp") == 0 || strcmp(app->type, "jsapp") == 0;
+}
+
 }  // namespace
 
 namespace tpk {
@@ -84,7 +88,7 @@ common_installer::Step::Status StepTpkPatchIcons::process() {
   bf::create_directories(common_icon_location, error);
   for (application_x* app :
       GListRange<application_x*>(context_->manifest_data.get()->application)) {
-    if (strcmp(app->type, "capp") != 0 && strcmp(app->type, "jsapp") != 0)
+    if (!IsTpkApp(app))
       continue;
     if (app->icon) {
       icon_x* icon = reinterpret_cast<icon_x*>(app->icon->data);
index 34fdd0c7f0ecdd46d0f38c6f6ee3812e836f127a..aaac56c420a8885b989603ef305c21d383e7dabf 100644 (file)
@@ -5,6 +5,7 @@
 #include <common/step/step_configure.h>
 #include <common/step/step_backup_icons.h>
 #include <common/step/step_backup_manifest.h>
+#include <common/step/step_clear_data.h>
 #include <common/step/step_create_icons.h>
 #include <common/step/step_create_storage_directories.h>
 #include <common/step/step_copy.h>
@@ -90,6 +91,9 @@ void TpkInstaller::Prepare() {
     case ci::RequestType::ManifestDirectUpdate:
       ManifestDirectUpdateSteps();
       break;
+    case ci::RequestType::Clear:
+      ClearSteps();
+      break;
     default:
       AddStep<ci::configuration::StepFail>();
       break;
@@ -243,4 +247,9 @@ void TpkInstaller::ManifestDirectUpdateSteps() {
   AddStep<ci::pkgmgr::StepUpdateApplication>();
 }
 
+void TpkInstaller::ClearSteps() {
+  AddStep<ci::configuration::StepConfigure>(pkgmgr_);
+  AddStep<ci::filesystem::StepClearData>();
+}
+
 }  // namespace tpk
index 1b5d8fe6208632b43bd28443824b941ec2d22988..8037f81071161fdb86e34f814c9ee40606da0c40 100644 (file)
@@ -32,6 +32,7 @@ class TpkInstaller : public common_installer::AppInstaller {
   void RecoverySteps();
   void ManifestDirectInstallSteps();
   void ManifestDirectUpdateSteps();
+  void ClearSteps();
 
   SCOPE_LOG_TAG(TpkInstaller)
 };