Remove tidl dependency
authorIlho Kim <ilho159.kim@samsung.com>
Thu, 28 Mar 2024 13:15:48 +0000 (22:15 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Thu, 28 Mar 2024 13:15:48 +0000 (22:15 +0900)
Change-Id: I80a7d008c563496db6108a73e1ec341eefe47224
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
client/src/PkgMgrProxy.cc [new file with mode: 0644]
client/src/PkgMgrProxy.h [new file with mode: 0644]
client/src/signal_receiver.cc [deleted file]
client/src/signal_receiver.hh [deleted file]
packaging/pkgmgr.spec

diff --git a/client/src/PkgMgrProxy.cc b/client/src/PkgMgrProxy.cc
new file mode 100644 (file)
index 0000000..a0465e0
--- /dev/null
@@ -0,0 +1,3665 @@
+/*
+ * Generated by tidlc 2.0.4.
+ */
+
+#include <stdlib.h>
+#include <assert.h>
+#include <dlog.h>
+
+#include "PkgMgrProxy.h"
+
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "RPC_PORT_PROXY"
+
+#ifdef _E
+#undef _E
+#endif
+
+#ifdef _W
+#undef _W
+#endif
+
+#ifdef _I
+#undef _I
+#endif
+
+#ifdef _D
+#undef _D
+#endif
+
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > " fmt, basename(const_cast<char*>(__FILE__)), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#ifndef TIDL_VERSION
+#define TIDL_VERSION "2.0.4"
+#endif
+
+namespace rpc_port {
+namespace PkgMgrProxy {
+
+ResPath::ResPath() {}
+
+ResPath::ResPath(std::string From, std::string To)
+    : From_(std::move(From)), To_(std::move(To)) {}
+
+
+namespace proxy {
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const ResPath& param);
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, ResPath& param);
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const std::vector<ResPath>& param);
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, std::vector<ResPath>& param);
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const std::vector<std::string>& param);
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, std::vector<std::string>& param);
+
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const ResPath& param) {
+  rpc_port_parcel_write_string(h, param.GetFrom().c_str());
+  rpc_port_parcel_write_string(h, param.GetTo().c_str());
+  return h;
+}
+
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, ResPath& param) {
+  char* From_raw  = nullptr;
+  rpc_port_parcel_read_string(h, &From_raw);
+  std::string From(From_raw);
+  free(From_raw);
+  param.SetFrom(std::move(From));
+
+  char* To_raw  = nullptr;
+  rpc_port_parcel_read_string(h, &To_raw);
+  std::string To(To_raw);
+  free(To_raw);
+  param.SetTo(std::move(To));
+
+  return h;
+}
+
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const std::vector<ResPath>& param) {
+  rpc_port_parcel_write_array_count(h, param.size());
+  for (const auto& i : param) {
+    h << i;
+
+  }
+
+  return h;
+}
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, std::vector<ResPath>& param) {
+  int l = 0;
+  rpc_port_parcel_read_array_count(h, &l);
+
+  for (int i = 0; i < l; i++) {
+    ResPath v;
+    h >> v;
+
+    param.push_back(std::move(v));
+  }
+
+  return h;
+}
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const std::vector<std::string>& param) {
+  rpc_port_parcel_write_array_count(h, param.size());
+  for (const auto& i : param) {
+    rpc_port_parcel_write_string(h, i.c_str());
+
+  }
+
+  return h;
+}
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, std::vector<std::string>& param) {
+  int l = 0;
+  rpc_port_parcel_read_array_count(h, &l);
+
+  for (int i = 0; i < l; i++) {
+    char* v_raw  = nullptr;
+    rpc_port_parcel_read_string(h, &v_raw);
+    std::string v(v_raw);
+    free(v_raw);
+
+    param.push_back(std::move(v));
+  }
+
+  return h;
+}
+
+std::atomic<int> PkgMgrForClearCache::CallbackBase::seq_num_ { 0 };
+
+PkgMgrForClearCache::CallbackBase::CallbackBase(int delegate_id, bool once)
+    : id_(delegate_id), once_(once) {
+  seq_id_ = seq_num_++;
+}
+
+int PkgMgrForClearCache::CallbackBase::GetId() const {
+  return id_;
+}
+
+int PkgMgrForClearCache::CallbackBase::GetSeqId() const {
+  return seq_id_;
+}
+
+bool PkgMgrForClearCache::CallbackBase::IsOnce() const {
+  return once_;
+}
+
+std::string PkgMgrForClearCache::CallbackBase::GetTag() const {
+  return std::to_string(id_) + "::" + std::to_string(seq_id_);
+}
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const PkgMgrForClearCache::CallbackBase& cb) {
+  rpc_port_parcel_write_int32(h, cb.id_);
+  rpc_port_parcel_write_int32(h, cb.seq_id_);
+  rpc_port_parcel_write_bool(h, cb.once_);
+
+  return h;
+}
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, PkgMgrForClearCache::CallbackBase& cb) {
+  rpc_port_parcel_read_int32(h, &cb.id_);
+  rpc_port_parcel_read_int32(h, &cb.seq_id_);
+  rpc_port_parcel_read_bool(h, &cb.once_);
+
+  return h;
+}
+
+PkgMgrForClearCache::PkgMgrForClearCache(IEventListener* listener, const std::string& target_appid)
+    : port_(nullptr), callback_port_(nullptr), proxy_(nullptr),
+      listener_(listener), target_appid_(target_appid) {
+  int r = rpc_port_proxy_create(&proxy_);
+
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create proxy");
+    throw InvalidIOException();
+  }
+
+  rpc_port_proxy_add_connected_event_cb(proxy_, OnConnectedCB, this);
+  rpc_port_proxy_add_disconnected_event_cb(proxy_, OnDisconnectedCB, this);
+  rpc_port_proxy_add_rejected_event_cb(proxy_, OnRejectedCB, this);
+  rpc_port_proxy_add_received_event_cb(proxy_, OnReceivedCB, this);
+}
+
+PkgMgrForClearCache::~PkgMgrForClearCache() {
+  if (proxy_)
+    rpc_port_proxy_destroy(proxy_);
+}
+
+void PkgMgrForClearCache::Connect(bool sync) {
+  int ret;
+  if (sync)
+    ret = rpc_port_proxy_connect_sync(proxy_, target_appid_.c_str(), "PkgMgrForClearCache");
+  else
+    ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "PkgMgrForClearCache");
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to connect PkgMgrForClearCache");
+    switch (ret) {
+      case RPC_PORT_ERROR_INVALID_PARAMETER:
+        throw InvalidIDException();
+
+      case RPC_PORT_ERROR_IO_ERROR:
+        throw InvalidIOException();
+
+      case RPC_PORT_ERROR_PERMISSION_DENIED:
+        throw PermissionDeniedException();
+    }
+  }
+}
+
+void PkgMgrForClearCache::Disconnect() {
+  int ret = rpc_port_disconnect(port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to disconnect PkgMgrForClearCache");
+    throw InvalidIDException();
+  }
+}
+
+void PkgMgrForClearCache::DisposeCallback(const std::string& tag) {
+  for (auto& i : delegate_list_) {
+    if (i->GetTag() == tag) {
+      delegate_list_.remove(i);
+      return;
+    }
+  }
+}
+
+void PkgMgrForClearCache::ProcessReceivedEvent(rpc_port_parcel_h parcel) {
+  int id = 0;
+  int seq_id = 0;
+  bool once = false;
+
+  rpc_port_parcel_read_int32(parcel, &id);
+  rpc_port_parcel_read_int32(parcel, &seq_id);
+  rpc_port_parcel_read_bool(parcel, &once);
+
+  for (auto& i : delegate_list_) {
+    if (i->GetId() == id && i->GetSeqId() == seq_id) {
+      i->OnReceivedEvent(parcel);
+      if (i->IsOnce())
+        delegate_list_.remove(i);
+      break;
+    }
+  }
+}
+
+void PkgMgrForClearCache::ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port) {
+  do {
+    rpc_port_parcel_h p;
+    int ret = rpc_port_parcel_create_from_port(&p, port);
+    int cmd;
+
+    if (ret != 0)
+      break;
+    rpc_port_parcel_read_int32(p, &cmd);
+    if (cmd == static_cast<int>(MethodId::__Result)) {
+      *parcel = p;
+      return;
+    }
+
+    rpc_port_parcel_destroy(p);
+    *parcel = nullptr;
+  } while (true);
+  *parcel = nullptr;
+}
+
+void PkgMgrForClearCache::OnConnectedCB(const char *ep, const char *port_name, rpc_port_h port, void *data) {
+  PkgMgrForClearCache* l = static_cast<PkgMgrForClearCache*>(data);
+  rpc_port_h cb_port;
+
+  l->port_ = port;
+  rpc_port_proxy_get_port(l->proxy_, RPC_PORT_PORT_CALLBACK, &cb_port);
+  l->callback_port_ = cb_port;
+  l->listener_->OnConnected();
+}
+
+void PkgMgrForClearCache::OnDisconnectedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgrForClearCache* l = static_cast<PkgMgrForClearCache*>(data);
+  l->delegate_list_.clear();
+  l->listener_->OnDisconnected();
+}
+
+void PkgMgrForClearCache::OnRejectedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgrForClearCache* l = static_cast<PkgMgrForClearCache*>(data);
+  l->listener_->OnRejected();
+}
+
+void PkgMgrForClearCache::OnReceivedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgrForClearCache* l = static_cast<PkgMgrForClearCache*>(data);
+  int cmd;
+  rpc_port_parcel_h parcel_received;
+
+  if (rpc_port_parcel_create_from_port(&parcel_received, l->callback_port_) != 0) {
+    _E("Failed to create parcel from port");
+    return;
+  }
+
+  rpc_port_parcel_read_int32(parcel_received, &cmd);
+  if (cmd != static_cast<int>(MethodId::__Callback)) {
+    rpc_port_parcel_destroy(parcel_received);
+    return;
+  }
+
+  l->ProcessReceivedEvent(parcel_received);
+  rpc_port_parcel_destroy(parcel_received);
+}
+
+
+int PkgMgrForClearCache::ClearCache(int uid, std::string pkgid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ClearCache));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+std::atomic<int> PkgMgr::CallbackBase::seq_num_ { 0 };
+
+PkgMgr::CallbackBase::CallbackBase(int delegate_id, bool once)
+    : id_(delegate_id), once_(once) {
+  seq_id_ = seq_num_++;
+}
+
+int PkgMgr::CallbackBase::GetId() const {
+  return id_;
+}
+
+int PkgMgr::CallbackBase::GetSeqId() const {
+  return seq_id_;
+}
+
+bool PkgMgr::CallbackBase::IsOnce() const {
+  return once_;
+}
+
+std::string PkgMgr::CallbackBase::GetTag() const {
+  return std::to_string(id_) + "::" + std::to_string(seq_id_);
+}
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const PkgMgr::CallbackBase& cb) {
+  rpc_port_parcel_write_int32(h, cb.id_);
+  rpc_port_parcel_write_int32(h, cb.seq_id_);
+  rpc_port_parcel_write_bool(h, cb.once_);
+
+  return h;
+}
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, PkgMgr::CallbackBase& cb) {
+  rpc_port_parcel_read_int32(h, &cb.id_);
+  rpc_port_parcel_read_int32(h, &cb.seq_id_);
+  rpc_port_parcel_read_bool(h, &cb.once_);
+
+  return h;
+}
+
+PkgMgr::PkgMgr(IEventListener* listener, const std::string& target_appid)
+    : port_(nullptr), callback_port_(nullptr), proxy_(nullptr),
+      listener_(listener), target_appid_(target_appid) {
+  int r = rpc_port_proxy_create(&proxy_);
+
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create proxy");
+    throw InvalidIOException();
+  }
+
+  rpc_port_proxy_add_connected_event_cb(proxy_, OnConnectedCB, this);
+  rpc_port_proxy_add_disconnected_event_cb(proxy_, OnDisconnectedCB, this);
+  rpc_port_proxy_add_rejected_event_cb(proxy_, OnRejectedCB, this);
+  rpc_port_proxy_add_received_event_cb(proxy_, OnReceivedCB, this);
+}
+
+PkgMgr::~PkgMgr() {
+  if (proxy_)
+    rpc_port_proxy_destroy(proxy_);
+}
+
+void PkgMgr::Connect(bool sync) {
+  int ret;
+  if (sync)
+    ret = rpc_port_proxy_connect_sync(proxy_, target_appid_.c_str(), "PkgMgr");
+  else
+    ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "PkgMgr");
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to connect PkgMgr");
+    switch (ret) {
+      case RPC_PORT_ERROR_INVALID_PARAMETER:
+        throw InvalidIDException();
+
+      case RPC_PORT_ERROR_IO_ERROR:
+        throw InvalidIOException();
+
+      case RPC_PORT_ERROR_PERMISSION_DENIED:
+        throw PermissionDeniedException();
+    }
+  }
+}
+
+void PkgMgr::Disconnect() {
+  int ret = rpc_port_disconnect(port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to disconnect PkgMgr");
+    throw InvalidIDException();
+  }
+}
+
+void PkgMgr::DisposeCallback(const std::string& tag) {
+  for (auto& i : delegate_list_) {
+    if (i->GetTag() == tag) {
+      delegate_list_.remove(i);
+      return;
+    }
+  }
+}
+
+void PkgMgr::ProcessReceivedEvent(rpc_port_parcel_h parcel) {
+  int id = 0;
+  int seq_id = 0;
+  bool once = false;
+
+  rpc_port_parcel_read_int32(parcel, &id);
+  rpc_port_parcel_read_int32(parcel, &seq_id);
+  rpc_port_parcel_read_bool(parcel, &once);
+
+  for (auto& i : delegate_list_) {
+    if (i->GetId() == id && i->GetSeqId() == seq_id) {
+      i->OnReceivedEvent(parcel);
+      if (i->IsOnce())
+        delegate_list_.remove(i);
+      break;
+    }
+  }
+}
+
+void PkgMgr::ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port) {
+  do {
+    rpc_port_parcel_h p;
+    int ret = rpc_port_parcel_create_from_port(&p, port);
+    int cmd;
+
+    if (ret != 0)
+      break;
+    rpc_port_parcel_read_int32(p, &cmd);
+    if (cmd == static_cast<int>(MethodId::__Result)) {
+      *parcel = p;
+      return;
+    }
+
+    rpc_port_parcel_destroy(p);
+    *parcel = nullptr;
+  } while (true);
+  *parcel = nullptr;
+}
+
+void PkgMgr::OnConnectedCB(const char *ep, const char *port_name, rpc_port_h port, void *data) {
+  PkgMgr* l = static_cast<PkgMgr*>(data);
+  rpc_port_h cb_port;
+
+  l->port_ = port;
+  rpc_port_proxy_get_port(l->proxy_, RPC_PORT_PORT_CALLBACK, &cb_port);
+  l->callback_port_ = cb_port;
+  l->listener_->OnConnected();
+}
+
+void PkgMgr::OnDisconnectedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgr* l = static_cast<PkgMgr*>(data);
+  l->delegate_list_.clear();
+  l->listener_->OnDisconnected();
+}
+
+void PkgMgr::OnRejectedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgr* l = static_cast<PkgMgr*>(data);
+  l->listener_->OnRejected();
+}
+
+void PkgMgr::OnReceivedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgr* l = static_cast<PkgMgr*>(data);
+  int cmd;
+  rpc_port_parcel_h parcel_received;
+
+  if (rpc_port_parcel_create_from_port(&parcel_received, l->callback_port_) != 0) {
+    _E("Failed to create parcel from port");
+    return;
+  }
+
+  rpc_port_parcel_read_int32(parcel_received, &cmd);
+  if (cmd != static_cast<int>(MethodId::__Callback)) {
+    rpc_port_parcel_destroy(parcel_received);
+    return;
+  }
+
+  l->ProcessReceivedEvent(parcel_received);
+  rpc_port_parcel_destroy(parcel_received);
+}
+
+
+int PkgMgr::GetSize(int uid, std::string pkgid, int getType, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::GetSize));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+  rpc_port_parcel_write_int32(p, getType);
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgr::GetSizeSync(int uid, std::string pkgid, int getType, std::string& ReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::GetSizeSync));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+  rpc_port_parcel_write_int32(p, getType);
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* ReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &ReqKey_raw);
+    ReqKey = ReqKey_raw;
+    free(ReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgr::GetSizeSyncResult(std::string reqKey, int& result, long long& sizeInfo) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::GetSizeSyncResult));
+  rpc_port_parcel_write_string(p, reqKey.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &result);
+    rpc_port_parcel_read_int64(parcel_received, &sizeInfo);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgr::Check(int uid, std::string pkgid, int& pid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::Check));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &pid);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+std::atomic<int> PkgMgrAdmin::CallbackBase::seq_num_ { 0 };
+
+PkgMgrAdmin::CallbackBase::CallbackBase(int delegate_id, bool once)
+    : id_(delegate_id), once_(once) {
+  seq_id_ = seq_num_++;
+}
+
+int PkgMgrAdmin::CallbackBase::GetId() const {
+  return id_;
+}
+
+int PkgMgrAdmin::CallbackBase::GetSeqId() const {
+  return seq_id_;
+}
+
+bool PkgMgrAdmin::CallbackBase::IsOnce() const {
+  return once_;
+}
+
+std::string PkgMgrAdmin::CallbackBase::GetTag() const {
+  return std::to_string(id_) + "::" + std::to_string(seq_id_);
+}
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const PkgMgrAdmin::CallbackBase& cb) {
+  rpc_port_parcel_write_int32(h, cb.id_);
+  rpc_port_parcel_write_int32(h, cb.seq_id_);
+  rpc_port_parcel_write_bool(h, cb.once_);
+
+  return h;
+}
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, PkgMgrAdmin::CallbackBase& cb) {
+  rpc_port_parcel_read_int32(h, &cb.id_);
+  rpc_port_parcel_read_int32(h, &cb.seq_id_);
+  rpc_port_parcel_read_bool(h, &cb.once_);
+
+  return h;
+}
+
+PkgMgrAdmin::PkgMgrAdmin(IEventListener* listener, const std::string& target_appid)
+    : port_(nullptr), callback_port_(nullptr), proxy_(nullptr),
+      listener_(listener), target_appid_(target_appid) {
+  int r = rpc_port_proxy_create(&proxy_);
+
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create proxy");
+    throw InvalidIOException();
+  }
+
+  rpc_port_proxy_add_connected_event_cb(proxy_, OnConnectedCB, this);
+  rpc_port_proxy_add_disconnected_event_cb(proxy_, OnDisconnectedCB, this);
+  rpc_port_proxy_add_rejected_event_cb(proxy_, OnRejectedCB, this);
+  rpc_port_proxy_add_received_event_cb(proxy_, OnReceivedCB, this);
+}
+
+PkgMgrAdmin::~PkgMgrAdmin() {
+  if (proxy_)
+    rpc_port_proxy_destroy(proxy_);
+}
+
+void PkgMgrAdmin::Connect(bool sync) {
+  int ret;
+  if (sync)
+    ret = rpc_port_proxy_connect_sync(proxy_, target_appid_.c_str(), "PkgMgrAdmin");
+  else
+    ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "PkgMgrAdmin");
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to connect PkgMgrAdmin");
+    switch (ret) {
+      case RPC_PORT_ERROR_INVALID_PARAMETER:
+        throw InvalidIDException();
+
+      case RPC_PORT_ERROR_IO_ERROR:
+        throw InvalidIOException();
+
+      case RPC_PORT_ERROR_PERMISSION_DENIED:
+        throw PermissionDeniedException();
+    }
+  }
+}
+
+void PkgMgrAdmin::Disconnect() {
+  int ret = rpc_port_disconnect(port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to disconnect PkgMgrAdmin");
+    throw InvalidIDException();
+  }
+}
+
+void PkgMgrAdmin::DisposeCallback(const std::string& tag) {
+  for (auto& i : delegate_list_) {
+    if (i->GetTag() == tag) {
+      delegate_list_.remove(i);
+      return;
+    }
+  }
+}
+
+void PkgMgrAdmin::ProcessReceivedEvent(rpc_port_parcel_h parcel) {
+  int id = 0;
+  int seq_id = 0;
+  bool once = false;
+
+  rpc_port_parcel_read_int32(parcel, &id);
+  rpc_port_parcel_read_int32(parcel, &seq_id);
+  rpc_port_parcel_read_bool(parcel, &once);
+
+  for (auto& i : delegate_list_) {
+    if (i->GetId() == id && i->GetSeqId() == seq_id) {
+      i->OnReceivedEvent(parcel);
+      if (i->IsOnce())
+        delegate_list_.remove(i);
+      break;
+    }
+  }
+}
+
+void PkgMgrAdmin::ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port) {
+  do {
+    rpc_port_parcel_h p;
+    int ret = rpc_port_parcel_create_from_port(&p, port);
+    int cmd;
+
+    if (ret != 0)
+      break;
+    rpc_port_parcel_read_int32(p, &cmd);
+    if (cmd == static_cast<int>(MethodId::__Result)) {
+      *parcel = p;
+      return;
+    }
+
+    rpc_port_parcel_destroy(p);
+    *parcel = nullptr;
+  } while (true);
+  *parcel = nullptr;
+}
+
+void PkgMgrAdmin::OnConnectedCB(const char *ep, const char *port_name, rpc_port_h port, void *data) {
+  PkgMgrAdmin* l = static_cast<PkgMgrAdmin*>(data);
+  rpc_port_h cb_port;
+
+  l->port_ = port;
+  rpc_port_proxy_get_port(l->proxy_, RPC_PORT_PORT_CALLBACK, &cb_port);
+  l->callback_port_ = cb_port;
+  l->listener_->OnConnected();
+}
+
+void PkgMgrAdmin::OnDisconnectedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgrAdmin* l = static_cast<PkgMgrAdmin*>(data);
+  l->delegate_list_.clear();
+  l->listener_->OnDisconnected();
+}
+
+void PkgMgrAdmin::OnRejectedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgrAdmin* l = static_cast<PkgMgrAdmin*>(data);
+  l->listener_->OnRejected();
+}
+
+void PkgMgrAdmin::OnReceivedCB(const char *ep, const char *port_name, void *data) {
+  PkgMgrAdmin* l = static_cast<PkgMgrAdmin*>(data);
+  int cmd;
+  rpc_port_parcel_h parcel_received;
+
+  if (rpc_port_parcel_create_from_port(&parcel_received, l->callback_port_) != 0) {
+    _E("Failed to create parcel from port");
+    return;
+  }
+
+  rpc_port_parcel_read_int32(parcel_received, &cmd);
+  if (cmd != static_cast<int>(MethodId::__Callback)) {
+    rpc_port_parcel_destroy(parcel_received);
+    return;
+  }
+
+  l->ProcessReceivedEvent(parcel_received);
+  rpc_port_parcel_destroy(parcel_received);
+}
+
+
+int PkgMgrAdmin::Install(int uid, std::string pkgType, std::string pkgPath, std::vector<std::string> args, std::string reqId, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::Install));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgType.c_str());
+  rpc_port_parcel_write_string(p, pkgPath.c_str());
+  p << args;
+  rpc_port_parcel_write_string(p, reqId.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::InstallPkgs(int uid, std::vector<std::string> pkgs, std::vector<std::string> args, std::string reqId, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::InstallPkgs));
+  rpc_port_parcel_write_int32(p, uid);
+  p << pkgs;
+  p << args;
+  rpc_port_parcel_write_string(p, reqId.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::Reinstall(int uid, std::string pkgid, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::Reinstall));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::MountInstall(int uid, std::string pkgType, std::string pkgPath, std::vector<std::string> args, std::string reqId, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::MountInstall));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgType.c_str());
+  rpc_port_parcel_write_string(p, pkgPath.c_str());
+  p << args;
+  rpc_port_parcel_write_string(p, reqId.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::MountInstallPkgs(int uid, std::vector<std::string> pkgs, std::string reqId, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::MountInstallPkgs));
+  rpc_port_parcel_write_int32(p, uid);
+  p << pkgs;
+  rpc_port_parcel_write_string(p, reqId.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::Uninstall(int uid, std::string pkgid, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::Uninstall));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::UninstallPkgs(int uid, std::vector<std::string> pkgs, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::UninstallPkgs));
+  rpc_port_parcel_write_int32(p, uid);
+  p << pkgs;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::Move(int uid, std::string pkgId, int moveType, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::Move));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgId.c_str());
+  rpc_port_parcel_write_int32(p, moveType);
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::EnablePkgs(int uid, std::vector<std::string> pkgIds, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::EnablePkgs));
+  rpc_port_parcel_write_int32(p, uid);
+  p << pkgIds;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::DisablePkgs(int uid, std::vector<std::string> pkgIds, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::DisablePkgs));
+  rpc_port_parcel_write_int32(p, uid);
+  p << pkgIds;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::RegisterPkgUpdateInfo(int uid, std::string pkgid, std::string version, int type, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::RegisterPkgUpdateInfo));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+  rpc_port_parcel_write_string(p, version.c_str());
+  rpc_port_parcel_write_int32(p, type);
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::UnregisterPkgUpdateInfo(int uid, std::string pkgid, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::UnregisterPkgUpdateInfo));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::UnregisterAllPkgUpdateInfo(int uid, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::UnregisterAllPkgUpdateInfo));
+  rpc_port_parcel_write_int32(p, uid);
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::EnableApp(int uid, std::string appid, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::EnableApp));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::DisableApp(int uid, std::string appid, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::DisableApp));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::EnableApps(int uid, std::vector<std::string> appIds, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::EnableApps));
+  rpc_port_parcel_write_int32(p, uid);
+  p << appIds;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::DisableApps(int uid, std::vector<std::string> appIds, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::DisableApps));
+  rpc_port_parcel_write_int32(p, uid);
+  p << appIds;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::EnableGlobalAppForUid(int uid, std::string appid, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::EnableGlobalAppForUid));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::DisableGlobalAppForUid(int uid, std::string appid, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::DisableGlobalAppForUid));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::Kill(int uid, std::string pkgid, int& pid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::Kill));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &pid);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::GenerateLicenseRequest(std::string respData, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::GenerateLicenseRequest));
+  rpc_port_parcel_write_string(p, respData.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::GetGenerateLicenseResult(std::string reqKey, int& result, std::string& reqData, std::string& licenseUrl) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::GetGenerateLicenseResult));
+  rpc_port_parcel_write_string(p, reqKey.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &result);
+    char* reqData_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqData_raw);
+    reqData = reqData_raw;
+    free(reqData_raw);
+    char* licenseUrl_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &licenseUrl_raw);
+    licenseUrl = licenseUrl_raw;
+    free(licenseUrl_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::RegisterLicense(std::string respData, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::RegisterLicense));
+  rpc_port_parcel_write_string(p, respData.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::DecryptPackage(std::string drmFilePath, std::string decryptedFilePath, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::DecryptPackage));
+  rpc_port_parcel_write_string(p, drmFilePath.c_str());
+  rpc_port_parcel_write_string(p, decryptedFilePath.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::EnableAppSplashScreen(int uid, std::string appid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::EnableAppSplashScreen));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::DisableAppSplashScreen(int uid, std::string appid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::DisableAppSplashScreen));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::SetAppLabel(int uid, std::string appid, std::string label, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::SetAppLabel));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+  rpc_port_parcel_write_string(p, label.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::SetAppIcon(int uid, std::string appid, std::string iconPath, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::SetAppIcon));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, appid.c_str());
+  rpc_port_parcel_write_string(p, iconPath.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::MigrateExternalImage(int uid, std::string pkgid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::MigrateExternalImage));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::ResCopy(std::vector<ResPath> copyPathsPair, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ResCopy));
+  p << copyPathsPair;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::ResCreateDir(std::vector<std::string> createDirPaths, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ResCreateDir));
+  p << createDirPaths;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::ResRemove(std::vector<std::string> removePaths, std::string& reqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ResRemove));
+  p << removePaths;
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* reqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &reqKey_raw);
+    reqKey = reqKey_raw;
+    free(reqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::ResUninstall(int uid, std::string pkgid, std::string& delayedReqKey) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ResUninstall));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    char* delayedReqKey_raw  = nullptr;
+    rpc_port_parcel_read_string(parcel_received, &delayedReqKey_raw);
+    delayedReqKey = delayedReqKey_raw;
+    free(delayedReqKey_raw);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::ClearData(int uid, std::string pkgid) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ClearData));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+int PkgMgrAdmin::ClearDataWithPath(int uid, std::string pkgid, std::string filePath) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::ClearDataWithPath));
+  rpc_port_parcel_write_int32(p, uid);
+  rpc_port_parcel_write_string(p, pkgid.c_str());
+  rpc_port_parcel_write_string(p, filePath.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+
+std::atomic<int> DelayedResult::CallbackBase::seq_num_ { 0 };
+
+DelayedResult::CallbackBase::CallbackBase(int delegate_id, bool once)
+    : id_(delegate_id), once_(once) {
+  seq_id_ = seq_num_++;
+}
+
+int DelayedResult::CallbackBase::GetId() const {
+  return id_;
+}
+
+int DelayedResult::CallbackBase::GetSeqId() const {
+  return seq_id_;
+}
+
+bool DelayedResult::CallbackBase::IsOnce() const {
+  return once_;
+}
+
+std::string DelayedResult::CallbackBase::GetTag() const {
+  return std::to_string(id_) + "::" + std::to_string(seq_id_);
+}
+
+rpc_port_parcel_h operator << (rpc_port_parcel_h h, const DelayedResult::CallbackBase& cb) {
+  rpc_port_parcel_write_int32(h, cb.id_);
+  rpc_port_parcel_write_int32(h, cb.seq_id_);
+  rpc_port_parcel_write_bool(h, cb.once_);
+
+  return h;
+}
+
+rpc_port_parcel_h operator >> (rpc_port_parcel_h h, DelayedResult::CallbackBase& cb) {
+  rpc_port_parcel_read_int32(h, &cb.id_);
+  rpc_port_parcel_read_int32(h, &cb.seq_id_);
+  rpc_port_parcel_read_bool(h, &cb.once_);
+
+  return h;
+}
+
+DelayedResult::DelayedResult(IEventListener* listener, const std::string& target_appid)
+    : port_(nullptr), callback_port_(nullptr), proxy_(nullptr),
+      listener_(listener), target_appid_(target_appid) {
+  int r = rpc_port_proxy_create(&proxy_);
+
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to create proxy");
+    throw InvalidIOException();
+  }
+
+  rpc_port_proxy_add_connected_event_cb(proxy_, OnConnectedCB, this);
+  rpc_port_proxy_add_disconnected_event_cb(proxy_, OnDisconnectedCB, this);
+  rpc_port_proxy_add_rejected_event_cb(proxy_, OnRejectedCB, this);
+  rpc_port_proxy_add_received_event_cb(proxy_, OnReceivedCB, this);
+}
+
+DelayedResult::~DelayedResult() {
+  if (proxy_)
+    rpc_port_proxy_destroy(proxy_);
+}
+
+void DelayedResult::Connect(bool sync) {
+  int ret;
+  if (sync)
+    ret = rpc_port_proxy_connect_sync(proxy_, target_appid_.c_str(), "DelayedResult");
+  else
+    ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "DelayedResult");
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to connect DelayedResult");
+    switch (ret) {
+      case RPC_PORT_ERROR_INVALID_PARAMETER:
+        throw InvalidIDException();
+
+      case RPC_PORT_ERROR_IO_ERROR:
+        throw InvalidIOException();
+
+      case RPC_PORT_ERROR_PERMISSION_DENIED:
+        throw PermissionDeniedException();
+    }
+  }
+}
+
+void DelayedResult::Disconnect() {
+  int ret = rpc_port_disconnect(port_);
+  if (ret != RPC_PORT_ERROR_NONE) {
+    _E("Failed to disconnect DelayedResult");
+    throw InvalidIDException();
+  }
+}
+
+void DelayedResult::DisposeCallback(const std::string& tag) {
+  for (auto& i : delegate_list_) {
+    if (i->GetTag() == tag) {
+      delegate_list_.remove(i);
+      return;
+    }
+  }
+}
+
+void DelayedResult::ProcessReceivedEvent(rpc_port_parcel_h parcel) {
+  int id = 0;
+  int seq_id = 0;
+  bool once = false;
+
+  rpc_port_parcel_read_int32(parcel, &id);
+  rpc_port_parcel_read_int32(parcel, &seq_id);
+  rpc_port_parcel_read_bool(parcel, &once);
+
+  for (auto& i : delegate_list_) {
+    if (i->GetId() == id && i->GetSeqId() == seq_id) {
+      i->OnReceivedEvent(parcel);
+      if (i->IsOnce())
+        delegate_list_.remove(i);
+      break;
+    }
+  }
+}
+
+void DelayedResult::ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port) {
+  do {
+    rpc_port_parcel_h p;
+    int ret = rpc_port_parcel_create_from_port(&p, port);
+    int cmd;
+
+    if (ret != 0)
+      break;
+    rpc_port_parcel_read_int32(p, &cmd);
+    if (cmd == static_cast<int>(MethodId::__Result)) {
+      *parcel = p;
+      return;
+    }
+
+    rpc_port_parcel_destroy(p);
+    *parcel = nullptr;
+  } while (true);
+  *parcel = nullptr;
+}
+
+void DelayedResult::OnConnectedCB(const char *ep, const char *port_name, rpc_port_h port, void *data) {
+  DelayedResult* l = static_cast<DelayedResult*>(data);
+  rpc_port_h cb_port;
+
+  l->port_ = port;
+  rpc_port_proxy_get_port(l->proxy_, RPC_PORT_PORT_CALLBACK, &cb_port);
+  l->callback_port_ = cb_port;
+  l->listener_->OnConnected();
+}
+
+void DelayedResult::OnDisconnectedCB(const char *ep, const char *port_name, void *data) {
+  DelayedResult* l = static_cast<DelayedResult*>(data);
+  l->delegate_list_.clear();
+  l->listener_->OnDisconnected();
+}
+
+void DelayedResult::OnRejectedCB(const char *ep, const char *port_name, void *data) {
+  DelayedResult* l = static_cast<DelayedResult*>(data);
+  l->listener_->OnRejected();
+}
+
+void DelayedResult::OnReceivedCB(const char *ep, const char *port_name, void *data) {
+  DelayedResult* l = static_cast<DelayedResult*>(data);
+  int cmd;
+  rpc_port_parcel_h parcel_received;
+
+  if (rpc_port_parcel_create_from_port(&parcel_received, l->callback_port_) != 0) {
+    _E("Failed to create parcel from port");
+    return;
+  }
+
+  rpc_port_parcel_read_int32(parcel_received, &cmd);
+  if (cmd != static_cast<int>(MethodId::__Callback)) {
+    rpc_port_parcel_destroy(parcel_received);
+    return;
+  }
+
+  l->ProcessReceivedEvent(parcel_received);
+  rpc_port_parcel_destroy(parcel_received);
+}
+
+
+int DelayedResult::GetResult(std::string reqKey, int& result) {
+  if (port_ == nullptr) {
+    _E("Not connected");
+    throw NotConnectedSocketException();
+  }
+
+  rpc_port_parcel_h p;
+  rpc_port_parcel_create(&p);
+
+  rpc_port_parcel_header_h header_;
+  rpc_port_parcel_get_header(p, &header_);
+  rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+  int seq_num_ = -1;
+  rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+  rpc_port_parcel_write_int32(p, static_cast<int>(MethodId::GetResult));
+  rpc_port_parcel_write_string(p, reqKey.c_str());
+
+  std::lock_guard<std::recursive_mutex> lock(mutex_);
+
+  // Send
+  int r = rpc_port_parcel_send(p, port_);
+  if (r != RPC_PORT_ERROR_NONE) {
+    _E("Failed to send parcel. result(%d)", r);
+    rpc_port_parcel_destroy(p);
+    throw InvalidIOException();
+  }
+
+  int ret;
+  bool done_ = false;
+  do {
+    rpc_port_parcel_h parcel_received = nullptr;
+    // Receive
+    ConsumeCommand(&parcel_received, port_);
+    if (parcel_received == nullptr) {
+      _E("Invalid protocol");
+      throw InvalidProtocolException();
+    }
+
+    rpc_port_parcel_get_header(parcel_received, &header_);
+    char* tag_ = nullptr;
+    rpc_port_parcel_header_get_tag(header_, &tag_);
+    std::unique_ptr<char, decltype(std::free)*> tag_auto_(tag_, std::free);
+    if (tag_ && tag_[0] != '\0') {
+      int seq_num_received_ = -1;
+      rpc_port_parcel_header_get_seq_num(header_, &seq_num_received_);
+      if (seq_num_received_ != seq_num_) {
+        _E("Invalid protocol. %d", seq_num_received_);
+        rpc_port_parcel_destroy(parcel_received);
+        continue;
+      }
+    }
+    done_ = true;
+
+    rpc_port_parcel_read_int32(parcel_received, &result);
+    rpc_port_parcel_read_int32(parcel_received, &ret);
+
+    rpc_port_parcel_destroy(parcel_received);
+  } while (!done_);
+
+  rpc_port_parcel_destroy(p);
+
+  return ret;
+
+}
+}  // namespace proxy
+}  // namespace PkgMgrProxy
+}  // namespace rpc_port
diff --git a/client/src/PkgMgrProxy.h b/client/src/PkgMgrProxy.h
new file mode 100644 (file)
index 0000000..5bcbaca
--- /dev/null
@@ -0,0 +1,668 @@
+/*
+ * Generated by tidlc 2.0.4.
+ */
+
+#pragma once
+
+#include <bundle.h>
+#include <rpc-port-parcel.h>
+#include <rpc-port.h>
+
+#include <string>
+#include <vector>
+#include <memory>
+#include <mutex>
+#include <list>
+#include <atomic>
+
+namespace rpc_port {
+namespace PkgMgrProxy {
+class Bundle final {
+ public:
+  Bundle() {
+    raw_ = bundle_create();
+  }
+
+  Bundle(bundle* b) {
+    raw_ = b;
+  }
+
+  ~Bundle() {
+    if (raw_)
+      bundle_free(raw_);
+  }
+
+  Bundle(Bundle&& b) : raw_(b.raw_) {
+    b.raw_ = nullptr;
+  }
+
+  Bundle& operator = (Bundle&& b) {
+    if (this != &b) {
+      if (raw_)
+        bundle_free(raw_);
+
+      raw_ = b.raw_;
+      b.raw_ = nullptr;
+    }
+    return *this;
+  }
+
+  Bundle(const Bundle& b) : raw_(bundle_dup(b.GetHandle())) {}
+
+  Bundle& operator = (const Bundle& b) {
+    if (this != &b) {
+      if (raw_)
+        bundle_free(raw_);
+
+      raw_ = bundle_dup(b.GetHandle());
+    }
+    return *this;
+  }
+
+  bundle* GetHandle() const {
+    return raw_;
+  }
+
+ private:
+  bundle* raw_;
+};
+
+class File final {
+ public:
+  File() {
+  }
+
+  File(std::string filename) {
+    filename_ = filename;
+  }
+
+  std::string GetFileName() const {
+    return filename_;
+  }
+
+ private:
+  std::string filename_;
+};
+
+
+class ResPath final {
+ public:
+  ResPath();
+  ResPath(std::string From, std::string To);
+  
+  void SetFrom(std::string From) {
+    From_ = std::move(From);
+  }
+
+  const std::string& GetFrom() const {
+    return From_;
+  }
+
+  void SetTo(std::string To) {
+    To_ = std::move(To);
+  }
+
+  const std::string& GetTo() const {
+    return To_;
+  }
+
+
+ private:
+  std::string From_;
+  std::string To_;
+
+};
+
+namespace proxy {
+
+class Exception {};
+class NotConnectedSocketException : public Exception {};
+class InvalidProtocolException : public Exception {};
+class InvalidIOException : public Exception {};
+class PermissionDeniedException : public Exception {};
+class InvalidIDException : public Exception {};
+
+class PkgMgrForClearCache {
+ public:
+
+  class CallbackBase {
+   public:
+    CallbackBase(int delegate_id, bool once);
+    virtual ~CallbackBase() = default;
+    virtual void OnReceivedEvent(rpc_port_parcel_h port) = 0;
+    int GetId() const;
+    int GetSeqId() const;
+    bool IsOnce() const;
+    std::string GetTag() const;
+
+   private:
+    friend rpc_port_parcel_h operator << (rpc_port_parcel_h h, const CallbackBase& cb);
+    friend rpc_port_parcel_h operator >> (rpc_port_parcel_h h, CallbackBase& cb);
+
+    static std::atomic<int> seq_num_;
+    int id_;
+    int seq_id_;
+    bool once_;
+  };
+
+  class IEventListener {
+   public:
+    /// <summary>
+    /// This method will be invoked when the client app is connected to the servicece app.
+    /// </summary>
+    virtual void OnConnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked after the client app was disconnected from the servicece app.
+    /// </summary>
+    virtual void OnDisconnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked when the service app rejects the client app.
+    /// </summary>
+    virtual void OnRejected() = 0;
+  };
+
+  /// <summary>
+  /// Constructor for this class
+  /// </summary>
+  /// <param name="listener">The listener for events</param>
+  /// <param name="target_appid">The service app ID to connect</param>
+  PkgMgrForClearCache(IEventListener* listener, const std::string& target_appid);
+
+  /// <summary>
+  /// Destructor for this class
+  /// </summary>
+  virtual ~PkgMgrForClearCache();
+
+  /// <summary>
+  /// Connects to the service app.
+  /// </summary>
+  /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+  /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+  //  <param name="sync">if true, connects to the service app synchornously</param>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the appid to connect is invalid.
+  /// </exception>
+  /// <exception cref="InvalidIOException">
+  /// Thrown when internal I/O error happen.
+  /// </exception>
+  /// <exception cref="PermissionDeniedException">
+  /// Thrown when the permission is denied.
+  /// </exception>
+  /// <remark> If you want to use this method, you must add privileges.</remark>
+  void Connect(bool sync = false);
+
+  /// <summary>
+  /// Disconnects from the service app.
+  /// </summary>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the stub port is invalid.
+  /// </exception>
+  void Disconnect();
+
+  /// <summary>
+  /// Disposes delegate objects in this interface
+  /// </summary>
+  /// <param name="tag">The tag string from delegate object</param>
+  void DisposeCallback(const std::string& tag);
+
+  int ClearCache(int uid, std::string pkgid);
+
+ private:
+  enum class MethodId : int {
+    __Result = 0,
+    __Callback = 1,
+    ClearCache = 2,
+
+  };
+
+  enum class DelegateId : int {
+
+  };
+  void ProcessReceivedEvent(rpc_port_parcel_h parcel);
+  void ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port);
+
+  static void OnConnectedCB(const char *ep, const char *port_name,
+                            rpc_port_h port, void *data);
+  static void OnDisconnectedCB(const char *ep, const char *port_name,
+                               void *data);
+  static void OnRejectedCB(const char *ep, const char *port_name, void *data);
+  static void OnReceivedCB(const char *ep, const char *port_name, void *data);
+
+  rpc_port_h port_;
+  rpc_port_h callback_port_;
+  rpc_port_proxy_h proxy_;
+  IEventListener* listener_;
+  std::recursive_mutex mutex_;
+  std::list<std::unique_ptr<CallbackBase>> delegate_list_;
+  std::string target_appid_;
+};
+
+class PkgMgr {
+ public:
+
+  class CallbackBase {
+   public:
+    CallbackBase(int delegate_id, bool once);
+    virtual ~CallbackBase() = default;
+    virtual void OnReceivedEvent(rpc_port_parcel_h port) = 0;
+    int GetId() const;
+    int GetSeqId() const;
+    bool IsOnce() const;
+    std::string GetTag() const;
+
+   private:
+    friend rpc_port_parcel_h operator << (rpc_port_parcel_h h, const CallbackBase& cb);
+    friend rpc_port_parcel_h operator >> (rpc_port_parcel_h h, CallbackBase& cb);
+
+    static std::atomic<int> seq_num_;
+    int id_;
+    int seq_id_;
+    bool once_;
+  };
+
+  class IEventListener {
+   public:
+    /// <summary>
+    /// This method will be invoked when the client app is connected to the servicece app.
+    /// </summary>
+    virtual void OnConnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked after the client app was disconnected from the servicece app.
+    /// </summary>
+    virtual void OnDisconnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked when the service app rejects the client app.
+    /// </summary>
+    virtual void OnRejected() = 0;
+  };
+
+  /// <summary>
+  /// Constructor for this class
+  /// </summary>
+  /// <param name="listener">The listener for events</param>
+  /// <param name="target_appid">The service app ID to connect</param>
+  PkgMgr(IEventListener* listener, const std::string& target_appid);
+
+  /// <summary>
+  /// Destructor for this class
+  /// </summary>
+  virtual ~PkgMgr();
+
+  /// <summary>
+  /// Connects to the service app.
+  /// </summary>
+  /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+  /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+  //  <param name="sync">if true, connects to the service app synchornously</param>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the appid to connect is invalid.
+  /// </exception>
+  /// <exception cref="InvalidIOException">
+  /// Thrown when internal I/O error happen.
+  /// </exception>
+  /// <exception cref="PermissionDeniedException">
+  /// Thrown when the permission is denied.
+  /// </exception>
+  /// <remark> If you want to use this method, you must add privileges.</remark>
+  void Connect(bool sync = false);
+
+  /// <summary>
+  /// Disconnects from the service app.
+  /// </summary>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the stub port is invalid.
+  /// </exception>
+  void Disconnect();
+
+  /// <summary>
+  /// Disposes delegate objects in this interface
+  /// </summary>
+  /// <param name="tag">The tag string from delegate object</param>
+  void DisposeCallback(const std::string& tag);
+
+  int GetSize(int uid, std::string pkgid, int getType, std::string& reqKey);
+  int GetSizeSync(int uid, std::string pkgid, int getType, std::string& ReqKey);
+  int GetSizeSyncResult(std::string reqKey, int& result, long long& sizeInfo);
+  int Check(int uid, std::string pkgid, int& pid);
+
+ private:
+  enum class MethodId : int {
+    __Result = 0,
+    __Callback = 1,
+    GetSize = 2,
+    GetSizeSync = 3,
+    GetSizeSyncResult = 4,
+    Check = 5,
+
+  };
+
+  enum class DelegateId : int {
+
+  };
+  void ProcessReceivedEvent(rpc_port_parcel_h parcel);
+  void ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port);
+
+  static void OnConnectedCB(const char *ep, const char *port_name,
+                            rpc_port_h port, void *data);
+  static void OnDisconnectedCB(const char *ep, const char *port_name,
+                               void *data);
+  static void OnRejectedCB(const char *ep, const char *port_name, void *data);
+  static void OnReceivedCB(const char *ep, const char *port_name, void *data);
+
+  rpc_port_h port_;
+  rpc_port_h callback_port_;
+  rpc_port_proxy_h proxy_;
+  IEventListener* listener_;
+  std::recursive_mutex mutex_;
+  std::list<std::unique_ptr<CallbackBase>> delegate_list_;
+  std::string target_appid_;
+};
+
+class PkgMgrAdmin {
+ public:
+
+  class CallbackBase {
+   public:
+    CallbackBase(int delegate_id, bool once);
+    virtual ~CallbackBase() = default;
+    virtual void OnReceivedEvent(rpc_port_parcel_h port) = 0;
+    int GetId() const;
+    int GetSeqId() const;
+    bool IsOnce() const;
+    std::string GetTag() const;
+
+   private:
+    friend rpc_port_parcel_h operator << (rpc_port_parcel_h h, const CallbackBase& cb);
+    friend rpc_port_parcel_h operator >> (rpc_port_parcel_h h, CallbackBase& cb);
+
+    static std::atomic<int> seq_num_;
+    int id_;
+    int seq_id_;
+    bool once_;
+  };
+
+  class IEventListener {
+   public:
+    /// <summary>
+    /// This method will be invoked when the client app is connected to the servicece app.
+    /// </summary>
+    virtual void OnConnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked after the client app was disconnected from the servicece app.
+    /// </summary>
+    virtual void OnDisconnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked when the service app rejects the client app.
+    /// </summary>
+    virtual void OnRejected() = 0;
+  };
+
+  /// <summary>
+  /// Constructor for this class
+  /// </summary>
+  /// <param name="listener">The listener for events</param>
+  /// <param name="target_appid">The service app ID to connect</param>
+  PkgMgrAdmin(IEventListener* listener, const std::string& target_appid);
+
+  /// <summary>
+  /// Destructor for this class
+  /// </summary>
+  virtual ~PkgMgrAdmin();
+
+  /// <summary>
+  /// Connects to the service app.
+  /// </summary>
+  /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+  /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+  //  <param name="sync">if true, connects to the service app synchornously</param>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the appid to connect is invalid.
+  /// </exception>
+  /// <exception cref="InvalidIOException">
+  /// Thrown when internal I/O error happen.
+  /// </exception>
+  /// <exception cref="PermissionDeniedException">
+  /// Thrown when the permission is denied.
+  /// </exception>
+  /// <remark> If you want to use this method, you must add privileges.</remark>
+  void Connect(bool sync = false);
+
+  /// <summary>
+  /// Disconnects from the service app.
+  /// </summary>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the stub port is invalid.
+  /// </exception>
+  void Disconnect();
+
+  /// <summary>
+  /// Disposes delegate objects in this interface
+  /// </summary>
+  /// <param name="tag">The tag string from delegate object</param>
+  void DisposeCallback(const std::string& tag);
+
+  int Install(int uid, std::string pkgType, std::string pkgPath, std::vector<std::string> args, std::string reqId, std::string& reqKey);
+  int InstallPkgs(int uid, std::vector<std::string> pkgs, std::vector<std::string> args, std::string reqId, std::string& reqKey);
+  int Reinstall(int uid, std::string pkgid, std::string& reqKey);
+  int MountInstall(int uid, std::string pkgType, std::string pkgPath, std::vector<std::string> args, std::string reqId, std::string& reqKey);
+  int MountInstallPkgs(int uid, std::vector<std::string> pkgs, std::string reqId, std::string& reqKey);
+  int Uninstall(int uid, std::string pkgid, std::string& reqKey);
+  int UninstallPkgs(int uid, std::vector<std::string> pkgs, std::string& reqKey);
+  int Move(int uid, std::string pkgId, int moveType, std::string& reqKey);
+  int EnablePkgs(int uid, std::vector<std::string> pkgIds, std::string& reqKey);
+  int DisablePkgs(int uid, std::vector<std::string> pkgIds, std::string& reqKey);
+  int RegisterPkgUpdateInfo(int uid, std::string pkgid, std::string version, int type, std::string& delayedReqKey);
+  int UnregisterPkgUpdateInfo(int uid, std::string pkgid, std::string& delayedReqKey);
+  int UnregisterAllPkgUpdateInfo(int uid, std::string& delayedReqKey);
+  int EnableApp(int uid, std::string appid, std::string& reqKey);
+  int DisableApp(int uid, std::string appid, std::string& reqKey);
+  int EnableApps(int uid, std::vector<std::string> appIds, std::string& reqKey);
+  int DisableApps(int uid, std::vector<std::string> appIds, std::string& reqKey);
+  int EnableGlobalAppForUid(int uid, std::string appid, std::string& reqKey);
+  int DisableGlobalAppForUid(int uid, std::string appid, std::string& reqKey);
+  int Kill(int uid, std::string pkgid, int& pid);
+  int GenerateLicenseRequest(std::string respData, std::string& delayedReqKey);
+  int GetGenerateLicenseResult(std::string reqKey, int& result, std::string& reqData, std::string& licenseUrl);
+  int RegisterLicense(std::string respData, std::string& delayedReqKey);
+  int DecryptPackage(std::string drmFilePath, std::string decryptedFilePath, std::string& delayedReqKey);
+  int EnableAppSplashScreen(int uid, std::string appid);
+  int DisableAppSplashScreen(int uid, std::string appid);
+  int SetAppLabel(int uid, std::string appid, std::string label, std::string& delayedReqKey);
+  int SetAppIcon(int uid, std::string appid, std::string iconPath, std::string& delayedReqKey);
+  int MigrateExternalImage(int uid, std::string pkgid);
+  int ResCopy(std::vector<ResPath> copyPathsPair, std::string& reqKey);
+  int ResCreateDir(std::vector<std::string> createDirPaths, std::string& reqKey);
+  int ResRemove(std::vector<std::string> removePaths, std::string& reqKey);
+  int ResUninstall(int uid, std::string pkgid, std::string& delayedReqKey);
+  int ClearData(int uid, std::string pkgid);
+  int ClearDataWithPath(int uid, std::string pkgid, std::string filePath);
+
+ private:
+  enum class MethodId : int {
+    __Result = 0,
+    __Callback = 1,
+    Install = 2,
+    InstallPkgs = 3,
+    Reinstall = 4,
+    MountInstall = 5,
+    MountInstallPkgs = 6,
+    Uninstall = 7,
+    UninstallPkgs = 8,
+    Move = 9,
+    EnablePkgs = 10,
+    DisablePkgs = 11,
+    RegisterPkgUpdateInfo = 12,
+    UnregisterPkgUpdateInfo = 13,
+    UnregisterAllPkgUpdateInfo = 14,
+    EnableApp = 15,
+    DisableApp = 16,
+    EnableApps = 17,
+    DisableApps = 18,
+    EnableGlobalAppForUid = 19,
+    DisableGlobalAppForUid = 20,
+    Kill = 21,
+    GenerateLicenseRequest = 22,
+    GetGenerateLicenseResult = 23,
+    RegisterLicense = 24,
+    DecryptPackage = 25,
+    EnableAppSplashScreen = 26,
+    DisableAppSplashScreen = 27,
+    SetAppLabel = 28,
+    SetAppIcon = 29,
+    MigrateExternalImage = 30,
+    ResCopy = 31,
+    ResCreateDir = 32,
+    ResRemove = 33,
+    ResUninstall = 34,
+    ClearData = 35,
+    ClearDataWithPath = 36,
+
+  };
+
+  enum class DelegateId : int {
+
+  };
+  void ProcessReceivedEvent(rpc_port_parcel_h parcel);
+  void ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port);
+
+  static void OnConnectedCB(const char *ep, const char *port_name,
+                            rpc_port_h port, void *data);
+  static void OnDisconnectedCB(const char *ep, const char *port_name,
+                               void *data);
+  static void OnRejectedCB(const char *ep, const char *port_name, void *data);
+  static void OnReceivedCB(const char *ep, const char *port_name, void *data);
+
+  rpc_port_h port_;
+  rpc_port_h callback_port_;
+  rpc_port_proxy_h proxy_;
+  IEventListener* listener_;
+  std::recursive_mutex mutex_;
+  std::list<std::unique_ptr<CallbackBase>> delegate_list_;
+  std::string target_appid_;
+};
+
+class DelayedResult {
+ public:
+
+  class CallbackBase {
+   public:
+    CallbackBase(int delegate_id, bool once);
+    virtual ~CallbackBase() = default;
+    virtual void OnReceivedEvent(rpc_port_parcel_h port) = 0;
+    int GetId() const;
+    int GetSeqId() const;
+    bool IsOnce() const;
+    std::string GetTag() const;
+
+   private:
+    friend rpc_port_parcel_h operator << (rpc_port_parcel_h h, const CallbackBase& cb);
+    friend rpc_port_parcel_h operator >> (rpc_port_parcel_h h, CallbackBase& cb);
+
+    static std::atomic<int> seq_num_;
+    int id_;
+    int seq_id_;
+    bool once_;
+  };
+
+  class IEventListener {
+   public:
+    /// <summary>
+    /// This method will be invoked when the client app is connected to the servicece app.
+    /// </summary>
+    virtual void OnConnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked after the client app was disconnected from the servicece app.
+    /// </summary>
+    virtual void OnDisconnected() = 0;
+
+    /// <summary>
+    /// This method will be invoked when the service app rejects the client app.
+    /// </summary>
+    virtual void OnRejected() = 0;
+  };
+
+  /// <summary>
+  /// Constructor for this class
+  /// </summary>
+  /// <param name="listener">The listener for events</param>
+  /// <param name="target_appid">The service app ID to connect</param>
+  DelayedResult(IEventListener* listener, const std::string& target_appid);
+
+  /// <summary>
+  /// Destructor for this class
+  /// </summary>
+  virtual ~DelayedResult();
+
+  /// <summary>
+  /// Connects to the service app.
+  /// </summary>
+  /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+  /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+  //  <param name="sync">if true, connects to the service app synchornously</param>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the appid to connect is invalid.
+  /// </exception>
+  /// <exception cref="InvalidIOException">
+  /// Thrown when internal I/O error happen.
+  /// </exception>
+  /// <exception cref="PermissionDeniedException">
+  /// Thrown when the permission is denied.
+  /// </exception>
+  /// <remark> If you want to use this method, you must add privileges.</remark>
+  void Connect(bool sync = false);
+
+  /// <summary>
+  /// Disconnects from the service app.
+  /// </summary>
+  /// <exception cref="InvalidIDException">
+  /// Thrown when the stub port is invalid.
+  /// </exception>
+  void Disconnect();
+
+  /// <summary>
+  /// Disposes delegate objects in this interface
+  /// </summary>
+  /// <param name="tag">The tag string from delegate object</param>
+  void DisposeCallback(const std::string& tag);
+
+  int GetResult(std::string reqKey, int& result);
+
+ private:
+  enum class MethodId : int {
+    __Result = 0,
+    __Callback = 1,
+    GetResult = 2,
+
+  };
+
+  enum class DelegateId : int {
+
+  };
+  void ProcessReceivedEvent(rpc_port_parcel_h parcel);
+  void ConsumeCommand(rpc_port_parcel_h* parcel, rpc_port_h port);
+
+  static void OnConnectedCB(const char *ep, const char *port_name,
+                            rpc_port_h port, void *data);
+  static void OnDisconnectedCB(const char *ep, const char *port_name,
+                               void *data);
+  static void OnRejectedCB(const char *ep, const char *port_name, void *data);
+  static void OnReceivedCB(const char *ep, const char *port_name, void *data);
+
+  rpc_port_h port_;
+  rpc_port_h callback_port_;
+  rpc_port_proxy_h proxy_;
+  IEventListener* listener_;
+  std::recursive_mutex mutex_;
+  std::list<std::unique_ptr<CallbackBase>> delegate_list_;
+  std::string target_appid_;
+};
+}  // namespace proxy
+}  // namespace PkgMgrProxy
+}  // namespace rpc_port
diff --git a/client/src/signal_receiver.cc b/client/src/signal_receiver.cc
deleted file mode 100644 (file)
index c95bcea..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <sstream>
-
-#include "signal_receiver.hh"
-
-namespace pkgmgr {
-namespace client {
-
-#define AGENT_APPID "signal_agent"
-
-SignalReceiver::SignalReceiver(bool is_system)
-    : PkgSignal(is_system ? "" : AGENT_APPID, is_system) {
-}
-
-SignalReceiver::~SignalReceiver() {
-}
-
-void SignalReceiver::OnAsyncResult(std::string signal, int targetUid,
-    std::string reqId, std::vector<pkg_signal::PkgInfo> pkgs,
-    std::string key, std::string val) {
-  HandleHandler(targetUid, reqId, pkgs, key, val);
-  HandleGlobalHandler(targetUid, reqId, pkgs, key, val);
-  HandleSizeInfoHandler(reqId, pkgs, key, val);
-}
-
-void SignalReceiver::HandleHandler(int targetUid,
-    const std::string& reqId, const std::vector<pkg_signal::PkgInfo>& pkgs,
-    const std::string& key, const std::string& val) const {
-  const auto it = handlers_.find(reqId);
-  if (it == handlers_.end())
-    return;
-  const auto& [id, cb, app_cb, data] = it->second;
-
-  for (auto& i : pkgs) {
-    if (cb) {
-      cb(targetUid, id, i.GetPkgType().c_str(), i.GetPkgid().c_str(),
-          key.c_str(), val.c_str(), nullptr, data);
-    } else {
-      app_cb(targetUid, id, i.GetPkgType().c_str(), i.GetPkgid().c_str(),
-          i.GetAppid().c_str(), key.c_str(), val.c_str(), nullptr, data);
-    }
-  }
-}
-
-void SignalReceiver::HandleGlobalHandler(int targetUid,
-    const std::string& reqId, const std::vector<pkg_signal::PkgInfo>& pkgs,
-    const std::string& key, const std::string& val) const {
-  for (auto& i : pkgs) {
-    for (const auto& [id, cb, app_cb, data] : global_handlers_) {
-      if (cb) {
-        cb(targetUid, id, i.GetPkgType().c_str(), i.GetPkgid().c_str(),
-            key.c_str(), val.c_str(), nullptr, data);
-      } else {
-        app_cb(targetUid, id, i.GetPkgType().c_str(), i.GetPkgid().c_str(),
-            i.GetAppid().c_str(), key.c_str(), val.c_str(), nullptr, data);
-      }
-    }
-  }
-}
-
-void SignalReceiver::HandleSizeInfoHandler(
-    const std::string& reqId, const std::vector<pkg_signal::PkgInfo>& pkgs,
-    const std::string& key, const std::string& val) const {
-  auto it = size_info_handlers_.find(reqId);
-  if (it == size_info_handlers_.end())
-    return;
-  const auto& [id, cb, pc, data] = it->second;
-
-  std::vector<std::string> tokens;
-  std::istringstream ss(val);
-  std::string token;
-
-  while (std::getline(ss, token, ':')) {
-      tokens.push_back(token);
-  }
-
-  if (tokens.size() != 6) {
-        return;
-    }
-
-  pkg_size_info_t size_info{
-      std::stoll(tokens[0]),
-      std::stoll(tokens[1]),
-      std::stoll(tokens[2]),
-      std::stoll(tokens[3]),
-      std::stoll(tokens[4]),
-      std::stoll(tokens[5]),
-  };
-
-  for (auto& i : pkgs) {
-    if (i.GetPkgid() == std::string(PKG_SIZE_INFO_TOTAL)) {
-      pkgmgr_total_pkg_size_info_receive_cb callback;
-      callback = (pkgmgr_total_pkg_size_info_receive_cb)cb;
-      callback(pc, &size_info, data);
-    } else {
-      cb(pc, i.GetPkgid().c_str(), &size_info, data);
-    }
-  }
-}
-
-void SignalReceiver::OnAsyncResultForResource(std::string signal,
-    int targetUid, std::string reqId, std::string pkgid,
-    std::string status, pkg_signal::ExtraData extra) {
-  HandleResHandler(signal, targetUid, reqId, pkgid, status, extra);
-  HandleGlobalResHandler(signal, targetUid, reqId, pkgid, status, extra);
-}
-
-void SignalReceiver::HandleResHandler(const std::string& signal,
-    int targetUid, const std::string& reqId, const std::string& pkgid,
-    const std::string& status, pkg_signal::ExtraData& extra) const {
-  auto it = res_handlers_.find(reqId);
-  if (it == res_handlers_.end())
-    return;
-  const auto& [id, cb, data] = it->second;
-
-  cb(targetUid, id, pkgid.c_str(), signal.c_str(), status.c_str(),
-      static_cast<void*>(&extra), data);
-}
-
-void SignalReceiver::HandleGlobalResHandler(const std::string& signal,
-    int targetUid, const std::string& reqId, const std::string& pkgid,
-    const std::string& status, pkg_signal::ExtraData& extra) const {
-  for (const auto& [id, cb, data] : global_res_handlers_) {
-    cb(targetUid, id, pkgid.c_str(), signal.c_str(), status.c_str(),
-        static_cast<void*>(&extra), data);
-  }
-}
-
-
-int SignalReceiver::AddEventHandler(std::string req_key,
-    pkgmgr_handler event_cb, void* data) {
-  return AddEventHandler(std::move(req_key), event_cb, nullptr, data);
-}
-
-int SignalReceiver::AddEventHandler(std::string req_key,
-    pkgmgr_app_handler app_event_cb, void* data) {
-  return AddEventHandler(std::move(req_key), nullptr, app_event_cb, data);
-}
-
-int SignalReceiver::AddEventHandler(std::string req_key,
-      pkgmgr_pkg_size_info_receive_cb event_cb, void* pc, void* data) {
-  int sId = SignalReceiver::GetRequestId();
-  if (req_key.empty())
-    global_size_info_handlers_.emplace_back(sId, event_cb, pc, data);
-  else
-    size_info_handlers_[req_key] = { sId, event_cb, pc, data };
-  return sId;
-}
-
-int SignalReceiver::AddEventHandler(std::string req_key,
-    pkgmgr_handler event_cb, pkgmgr_app_handler app_event_cb, void* data) {
-  int sId = SignalReceiver::GetRequestId();
-  if (req_key.empty())
-    global_handlers_.emplace_back(sId, event_cb, app_event_cb, data);
-  else
-    handlers_[req_key] = { sId, event_cb, app_event_cb, data };
-  return sId;
-}
-
-int SignalReceiver::AddEventHandler(std::string req_key,
-    pkgmgr_res_handler event_cb, void* data) {
-  int sId = SignalReceiver::GetRequestId();
-  if (req_key.empty())
-    global_res_handlers_.emplace_back(sId, event_cb, data);
-  else
-    res_handlers_[req_key] = { sId, event_cb, data };
-  return sId;
-}
-
-
-int SignalReceiver::GetRequestId() {
-  return ++request_id_;
-}
-
-}  // namespace client
-}  // namespace pkgmgr
-
diff --git a/client/src/signal_receiver.hh b/client/src/signal_receiver.hh
deleted file mode 100644 (file)
index b6cf64b..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef CLIENT_SRC_SIGNAL_RECEIVER_H_
-#define CLIENT_SRC_SIGNAL_RECEIVER_H_
-
-#include "package-manager.h"
-
-#include <map>
-#include <memory>
-#include <string>
-#include <tuple>
-
-#include "PkgSignal.h"
-
-
-namespace pkgmgr {
-namespace client {
-
-namespace pkg_group = rpc_port::PkgSignal::group;
-namespace pkg_signal = rpc_port::PkgSignal;
-
-class SignalReceiver : public pkg_group::PkgSignal {
- public:
-  SignalReceiver(bool is_system);
-  virtual ~SignalReceiver();
-
-  void OnAsyncResult(std::string signal, int targetUid, std::string reqId,
-      std::vector<pkg_signal::PkgInfo> pkgs, std::string key,
-      std::string val) override;
-
-  void OnAsyncResultForResource(std::string signal, int targetUid,
-      std::string reqId, std::string pkgid, std::string status,
-      pkg_signal::ExtraData extra) override;
-
-  int AddEventHandler(std::string req_key, pkgmgr_handler event_cb, void* data);
-  int AddEventHandler(std::string req_key, pkgmgr_app_handler app_event_cb,
-      void* data);
-  int AddEventHandler(std::string req_key,
-      pkgmgr_pkg_size_info_receive_cb event_cb, void* pc, void* data);
-  int AddEventHandler(std::string req_key, pkgmgr_res_handler event_cb,
-      void* data);
-
- private:
-  static int GetRequestId();
-  int AddEventHandler(std::string req_key, pkgmgr_handler event_cb,
-      pkgmgr_app_handler app_event_cb, void* data);
-  void HandleHandler(int targetUid, const std::string& reqId,
-      const std::vector<pkg_signal::PkgInfo>& pkgs, const std::string& key,
-      const std::string& val) const;
-  void HandleGlobalHandler(int targetUid, const std::string& reqId,
-      const std::vector<pkg_signal::PkgInfo>& pkgs, const std::string& key,
-      const std::string& val) const;
-  void HandleResHandler(const std::string& signal, int targetUid,
-      const std::string& reqId, const std::string& pkgid,
-      const std::string& status, pkg_signal::ExtraData& extra) const;
-  void HandleGlobalResHandler(const std::string& signal, int targetUid,
-      const std::string& reqId, const std::string& pkgid,
-      const std::string& status, pkg_signal::ExtraData& extra) const;
-  void HandleSizeInfoHandler(const std::string& reqId,
-      const std::vector<pkg_signal::PkgInfo>& pkgs,
-      const std::string& key, const std::string& val) const;
-
- private:
-  static inline int request_id_;
-  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_;
-  std::map<std::string,
-      std::tuple<int, pkgmgr_res_handler, void*>> res_handlers_;
-  std::list<std::tuple<int, pkgmgr_res_handler, void*>> global_res_handlers_;
-  std::map<std::string,
-      std::tuple<int, pkgmgr_pkg_size_info_receive_cb, void*, void*>> size_info_handlers_;
-  std::list<std::tuple<int, pkgmgr_pkg_size_info_receive_cb, void*, void*>> global_size_info_handlers_;
-};
-
-}  // namespace client
-}  // namespace pkgmgr
-
-#endif  // CLIENT_SRC_CONNECTOR_H_
\ No newline at end of file
index 1ec293f..b0c2c50 100644 (file)
@@ -38,7 +38,6 @@ BuildRequires:  pkgconfig(gmock)
 BuildRequires:  pkgmgr-info-parser-devel
 BuildRequires:  pkgmgr-info-parser
 BuildRequires:  fdupes
-BuildRequires:  tidl
 
 %if 0%{?gcov:1}
 BuildRequires:  lcov
@@ -102,11 +101,6 @@ Package Manager client types develpoment package for packaging
 %prep
 %setup -q
 cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{SOURCE1005} %{SOURCE1006} .
-tidlc -p -l C++ -i ./tidl/PkgMgr.tidl -o PkgMgrProxy
-mv PkgMgrProxy.* ./client/src/
-tidlc -g -l C++ -i ./tidl/PkgSignal.tidl -o PkgSignal
-cp PkgSignal.* ./client/src/
-mv PkgSignal.* ./installer/src/
 
 %build
 %if 0%{?gcov:1}