Set is_upgrade flag before sending signal 94/238794/6
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 17 Jul 2020 08:54:33 +0000 (17:54 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Fri, 24 Jul 2020 04:12:06 +0000 (13:12 +0900)
There is no way to know whether a request type is "upgrade" when emitting signal
Installer can set upgrade flag before sending signal
and that flag is used to identify request type

Related change:
   [slp-pkgmgr] https://review.tizen.org/gerrit/#/c/platform/core/appfw/slp-pkgmgr/+/237961/
   [slp-pkgmgr] https://review.tizen.org/gerrit/#/c/platform/core/appfw/slp-pkgmgr/+/238789/

Change-Id: Ifcd05d766bd69422c0e7397bad7484282ec2f2b2
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/common/pkgmgr_signal.cc
src/common/pkgmgr_signal.h

index 2c90ecc97b4ce3fb339d258436b3140981c039d2..f5e8211787034cef04bd2181be97c94edda3cbe3 100644 (file)
@@ -54,7 +54,7 @@ namespace common_installer {
 
 PkgmgrSignal::PkgmgrSignal(pkgmgr_installer* pi)
     : pi_(pi), state_(State::NOT_SENT), request_type_(RequestType::Unknown),
-      error_message_sent_(false) {
+      error_message_sent_(false), is_upgrade_(false) {
   uid_ = pkgmgr_installer_get_uid(pi_);
   request_mode_ = GetRequestMode(uid_);
 }
@@ -71,6 +71,11 @@ bool PkgmgrSignal::SendStarted(
   if (key == kEventStr.end())
     return false;
 
+  if (strcmp(key->second, PKGMGR_INSTALLER_UPGRADE_EVENT_STR) == 0)
+    is_upgrade_ = true;
+
+  pkgmgr_installer_set_is_upgrade(pi_, is_upgrade_ ? 1 : 0);
+
   if (!SendSignal(PKGMGR_INSTALLER_START_KEY_STR, key->second, type, pkgid))
     return false;
 
@@ -117,6 +122,8 @@ bool PkgmgrSignal::SendFinished(
   if (state_ != State::STARTED)
     return false;
 
+  pkgmgr_installer_set_is_upgrade(pi_, is_upgrade_ ? 1 : 0);
+
   if (result != Step::Status::OK && !error_message_sent_) {
     if (!SendSignal(
         PKGMGR_INSTALLER_ERROR_KEY_STR,
@@ -147,6 +154,8 @@ bool PkgmgrSignal::SendError(
   if (state_ != State::STARTED)
     return false;
 
+  pkgmgr_installer_set_is_upgrade(pi_, is_upgrade_ ? 1 : 0);
+
   std::string error_value = std::to_string(static_cast<int>(result));
   if (!error_message.empty())
     error_value = error_value + ":" + error_message;
index 073232a89dca1100257dc0c37d8f89389e91182c..a9db342bb0149f3e9f120b4ce4a875afdb59489a 100644 (file)
@@ -133,6 +133,7 @@ class PkgmgrSignal {
   RequestMode request_mode_;
   uid_t uid_;
   bool error_message_sent_;
+  bool is_upgrade_;
   std::vector<std::pair<uid_t, RequestType>> user_list_;
 
   DISALLOW_COPY_AND_ASSIGN(PkgmgrSignal);