step/pkgmgr/step_run_parser_plugins.cc
step/pkgmgr/step_unregister_app.cc
step/pkgmgr/step_update_app.cc
+ step/pkgmgr/step_update_pkg_disable_info.cc
step/rds/step_rds_modify.cc
step/rds/step_rds_parse.cc
step/recovery/step_open_recovery_file.cc
return RequestType::MountInstall;
else
return RequestType::MountUpdate;
+ case PKGMGR_REQ_DISABLE_PKG:
+ return RequestType::DisablePkg;
+ case PKGMGR_REQ_ENABLE_PKG:
+ return RequestType::EnablePkg;
default:
return RequestType::Unknown;
}
return true;
}
+bool DisablePkgInPkgmgr(const std::string& pkgid, uid_t uid,
+ RequestMode request_mode) {
+ int ret = request_mode != RequestMode::GLOBAL ?
+ pkgmgr_parser_update_pkg_disable_info_in_usr_db(pkgid.c_str(), uid, 1) :
+ pkgmgr_parser_update_pkg_disable_info_in_db(pkgid.c_str(), 1);
+ if (ret != 0) {
+ LOG(ERROR) << "Failed to disable pkg: " << pkgid;
+ return false;
+ }
+
+ return true;
+}
+
+bool EnablePkgInPkgmgr(const std::string& pkgid, uid_t uid,
+ RequestMode request_mode) {
+ int ret = request_mode != RequestMode::GLOBAL ?
+ pkgmgr_parser_update_pkg_disable_info_in_usr_db(pkgid.c_str(), uid, 0) :
+ pkgmgr_parser_update_pkg_disable_info_in_db(pkgid.c_str(), 0);
+ if (ret != 0) {
+ LOG(ERROR) << "Failed to enable pkg: " << pkgid;
+ return false;
+ }
+
+ return true;
+}
+
} // namespace common_installer
uid_t uid,
RequestMode request_mode);
+/**
+ * \brief Adapter interface for external PkgMgr module used for updating
+ * pkg disable info about package within pkgmgr
+ *
+ * \param pkgid package pkgid
+ * \param uid user id
+ * \param request_mode current request mode
+ *
+ * \return true if success
+ */
+bool DisablePkgInPkgmgr(const std::string& pkgid, uid_t uid,
+ RequestMode request_mode);
+
+/**
+ * \brief Adapter interface for external PkgMgr module used for updating
+ * pkg enable info about package within pkgmgr
+ *
+ * \param pkgid package pkgid
+ * \param uid user id
+ * \param request_mode current request mode
+ *
+ * \return true if success
+ */
+bool EnablePkgInPkgmgr(const std::string& pkgid, uid_t uid,
+ RequestMode request_mode);
+
} // namespace common_installer
#endif // COMMON_PKGMGR_REGISTRATION_H_
{ci::RequestType::MountUpdate, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
{ci::RequestType::ManifestDirectInstall, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::ManifestDirectUpdate, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
+ {ci::RequestType::DisablePkg, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
+ {ci::RequestType::EnablePkg, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
{ci::RequestType::Unknown, PKGMGR_INSTALLER_UNKNOWN_EVENT_STR}
};
MountInstall,
MountUpdate,
ManifestDirectInstall,
- ManifestDirectUpdate
+ ManifestDirectUpdate,
+ DisablePkg,
+ EnablePkg
};
/** Request mode (USER vs GLOBAL) */
context_->xml_path.set(xml_path);
break;
}
+ case RequestType::DisablePkg:
+ case RequestType::EnablePkg:
+ context_->pkgid.set(pkgmgr_->GetRequestInfo());
+ break;
default:
LOG(ERROR) <<
"Only installation, update and uninstallation is now supported";
--- /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/pkgmgr/step_update_pkg_disable_info.h"
+#include "common/pkgmgr_registration.h"
+
+namespace common_installer {
+namespace pkgmgr {
+
+StepUpdatePkgDisableInfo::StepUpdatePkgDisableInfo(
+ common_installer::InstallerContext* context, ActionType action_type)
+ : Step(context), action_type_(action_type) {}
+
+Step::Status StepUpdatePkgDisableInfo::precheck() {
+ if (context_->pkgid.get().empty()) {
+ LOG(ERROR) << "pkgid attribute is empty";
+ return Status::PACKAGE_NOT_FOUND;
+ }
+
+ return Step::Status::OK;
+}
+
+Step::Status StepUpdatePkgDisableInfo::process() {
+ if (action_type_ == ActionType::Disable) {
+ if (!DisablePkgInPkgmgr(context_->pkgid.get(), context_->uid.get(), context_->request_mode.get())) {
+ LOG(ERROR) << "Failed to update pkg info to disable :" << context_->pkgid.get();
+ return Status::REGISTER_ERROR;
+ }
+ } else {
+ if (!EnablePkgInPkgmgr(context_->pkgid.get(), context_->uid.get(), context_->request_mode.get())) {
+ LOG(ERROR) << "Failed to update pkg info to enable :" << context_->pkgid.get();
+ return Status::REGISTER_ERROR;
+ }
+ }
+ LOG(DEBUG) << "Successfully set pkg enable/disable info";
+ return Status::OK;
+}
+
+Step::Status StepUpdatePkgDisableInfo::undo() {
+ if (action_type_ == ActionType::Disable) {
+ if (!EnablePkgInPkgmgr(context_->pkgid.get(), context_->uid.get(), context_->request_mode.get())) {
+ LOG(ERROR) << "Failed to update pkg info to enable : " << context_->pkgid.get();
+ return Status::REGISTER_ERROR;
+ }
+ } else {
+ if (!DisablePkgInPkgmgr(context_->pkgid.get(), context_->uid.get(), context_->request_mode.get())) {
+ LOG(ERROR) << "Failed to update pkg info to disable : " << context_->pkgid.get();
+ return Status::REGISTER_ERROR;
+ }
+ }
+ LOG(DEBUG) << "Successfully undo pkg enable/disable info";
+ return Status::OK;
+}
+
+} // namespace pkgmgr
+} // 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_PKGMGR_STEP_UPDATE_PKG_DISABLE_INFO_H_
+#define COMMON_STEP_PKGMGR_STEP_UPDATE_PKG_DISABLE_INFO_H_
+
+#include <common/app_installer.h>
+#include <common/installer_context.h>
+#include <common/step/step.h>
+
+namespace common_installer {
+namespace pkgmgr {
+
+class StepUpdatePkgDisableInfo : public common_installer::Step {
+ public:
+ using Step::Step;
+ enum class ActionType { Disable, Enable };
+
+ explicit StepUpdatePkgDisableInfo(common_installer::InstallerContext* context,
+ ActionType action_type);
+
+ Step::Status process() override;
+ Step::Status clean() override { return Status::OK; }
+ Step::Status undo() override;
+ Status precheck() override;
+
+ private:
+ ActionType action_type_;
+ STEP_NAME(UpdatePkgDisableInfo)
+};
+
+} // namespace pkgmgr
+} // namespace common_installer
+
+#endif //COMMON_STEP_PKGMGR_STEP_UPDATE_PKG_DISABLE_INFO_H_