Add InstallationMode to InstallerContext 76/57876/4
authorArkadiusz Szulakiewicz <a.szulakiewi@partner.samsung.com>
Mon, 25 Jan 2016 13:15:18 +0000 (14:15 +0100)
committerTomasz Iwanek <t.iwanek@samsung.com>
Tue, 26 Jan 2016 11:51:24 +0000 (03:51 -0800)
Change-Id: I2cc21d4d79cb2187f65bfa04d152990b67b92333

src/common/app_installer.cc
src/common/installer_context.h
src/common/pkgmgr_interface.cc
src/common/pkgmgr_interface.h

index a3dcd52e249682d33a84cf885027e6697c942939..76eaeca1f2b0fa077b6b7ea729ad1636c68b66ec 100644 (file)
@@ -27,6 +27,7 @@ AppInstaller::AppInstaller(const char* package_type, PkgMgrPtr pkgmgr)
   // TODO(p.sikorski) below property is only used in AppInstaller.
   // maybe it should then be kept in AppInstaller
   context_->pkg_type.set(package_type);
+  context_->installation_mode.set(pkgmgr->GetInstallationMode());
 }
 
 AppInstaller::~AppInstaller() {
index df51dd772366d0778f7a57b70b58d2178d94d51c..5bf43ba5bb4c6919f5dbf2068faed49dd4fefdc5 100644 (file)
@@ -19,6 +19,7 @@
 #include <utility>
 #include <vector>
 
+#include "common/pkgmgr_interface.h"
 #include "common/recovery_file.h"
 #include "common/request.h"
 #include "common/utils/property.h"
@@ -261,6 +262,11 @@ class InstallerContext {
    * \brief request type received from pkgmgr_installer
    */
   Property<RequestType> request_type;
+
+  /**
+   * \brief installation mode (ONLINE / OFFLINE)
+   */
+  Property<InstallationMode> installation_mode;
 };
 
 }  // namespace common_installer
index 61630d88b7182a9433ebac918030fe8232cc56f3..980b5dddec9521d276f4febffc70f9f85de6c6c8 100644 (file)
@@ -46,6 +46,9 @@ int PkgMgrInterface::InitInternal(int argc, char** argv) {
       LOG(ERROR) << "Cannot create pkgmgr_installer object. Aborting.";
       return ENOMEM;
     }
+    install_mode_ = InstallationMode::OFFLINE;
+  } else {
+    install_mode_ = InstallationMode::ONLINE;
   }
 
   int result = pkgmgr_installer_receive_request(pi_, argc, argv);
index 5bbd935abb2c41e9601cf26519a0fae6521a8262..d65c558a4858120fc1567fe856368daae95e9dc4 100644 (file)
 
 namespace common_installer {
 
+enum class InstallationMode {
+  ONLINE,
+  OFFLINE
+};
+
 class PkgMgrInterface;
 typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
 
@@ -73,18 +78,29 @@ class PkgMgrInterface {
    */
   DEPRECATED pkgmgr_installer *GetRawPi() const { return pi_; }
 
+  /**
+  * Returns installation mode
+  *
+  * \return 'ONLINE' for online installation, 'OFFLINE' otherwise
+  */
+  InstallationMode GetInstallationMode() const { return install_mode_; }
+
+
   /** PkgMgrInstance destructor. */
   ~PkgMgrInterface();
 
  private:
   explicit PkgMgrInterface(AppQueryInterface* interface)
       : pi_(nullptr),
+        install_mode_(InstallationMode::ONLINE),
         is_app_installed_(false),
         query_interface_(interface) {}
   int InitInternal(int argc, char** argv);
 
   pkgmgr_installer* pi_;
+  InstallationMode install_mode_;
   bool is_app_installed_;
+
   AppQueryInterface* query_interface_;
 
   SCOPE_LOG_TAG(PkgMgrInterface)