summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlho Kim <ilho159.kim@samsung.com>2024-04-15 12:03:22 +0900
committerIlho Kim <ilho159.kim@samsung.com>2024-04-16 12:02:30 +0900
commitb0baac7866dd1489e9ed2071f13c57a8f55f5433 (patch)
treef3225d09a505de51ac44e87e4b603f364de94228
parenta8abe4a18ff0a3b5da8eee8033d08e1a3dd11b67 (diff)
downloadslp-pkgmgr-b0baac7866dd1489e9ed2071f13c57a8f55f5433.tar.gz
slp-pkgmgr-b0baac7866dd1489e9ed2071f13c57a8f55f5433.tar.bz2
slp-pkgmgr-b0baac7866dd1489e9ed2071f13c57a8f55f5433.zip
Implement pkgmgr_client_set_status_type
Change-Id: I0808d8d4bbefbfe142c0d9f7c419f7933e2930f3 Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
-rw-r--r--client/src/api_stub.cc9
-rw-r--r--client/src/connector.cc7
-rw-r--r--client/src/connector.hh5
-rw-r--r--client/src/signal_receiver.cc64
-rw-r--r--client/src/signal_receiver.hh4
5 files changed, 83 insertions, 6 deletions
diff --git a/client/src/api_stub.cc b/client/src/api_stub.cc
index d3439e1..b60ae41 100644
--- a/client/src/api_stub.cc
+++ b/client/src/api_stub.cc
@@ -1159,7 +1159,14 @@ API int pkgmgr_client_clear_user_data_with_path(pkgmgr_client *pc, const char *p
}
API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type) {
- //TODO
+ if (pc == nullptr) {
+ _E("invalid parameter");
+ return PKGMGR_R_EINVAL;
+ }
+
+ auto* con = static_cast<Connector*>(pc);
+ con->SetStatusType(status_type);
+
return PKGMGR_R_OK;
}
diff --git a/client/src/connector.cc b/client/src/connector.cc
index c968eb9..a9e0948 100644
--- a/client/src/connector.cc
+++ b/client/src/connector.cc
@@ -82,6 +82,10 @@ void Connector::SetSkipOptimization() {
argv_.push_back("-S");
}
+void Connector::SetStatusType(int status_type) {
+ status_type_ = status_type;
+}
+
const std::vector<std::string>& Connector::GetArgv() const {
return argv_;
}
@@ -188,7 +192,8 @@ bool Connector::ConnectForDelayedResult() {
const std::unique_ptr<SignalReceiver>& Connector::GetSignalReceiver() {
if (!signal_receiver_)
- signal_receiver_.reset(new SignalReceiver(__is_system_type(pc_type_)));
+ signal_receiver_.reset(
+ new SignalReceiver(__is_system_type(pc_type_), status_type_));
return signal_receiver_;
}
diff --git a/client/src/connector.hh b/client/src/connector.hh
index 89f8697..e81b6fe 100644
--- a/client/src/connector.hh
+++ b/client/src/connector.hh
@@ -37,7 +37,8 @@ namespace pp = rpc_port::PkgMgrProxy;
class Connector {
public:
- Connector(pkgmgr_client_type pc_type) : pc_type_(pc_type) {}
+ Connector(pkgmgr_client_type pc_type) : pc_type_(pc_type),
+ status_type_(PKGMGR_CLIENT_STATUS_ALL) {}
virtual ~Connector();
virtual pkg_proxy::PkgMgrAdmin* GetAdminProxy();
@@ -50,6 +51,7 @@ class Connector {
void SetTepArgs();
void SetDebugMode();
void SetSkipOptimization();
+ void SetStatusType(int status_type);
const std::vector<std::string>& GetArgv() const;
pkgmgr_client_type GetPcType() const;
std::vector<std::string>& GetResRemovePath();
@@ -66,6 +68,7 @@ class Connector {
private:
pkgmgr_client_type pc_type_;
+ int status_type_;
std::unique_ptr<pkg_proxy::PkgMgr> info_proxy_;
std::unique_ptr<pkg_proxy::PkgMgrForClearCache> cache_proxy_;
std::unique_ptr<pkg_proxy::PkgMgrAdmin> admin_proxy_;
diff --git a/client/src/signal_receiver.cc b/client/src/signal_receiver.cc
index eac5686..b4761f0 100644
--- a/client/src/signal_receiver.cc
+++ b/client/src/signal_receiver.cc
@@ -18,21 +18,65 @@
#include "signal_receiver.hh"
+#include "log.hh"
+#include "../../installer/src/pkgmgr_installer.h"
+
namespace pkgmgr {
namespace client {
#define AGENT_APPID "signal_agent"
-SignalReceiver::SignalReceiver(bool is_system)
- : PkgSignal(is_system ? "" : AGENT_APPID, is_system) {
+SignalReceiver::SignalReceiver(bool is_system, int status_type)
+ : PkgSignal(is_system ? "" : AGENT_APPID, is_system),
+ status_type_(status_type) {
}
SignalReceiver::~SignalReceiver() {
}
+const std::map<std::string, int> signal_map = {
+ {PKGMGR_INSTALLER_INSTALL_EVENT_STR, PKGMGR_CLIENT_STATUS_INSTALL},
+ {PKGMGR_INSTALLER_UNINSTALL_EVENT_STR, PKGMGR_CLIENT_STATUS_UNINSTALL},
+ {PKGMGR_INSTALLER_UPGRADE_EVENT_STR, PKGMGR_CLIENT_STATUS_UPGRADE},
+ {PKGMGR_INSTALLER_CLEAR_EVENT_STR, PKGMGR_CLIENT_STATUS_CLEAR_DATA},
+ {PKGMGR_INSTALLER_MOVE_EVENT_STR, PKGMGR_CLIENT_STATUS_MOVE},
+ {PKGMGR_INSTALLER_INSTALL_PERCENT_KEY_STR,
+ PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS},
+ {PKGMGR_INSTALLER_GET_SIZE_KEY_STR, PKGMGR_CLIENT_STATUS_GET_SIZE},
+ {PKGMGR_INSTALLER_CLEAR_CACHE_KEY_STR,
+ PKGMGR_CLIENT_STATUS_CLEAR_CACHE},
+ {PKGMGR_INSTALLER_APP_ENABLE_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_ENABLE_APP},
+ {PKGMGR_INSTALLER_APP_DISABLE_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_DISABLE_APP},
+ {PKGMGR_INSTALLER_APP_ENABLE_SPLASH_SCREEN_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_ENABLE_APP_SPLASH_SCREEN},
+ {PKGMGR_INSTALLER_APP_DISABLE_SPLASH_SCREEN_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_DISABLE_APP_SPLASH_SCREEN},
+ {PKGMGR_INSTALLER_RES_COPY_EVENT_STR, PKGMGR_CLIENT_STATUS_RES_COPY},
+ {PKGMGR_INSTALLER_RES_CREATE_DIR_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_RES_CREATE_DIR},
+ {PKGMGR_INSTALLER_RES_REMOVE_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_RES_REMOVE},
+ {PKGMGR_INSTALLER_RES_UNINSTALL_EVENT_STR,
+ PKGMGR_CLIENT_STATUS_RES_UNINSTALL}
+};
+
void SignalReceiver::OnAsyncResult(std::string signal, int targetUid,
std::string reqId, std::vector<pkg_signal::PkgInfo> pkgs,
std::string key, std::string val) {
+ if (status_type_ != PKGMGR_CLIENT_STATUS_ALL) {
+ auto it = signal_map.find(signal);
+ if (it == signal_map.end()) {
+ _E("Unexpected signal : %s", signal.c_str());
+ return;
+ }
+
+ if ((it->second & status_type_) == 0) {
+ return;
+ }
+ }
+
HandleHandler(targetUid, reqId, pkgs, key, val);
HandleGlobalHandler(targetUid, reqId, pkgs, key, val);
HandleSizeInfoHandler(reqId, pkgs, key, val);
@@ -116,6 +160,18 @@ void SignalReceiver::HandleSizeInfoHandler(
void SignalReceiver::OnAsyncResultForResource(std::string signal,
int targetUid, std::string reqId, std::string pkgid,
std::string status, pkg_signal::ExtraData extra) {
+ if (status_type_ != PKGMGR_CLIENT_STATUS_ALL) {
+ auto it = signal_map.find(signal);
+ if (it == signal_map.end()) {
+ _E("Unexpected signal : %s", signal.c_str());
+ return;
+ }
+
+ if ((it->second & status_type_) == 0) {
+ return;
+ }
+ }
+
HandleResHandler(signal, targetUid, reqId, pkgid, status, extra);
HandleGlobalResHandler(signal, targetUid, reqId, pkgid, status, extra);
}
@@ -196,6 +252,10 @@ int SignalReceiver::AddEventHandler(pkgmgr_pkg_upgrade_handler event_cb,
return sId;
}
+void SignalReceiver::SetStatusType(int status_type) {
+ status_type_ = status_type;
+}
+
int SignalReceiver::GetRequestId() {
return ++request_id_;
diff --git a/client/src/signal_receiver.hh b/client/src/signal_receiver.hh
index 620c1ca..18a4572 100644
--- a/client/src/signal_receiver.hh
+++ b/client/src/signal_receiver.hh
@@ -36,7 +36,7 @@ namespace pkg_signal = rpc_port::PkgSignal;
class SignalReceiver : public pkg_group::PkgSignal {
public:
- SignalReceiver(bool is_system);
+ SignalReceiver(bool is_system, int status_type);
virtual ~SignalReceiver();
void OnAsyncResult(std::string signal, int targetUid, std::string reqId,
@@ -57,6 +57,7 @@ class SignalReceiver : public pkg_group::PkgSignal {
int AddEventHandler(std::string req_key, pkgmgr_res_handler event_cb,
void* data);
int AddEventHandler(pkgmgr_pkg_upgrade_handler event_cb, void* data);
+ void SetStatusType(int status_type);
private:
static int GetRequestId();
@@ -80,6 +81,7 @@ class SignalReceiver : public pkg_group::PkgSignal {
private:
static inline int request_id_;
+ int status_type_;
std::map<std::string, std::tuple<int, pkgmgr_handler, pkgmgr_app_handler,
void*>> handlers_;
std::list<std::tuple<int, pkgmgr_handler, pkgmgr_app_handler, void*>> global_handlers_;