Refine sending pkgmgr signal for recovery 64/167964/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Mon, 22 Jan 2018 06:30:48 +0000 (15:30 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 23 Jan 2018 07:56:16 +0000 (07:56 +0000)
Set request type differently to each recovery mode.
Recovery for install will emit uninstall signal, and recovery for
update(RecoveryUpdate) will emit upgrade signal.

Change-Id: I619e041e9541ef00d84bdbe1150aa4265e60e67a
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/common/app_installer.cc
src/common/pkgmgr_interface.cc
src/common/pkgmgr_signal.cc
src/common/pkgmgr_signal.h
src/common/request.h
src/common/step/recovery/step_open_recovery_file.cc

index ef2cf99..5dbd755 100644 (file)
@@ -80,6 +80,8 @@ AppInstaller::Result AppInstaller::Run() {
       // send START signal as soon as possible if not sent
       if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
         if (!context_->pkgid.get().empty()) {
+          // set request type before sending start signal
+          pi_->SetRequestType(context_->request_type.get());
           pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
         }
       }
@@ -131,6 +133,8 @@ AppInstaller::Result AppInstaller::Run() {
   if (pi_) {
     // send START if pkgid was not parsed
     if (pi_->state() == PkgmgrSignal::State::NOT_SENT) {
+      // set request type before sending start signal
+      pi_->SetRequestType(context_->request_type.get());
       pi_->SendStarted(context_->pkg_type.get(), context_->pkgid.get());
     }
     pi_->SendFinished(process_status,
index 82fd336..cbe4f3c 100644 (file)
@@ -263,7 +263,7 @@ bool PkgMgrInterface::GetIsPartialRW() const {
 std::unique_ptr<PkgmgrSignal> PkgMgrInterface::CreatePkgmgrSignal() const {
   if (!pkgmgr_installer_interface_->ShouldCreateSignal())
     return nullptr;
-  return std::unique_ptr<PkgmgrSignal>(new PkgmgrSignal(pi_, GetRequestType()));
+  return std::unique_ptr<PkgmgrSignal>(new PkgmgrSignal(pi_));
 }
 
 bool PkgMgrInterface::GetIsForceRemoval() const {
index d544423..13336b7 100644 (file)
@@ -24,7 +24,8 @@ namespace ci = common_installer;
 const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
 const std::map<ci::RequestType, const char*> kEventStr = {
   {ci::RequestType::Install, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
-  {ci::RequestType::Recovery, PKGMGR_INSTALLER_INSTALL_EVENT_STR},
+  {ci::RequestType::Recovery, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
+  {ci::RequestType::RecoveryUpdate, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
   {ci::RequestType::Reinstall, PKGMGR_INSTALLER_UPGRADE_EVENT_STR},
   {ci::RequestType::Uninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
   {ci::RequestType::PartialUninstall, PKGMGR_INSTALLER_UNINSTALL_EVENT_STR},
@@ -52,8 +53,8 @@ namespace common_installer {
 
 PkgmgrSignal::State PkgmgrSignal::state_ = PkgmgrSignal::State::NOT_SENT;
 
-PkgmgrSignal::PkgmgrSignal(pkgmgr_installer* pi, RequestType req_type)
-    : pi_(pi), request_type_(req_type), error_message_sent_(false) {
+PkgmgrSignal::PkgmgrSignal(pkgmgr_installer* pi)
+    : pi_(pi), request_type_(RequestType::Unknown), error_message_sent_(false) {
   uid_ = pkgmgr_installer_get_uid(pi_);
   request_mode_ = GetRequestMode(uid_);
 }
@@ -168,6 +169,10 @@ bool PkgmgrSignal::SendError(
   return true;
 }
 
+void PkgmgrSignal::SetRequestType(RequestType req_type) {
+  request_type_ = req_type;
+}
+
 bool PkgmgrSignal::SendSignal(
     const char* key,
     const char* value,
index b5bbd84..143d86f 100644 (file)
@@ -41,9 +41,8 @@ class PkgmgrSignal {
    * Constructor
    *
    * \param pi pointer for pkgmgr_installer structure
-   * \param req_type request type
    */
-  explicit PkgmgrSignal(pkgmgr_installer* pi, RequestType req_type);
+  explicit PkgmgrSignal(pkgmgr_installer* pi);
 
   /**
    * "start" Signal sending
@@ -97,6 +96,13 @@ class PkgmgrSignal {
   bool IsFinished() const;
 
   /**
+   * Set current request type
+   *
+   * \param req_type request type
+   */
+  void SetRequestType(RequestType req_type);
+
+  /**
    * Getter of state of the object
    *
    *\return current state
index 9fd344e..a42d852 100644 (file)
@@ -21,6 +21,7 @@ enum class RequestType : int {
   Delta,
   Move,
   Recovery,
+  RecoveryUpdate,
   MountInstall,
   MountUpdate,
   ManifestDirectInstall,
index e654ae9..271164e 100644 (file)
@@ -28,18 +28,25 @@ Step::Status StepOpenRecoveryFile::process() {
       break;
     case RequestType::Update:
       LOG(INFO) << "Running recovery for update installation";
+      // There are two recovery types. One is recovery of install,
+      // the other is recovery of update. They should have send
+      // different signal.
+      context_->request_type.set(RequestType::RecoveryUpdate);
       break;
     case RequestType::Delta:
       LOG(INFO) << "Running recovery for delta installation";
+      context_->request_type.set(RequestType::RecoveryUpdate);
       break;
     case RequestType::MountInstall:
       LOG(INFO) << "Running recovery for mount install installation";
       break;
     case RequestType::MountUpdate:
       LOG(INFO) << "Running recovery for mount update installation";
+      context_->request_type.set(RequestType::RecoveryUpdate);
       break;
     case RequestType::ReadonlyUpdateInstall:
       LOG(INFO) << "Running recovery for readonly update installation";
+      context_->request_type.set(RequestType::RecoveryUpdate);
       context_->is_readonly_package.set(true);
       context_->root_application_path.set(
           GetRootAppPath(true, context_->uid.get()));