Force uninstall for external storage packages 78/86078/3
authorBartlomiej Kunikowski <b.kunikowski@partner.samsung.com>
Tue, 30 Aug 2016 10:56:56 +0000 (12:56 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Tue, 30 Aug 2016 15:42:30 +0000 (08:42 -0700)
StepOptionalAcquireExternalStorage

Change-Id: I2bdf0ddfc659defda95d46c287fff9df5cc4e54d

src/common/CMakeLists.txt
src/common/step/filesystem/step_acquire_external_storage.cc
src/common/step/filesystem/step_acquire_external_storage.h
src/common/step/filesystem/step_optional_acquire_external_storage.cc [new file with mode: 0644]
src/common/step/filesystem/step_optional_acquire_external_storage.h [new file with mode: 0644]

index dbd5703..1ba13da 100644 (file)
@@ -37,6 +37,7 @@ SET(SRCS
   step/configuration/step_parse_manifest.cc
   step/configuration/step_parse_preload.cc
   step/filesystem/step_acquire_external_storage.cc
+  step/filesystem/step_optional_acquire_external_storage.cc
   step/filesystem/step_change_owner.cc
   step/filesystem/step_clear_data.cc
   step/filesystem/step_copy.cc
index eacf442..da356af 100644 (file)
@@ -22,12 +22,6 @@ const char kPreferExternal[] = "prefer-external";
 const char kDefaultStorageVconfKey[] =
     VCONFKEY_SETAPPL_DEFAULT_MEM_INSTALL_APPLICATIONS_INT;
 
-enum class Storage {
-  NONE,
-  INTERNAL,
-  EXTERNAL
-};
-
 }  // namespace
 
 namespace common_installer {
index 58c3941..8785763 100644 (file)
@@ -20,6 +20,12 @@ class StepAcquireExternalStorage : public Step {
  public:
   using Step::Step;
 
+  enum class Storage {
+    NONE,
+    INTERNAL,
+    EXTERNAL
+  };
+
   explicit StepAcquireExternalStorage(InstallerContext* context,
       bool installed);
 
diff --git a/src/common/step/filesystem/step_optional_acquire_external_storage.cc b/src/common/step/filesystem/step_optional_acquire_external_storage.cc
new file mode 100644 (file)
index 0000000..6e0f864
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache 2.0 license that can be
+// found in the LICENSE file.
+
+#include "common/step/filesystem/step_optional_acquire_external_storage.h"
+
+#include <vconf.h>
+#include <vconf-internal-keys.h>
+
+#include <cstring>
+#include <string>
+
+#include "common/external_storage.h"
+#include "common/pkgmgr_query.h"
+
+namespace {
+
+const char kInstalledExternally[] = "installed_external";
+
+}  // namespace
+
+namespace common_installer {
+namespace filesystem {
+
+StepOptionalAcquireExternalStorage::StepOptionalAcquireExternalStorage(
+    InstallerContext* context)
+    : StepAcquireExternalStorage(context, true) {
+}
+
+Step::Status StepOptionalAcquireExternalStorage::process() {
+  Storage storage = Storage::NONE;
+
+  std::string storage_str = QueryStorageForPkgId(context_->pkgid.get(),
+      context_->uid.get());
+  if (!strcmp(storage_str.c_str(), kInstalledExternally))
+    storage = Storage::EXTERNAL;
+  else
+    storage = Storage::INTERNAL;
+
+  if (storage == Storage::EXTERNAL)
+    context_->external_storage =
+        ExternalStorage::AcquireExternalStorage(context_->request_type.get(),
+            context_->root_application_path.get(),
+            context_->pkgid.get(),
+            context_->pkg_type.get(),
+            context_->unpacked_dir_path.get(),
+            context_->uid.get());
+
+  if (storage == Storage::EXTERNAL && !context_->external_storage)
+      LOG(WARNING) << "Cannot initialize external storage for uninstalled package";
+
+  return Status::OK;
+}
+
+}  // namespace filesystem
+}  // namespace common_installer
+
diff --git a/src/common/step/filesystem/step_optional_acquire_external_storage.h b/src/common/step/filesystem/step_optional_acquire_external_storage.h
new file mode 100644 (file)
index 0000000..1b51e5f
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+// Use of this source code is governed by an apache 2.0 license that can be
+// found in the LICENSE file.
+
+#ifndef COMMON_STEP_FILESYSTEM_STEP_OPTIONAL_ACQUIRE_EXTERNAL_STORAGE_H_
+#define COMMON_STEP_FILESYSTEM_STEP_OPTIONAL_ACQUIRE_EXTERNAL_STORAGE_H_
+
+#include "common/installer_context.h"
+#include "common/step/filesystem/step_acquire_external_storage.h"
+
+namespace common_installer {
+namespace filesystem {
+
+class StepOptionalAcquireExternalStorage : public StepAcquireExternalStorage {
+ public:
+  explicit StepOptionalAcquireExternalStorage(InstallerContext* context);
+
+  Status process() override;
+
+  STEP_NAME(OptionalAcquireExternalStorage)
+};
+
+}  // namespace filesystem
+}  // namespace common_installer
+
+#endif  // COMMON_STEP_FILESYSTEM_STEP_OPTIONAL_ACQUIRE_EXTERNAL_STORAGE_H_