step/filesystem/step_create_per_user_storage_directories.cc
step/filesystem/step_create_storage_directories.cc
step/filesystem/step_delta_patch.cc
+ step/filesystem/step_move_installed_storage.cc
step/filesystem/step_recover_files.cc
step/filesystem/step_recover_icons.cc
step/filesystem/step_recover_manifest.cc
} else {
external_dirs_ = kExternalDirsForTpk;
}
+ move_type_ = -1;
+}
+
+ExternalStorage::ExternalStorage(RequestType type,
+ const std::string& pkgid, const std::string& package_type,
+ const boost::filesystem::path& application_root, uid_t uid,
+ bool is_external_move)
+ : type_(type),
+ pkgid_(pkgid),
+ package_type_(package_type),
+ application_root_(application_root),
+ uid_(uid),
+ handle_(nullptr) {
+ if (package_type_ == kWgtType) {
+ external_dirs_.push_back(kExternalDirForWgt);
+ } else {
+ external_dirs_ = kExternalDirsForTpk;
+ }
+ if (is_external_move)
+ move_type_ = APP2EXT_MOVE_TO_EXT;
+ else
+ move_type_ = APP2EXT_MOVE_TO_PHONE;
}
ExternalStorage::~ExternalStorage() {
ret = handle_->interface.client_usr_post_uninstall(pkgid_.c_str(), uid_);
break;
}
+ case RequestType::Move: {
+ break;
+ }
default:
assert(false && "Not supported installation mode");
}
ret = handle_->interface.client_usr_pre_upgrade(pkgid_.c_str(), glist,
external_size, uid_);
break;
+ case RequestType::Move:
+ if (move_type_ == -1) {
+ LOG(ERROR) << "Invalid request [" << move_type_ << "]";
+ ret = -1;
+ break;
+ }
+
+ ret = app2ext_usr_get_app_location(pkgid_.c_str(), uid_);
+ if (ret == APP2EXT_ERROR_INVALID_ARGUMENTS) {
+ LOG(ERROR) << "Failed to get installed location [" << pkgid_ << "]";
+ ret = -1;
+ break;
+ }
+
+ if ((ret == APP2EXT_SD_CARD && move_type_ == APP2EXT_MOVE_TO_EXT) ||
+ (ret == APP2EXT_INTERNAL_MEM && move_type_ == APP2EXT_MOVE_TO_PHONE)) {
+ LOG(ERROR) << "Invalid move request [" << move_type_ << "]";
+ ret = -1;
+ break;
+ }
+
+ ret = handle_->interface.client_usr_move(pkgid_.c_str(), glist,
+ (app2ext_move_type_t)move_type_,
+ uid_);
+ break;
case RequestType::Uninstall:
ret = handle_->interface.client_usr_pre_uninstall(pkgid_.c_str(), uid_);
break;
return ret == 0;
}
+std::unique_ptr<ExternalStorage> ExternalStorage::MoveInstalledStorage(
+ RequestType type, const boost::filesystem::path& application_root,
+ const std::string& pkgid, const std::string& package_type,
+ uid_t uid, bool is_external_move) {
+
+ std::unique_ptr<ExternalStorage> external_storage(
+ new ExternalStorage(type, pkgid, package_type, application_root, uid,
+ is_external_move));
+ if (!external_storage->Initialize(application_root)) {
+ LOG(WARNING) << "Cannot initialize external storage for move";
+ return nullptr;
+ }
+
+ return external_storage;
+}
+
std::unique_ptr<ExternalStorage> ExternalStorage::AcquireExternalStorage(
RequestType type, const boost::filesystem::path& application_root,
const std::string& pkgid, const std::string& package_type,
class ExternalStorage final {
public:
+ static std::unique_ptr<ExternalStorage> MoveInstalledStorage(
+ RequestType type, const boost::filesystem::path& application_root,
+ const std::string& pkgid, const std::string& package_type,
+ uid_t uid, bool is_external_move);
+
static std::unique_ptr<ExternalStorage> AcquireExternalStorage(
RequestType type, const boost::filesystem::path& application_root,
const std::string& pkgid, const std::string& package_type,
ExternalStorage(RequestType type, const std::string& pkgid,
const std::string& package_type,
- const boost::filesystem::path& application_root, uid_t uid);
+ const boost::filesystem::path& application_root, uid_t uid);
+
+ ExternalStorage(RequestType type, const std::string& pkgid,
+ const std::string& package_type,
+ const boost::filesystem::path& application_root, uid_t uid,
+ bool is_external_move);
~ExternalStorage();
bool Commit();
std::string package_type_;
boost::filesystem::path application_root_;
uid_t uid_;
+ int move_type_;
app2ext_handle* handle_;
std::vector<std::string> external_dirs_;
};
Property<bool> is_tep_move;
/**
+ * \brief boolean property that indicates request is external move or not
+ */
+ Property<bool> is_move_to_external;
+
+ /**
* \brief path to temporary directory when package files are unpacked
* before coping them to final destination
*/
return (pkgmgr_installer_get_tep_move_type(pi_) == 1)?true:false;
}
+bool PkgMgrInterface::GetIsMoveToExternal() {
+ return (pkgmgr_installer_get_move_type(pi_) == 1);
+}
+
bool PkgMgrInterface::GetIsPreloadRequest() {
return (pkgmgr_installer_get_is_preload(pi_) == 1)?
true:(install_mode_ == InstallationMode::OFFLINE)?
bool GetIsTepMove();
/**
+ * Returns True if move request is to external. Otherwise, return false
+ *
+ * \return True if move request is to external. Otherwise, return false
+ */
+ bool GetIsMoveToExternal();
+
+ /**
* Returns True if the request is for preload. Otherwise, return false
*
* \return True if the request is for preload. Otherwise, return false
{ci::RequestType::Uninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
{ci::RequestType::Update, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
{ci::RequestType::Delta, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
+ {ci::RequestType::Move, PKGMGR_INSTALLER_MOVE_EVENT_STR},
{ci::RequestType::MountInstall, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::MountUpdate, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
{ci::RequestType::ManifestDirectInstall, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
context_->pkgid.set(kStrEmpty);
context_->file_path.set(pkgmgr_->GetRequestInfo());
break;
+ case RequestType::Move:
+ context_->pkgid.set(pkgmgr_->GetRequestInfo());
+ context_->is_move_to_external.set(pkgmgr_->GetIsMoveToExternal());
+ break;
case RequestType::Recovery:
context_->file_path.set(pkgmgr_->GetRequestInfo());
context_->pkgid.set(kStrEmpty);
if (storage == Storage::EXTERNAL ||
(!strcmp(manifest->installlocation, kPreferExternal) &&
- storage == Storage::NONE)) {
+ storage == Storage::NONE) ||
+ context_->request_type.get() == RequestType::Move) {
context_->external_storage =
ExternalStorage::AcquireExternalStorage(context_->request_type.get(),
context_->root_application_path.get(),
--- /dev/null
+// 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_move_installed_storage.h"
+
+#include "common/external_storage.h"
+
+namespace common_installer {
+namespace filesystem {
+
+Step::Status StepMoveInstalledStorage::process() {
+ context_->external_storage =
+ ExternalStorage::MoveInstalledStorage(context_->request_type.get(),
+ context_->root_application_path.get(),
+ context_->pkgid.get(),
+ context_->pkg_type.get(),
+ context_->uid.get(),
+ context_->is_move_to_external.get());
+ if (!context_->external_storage) {
+ LOG(ERROR) << "Cannot initialize external storage for move";
+ return Status::APP_DIR_ERROR;
+ }
+
+ return Status::OK;
+}
+
+} // namespace filesystem
+} // namespace common_installer
+
--- /dev/null
+// 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_MOVE_INSTALLED_STORAGE_H_
+#define COMMON_STEP_FILESYSTEM_STEP_MOVE_INSTALLED_STORAGE_H_
+
+#include "common/installer_context.h"
+#include "common/step/step.h"
+
+namespace common_installer {
+namespace filesystem {
+
+class StepMoveInstalledStorage : public Step {
+ public:
+ using Step::Step;
+
+ Status process() override;
+
+ Status clean() override { return Status::OK; }
+ Status undo() override { return Status::OK; }
+ Status precheck() override { return Status::OK; }
+
+ STEP_NAME(MoveInstalledStorage)
+};
+
+} // namespace filesystem
+} // namespace common_installer
+
+#endif // COMMON_STEP_FILESYSTEM_STEP_MOVE_INSTALLED_STORAGE_H_