Impelement pkgmgr_client_remove_listen_status
[platform/core/appfw/slp-pkgmgr.git] / client / src / api_stub.cc
index f875642..20dc44d 100644 (file)
@@ -52,24 +52,29 @@ static int GetDelayedResult(pkgmgr_client *pc, const std::string& req_key) {
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetDelayedResultProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  int retry_cnt = 0;
-  int ret = 0;
-  do {
-    if (proxy->GetResult(req_key, ret) == PKGMGR_R_OK)
-      return ret;
+  try {
+    auto* proxy = con->GetDelayedResultProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    int retry_cnt = 0;
+    int ret = 0;
+    do {
+      if (proxy->GetResult(req_key, ret) == PKGMGR_R_OK)
+        return ret;
 
-    _E("Failed to get result sleep and retry[%d/%d]",
-        retry_cnt, CONNECTION_RETRY_MAX);
-    usleep(CONNECTION_WAIT_USEC);
-    retry_cnt++;
-  } while (retry_cnt <= CONNECTION_RETRY_MAX);
+      _E("Failed to get result sleep and retry[%d/%d]",
+          retry_cnt, CONNECTION_RETRY_MAX);
+      usleep(CONNECTION_WAIT_USEC);
+      retry_cnt++;
+    } while (retry_cnt <= CONNECTION_RETRY_MAX);
 
-  _E("Failed to get result");
-  return PKGMGR_R_ERROR;
+    _E("Failed to get result");
+    return PKGMGR_R_ERROR;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 static int ResultGetSizeSync(pkgmgr_client *pc, const std::string& req_key) {
@@ -84,37 +89,42 @@ static int ResultGetSizeSync(pkgmgr_client *pc, const std::string& req_key) {
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetInfoProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  int retry_cnt = 0;
-  int ret = PKGMGR_R_ECOMM;
-  long long size_info = 0;
-  do {
-    if (proxy->GetSizeSyncResult(req_key, ret, size_info) == PKGMGR_R_OK) {
-      if (ret != PKGMGR_R_OK) {
-        _E("request result failed: %d", ret);
-        return ret;
-      }
-
-      if (size_info < 0) {
-        _E("invalid size_info=(%lld)", size_info);
-        return -1;
+  try {
+    auto* proxy = con->GetInfoProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    int retry_cnt = 0;
+    int ret = PKGMGR_R_ECOMM;
+    long long size_info = 0;
+    do {
+      if (proxy->GetSizeSyncResult(req_key, ret, size_info) == PKGMGR_R_OK) {
+        if (ret != PKGMGR_R_OK) {
+          _E("request result failed: %d", ret);
+          return ret;
+        }
+
+        if (size_info < 0) {
+          _E("invalid size_info=(%lld)", size_info);
+          return -1;
+        }
+
+        _D("size_info(%lld), return size(%d)", size_info, ret);
+        return size_info;
       }
 
-      _D("size_info(%lld), return size(%d)", size_info, ret);
-      return size_info;
-    }
-
-    _E("Failed to get result sleep and retry[%d/%d]",
-        retry_cnt, CONNECTION_RETRY_MAX);
-    usleep(CONNECTION_WAIT_USEC);
-    retry_cnt++;
-  } while (retry_cnt <= CONNECTION_RETRY_MAX);
+      _E("Failed to get result sleep and retry[%d/%d]",
+          retry_cnt, CONNECTION_RETRY_MAX);
+      usleep(CONNECTION_WAIT_USEC);
+      retry_cnt++;
+    } while (retry_cnt <= CONNECTION_RETRY_MAX);
 
-  _E("Failed to get result");
-  return ret;
+    _E("Failed to get result");
+    return ret;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 static int GetGenerateLicenseResult(pkgmgr_client *pc,
@@ -130,25 +140,30 @@ static int GetGenerateLicenseResult(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  int retry_cnt = 0;
-  int ret = PKGMGR_R_ECOMM;
-  do {
-    if (proxy->GetGenerateLicenseResult(req_key,
-        ret, reqData, licenseUrl) == PKGMGR_R_OK)
-      return ret;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    int retry_cnt = 0;
+    int ret = PKGMGR_R_ECOMM;
+    do {
+      if (proxy->GetGenerateLicenseResult(req_key,
+          ret, reqData, licenseUrl) == PKGMGR_R_OK)
+        return ret;
 
-    _E("Failed to get result sleep and retry[%d/%d]",
-        retry_cnt, CONNECTION_RETRY_MAX);
-    usleep(CONNECTION_WAIT_USEC);
-    retry_cnt++;
-  } while (retry_cnt <= CONNECTION_RETRY_MAX);
+      _E("Failed to get result sleep and retry[%d/%d]",
+          retry_cnt, CONNECTION_RETRY_MAX);
+      usleep(CONNECTION_WAIT_USEC);
+      retry_cnt++;
+    } while (retry_cnt <= CONNECTION_RETRY_MAX);
 
-  _E("Failed to get result");
-  return ret;
+    _E("Failed to get result");
+    return ret;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 static inline uid_t GetUid() {
@@ -209,22 +224,27 @@ API int pkgmgr_client_usr_install_packages(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string req_key;
-  std::vector<std::string> pkgs;
-  for (int i = 0; i < n_pkgs; i++)
-    pkgs.push_back(pkg_paths[i]);
-
-  int ret = proxy->InstallPkgs(uid, pkgs, con->GetArgv(),
-      con->GenerateRequestId(), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    std::vector<std::string> pkgs;
+    for (int i = 0; i < n_pkgs; i++)
+      pkgs.push_back(pkg_paths[i]);
+
+    int ret = proxy->InstallPkgs(uid, pkgs, con->GetArgv(),
+        con->GenerateRequestId(), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_install_packages(pkgmgr_client *pc,
@@ -271,18 +291,23 @@ API int pkgmgr_client_usr_install(pkgmgr_client *pc, const char *pkg_type,
     con->SetTepArgs();
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string req_key;
-  int ret = proxy->Install(uid, pkg_type ? pkg_type : "", pkg_path, con->GetArgv(),
-      con->GenerateRequestId(), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    int ret = proxy->Install(uid, pkg_type ? pkg_type : "", pkg_path, con->GetArgv(),
+        con->GenerateRequestId(), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_reinstall(pkgmgr_client *pc, const char *pkg_type,
@@ -306,17 +331,22 @@ API int pkgmgr_client_usr_reinstall(pkgmgr_client *pc, const char *pkg_type,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->Reinstall(uid, pkgid, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->Reinstall(uid, pkgid, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_uninstall_packages(pkgmgr_client *pc,
@@ -340,21 +370,26 @@ API int pkgmgr_client_usr_uninstall_packages(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  std::vector<std::string> pkgs;
-  for (int i = 0; i < n_pkgs; i++)
-    pkgs.push_back(pkgids[i]);
+    std::string req_key;
+    std::vector<std::string> pkgs;
+    for (int i = 0; i < n_pkgs; i++)
+      pkgs.push_back(pkgids[i]);
 
-  int ret = proxy->UninstallPkgs(uid, pkgs, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    int ret = proxy->UninstallPkgs(uid, pkgs, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
@@ -378,17 +413,22 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->Uninstall(uid, pkgid, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->Uninstall(uid, pkgid, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_listen_res_status(pkgmgr_client *pc,
@@ -403,15 +443,26 @@ API int pkgmgr_client_listen_res_status(pkgmgr_client *pc,
     const auto& receiver = con->GetSignalReceiver();
     return receiver->AddEventHandler("", event_cb, data);
   } catch (...) {
-    _E("exception occured");
+    _E("Exception occured");
     return PKGMGR_R_ERROR;
   }
 }
 
 API int pkgmgr_client_listen_pkg_upgrade_status(pkgmgr_client *pc,
     pkgmgr_pkg_upgrade_handler event_cb, void *data) {
-  //TODO
-  return PKGMGR_R_OK;
+  Connector* con = static_cast<Connector*>(pc);
+  if (con->GetPcType() != PC_LISTENING) {
+    _E("client->pc_type is not PC_LISTENING");
+    return PKGMGR_R_EINVAL;
+  }
+
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    return receiver->AddEventHandler(event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ERROR;
+  }
 }
 
 API int pkgmgr_client_usr_mount_install_packages(pkgmgr_client *pc,
@@ -428,28 +479,33 @@ API int pkgmgr_client_usr_mount_install_packages(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    std::vector<std::string> pkgs;
+    for (int i = 0; i < n_pkgs; i++) {
+      if (access(pkg_paths[i], F_OK) != 0) {
+        _E("failed to access: %s", pkg_paths[i]);
+        return PKGMGR_R_EINVAL;
+      }
 
-  std::string req_key;
-  std::vector<std::string> pkgs;
-  for (int i = 0; i < n_pkgs; i++) {
-    if (access(pkg_paths[i], F_OK) != 0) {
-      _E("failed to access: %s", pkg_paths[i]);
-      return PKGMGR_R_EINVAL;
+      pkgs.push_back(pkg_paths[i]);
     }
 
-    pkgs.push_back(pkg_paths[i]);
-  }
-
-  int ret = proxy->MountInstallPkgs(uid, pkgs, con->GenerateRequestId(),
-      req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    int ret = proxy->MountInstallPkgs(uid, pkgs, con->GenerateRequestId(),
+        req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_mount_install_packages(pkgmgr_client *pc,
@@ -497,18 +553,23 @@ API int pkgmgr_client_usr_mount_install(pkgmgr_client *pc, const char *pkg_type,
     con->SetTepArgs();
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string req_key;
-  int ret = proxy->MountInstall(uid, pkg_type ? pkg_type : "", pkg_path,
-      con->GetArgv(), con->GenerateRequestId(), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    int ret = proxy->MountInstall(uid, pkg_type ? pkg_type : "", pkg_path,
+        con->GetArgv(), con->GenerateRequestId(), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
@@ -536,17 +597,22 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->Move(uid, pkgid, move_type, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->Move(uid, pkgid, move_type, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_register_pkg_update_info(pkgmgr_client *pc,
@@ -568,19 +634,24 @@ API int pkgmgr_client_usr_register_pkg_update_info(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    int ret = proxy->RegisterPkgUpdateInfo(uid, update_info->pkgid,
+        update_info->version, update_info->type, req_key);
+    if (ret != 0) {
+      _E("Request fail");
+      return ret;
+    }
 
-  std::string req_key;
-  int ret = proxy->RegisterPkgUpdateInfo(uid, update_info->pkgid,
-      update_info->version, update_info->type, req_key);
-  if (ret != 0) {
-    _E("Request fail");
-    return ret;
+    return GetDelayedResult(pc, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
   }
-
-  return GetDelayedResult(pc, req_key);
 }
 
 API int pkgmgr_client_usr_unregister_pkg_update_info(pkgmgr_client *pc,
@@ -596,19 +667,24 @@ API int pkgmgr_client_usr_unregister_pkg_update_info(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->UnregisterPkgUpdateInfo(uid, pkgid, req_key);
+    std::string req_key;
+    int ret = proxy->UnregisterPkgUpdateInfo(uid, pkgid, req_key);
 
-  if (ret != 0) {
-    _E("Request fail");
-    return ret;
-  }
+    if (ret != 0) {
+      _E("Request fail");
+      return ret;
+    }
 
-  return GetDelayedResult(pc, req_key);
+    return GetDelayedResult(pc, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_unregister_pkg_update_info(pkgmgr_client *pc,
@@ -629,12 +705,17 @@ API int pkgmgr_client_usr_unregister_all_pkg_update_info(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  return proxy->UnregisterAllPkgUpdateInfo(uid, req_key);
+    std::string req_key;
+    return proxy->UnregisterAllPkgUpdateInfo(uid, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_unregister_all_pkg_update_info(pkgmgr_client *pc) {
@@ -649,12 +730,22 @@ API int pkgmgr_client_usr_activate(pkgmgr_client *pc, const char *pkg_type,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
+
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  return proxy->EnablePkgs(uid, { pkgid }, req_key);
+    std::string req_key;
+    return proxy->EnablePkgs(uid, { pkgid }, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_activate(pkgmgr_client *pc, const char *pkg_type,
@@ -676,22 +767,27 @@ API int pkgmgr_client_usr_activate_packages(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string req_key;
-  std::vector<std::string> vec;
-  for (int i = 0; i < n_pkgs; i++) {
-    vec.push_back(pkgids[i]);
-  }
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    std::vector<std::string> vec;
+    for (int i = 0; i < n_pkgs; i++) {
+      vec.push_back(pkgids[i]);
+    }
 
-  int ret = proxy->EnablePkgs(uid, std::move(vec), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    int ret = proxy->EnablePkgs(uid, std::move(vec), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_activate_packages(pkgmgr_client *pc,
@@ -709,12 +805,22 @@ API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
 
-  std::string req_key;
-  return proxy->DisablePkgs(uid, { pkgid }, req_key);
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    return proxy->DisablePkgs(uid, { pkgid }, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
@@ -736,21 +842,26 @@ API int pkgmgr_client_usr_deactivate_packages(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    std::vector<std::string> vec;
+    for (int i = 0; i < n_pkgs; i++) {
+      vec.push_back(pkgids[i]);
+    }
+    int ret = proxy->DisablePkgs(uid, std::move(vec), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  std::string req_key;
-  std::vector<std::string> vec;
-  for (int i = 0; i < n_pkgs; i++) {
-    vec.push_back(pkgids[i]);
+    return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
   }
-  int ret = proxy->DisablePkgs(uid, std::move(vec), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
-
-  return receiver->AddEventHandler(req_key, event_cb, data);
 }
 
 API int pkgmgr_client_deactivate_packages(pkgmgr_client *pc,
@@ -773,17 +884,22 @@ API int pkgmgr_client_usr_activate_app(pkgmgr_client *pc, const char *appid,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->EnableApp(uid, appid, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->EnableApp(uid, appid, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, app_event_cb, data);
+    return receiver->AddEventHandler(req_key, app_event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_activate_app(pkgmgr_client *pc, const char *appid,
@@ -805,22 +921,27 @@ API int pkgmgr_client_usr_activate_apps(pkgmgr_client *pc, const char **appids,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string req_key;
-  std::vector<std::string> vec;
-  for (int i = 0; i < n_apps; i++) {
-    vec.push_back(appids[i]);
-  }
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    std::vector<std::string> vec;
+    for (int i = 0; i < n_apps; i++) {
+      vec.push_back(appids[i]);
+    }
 
-  int ret = proxy->EnableApps(uid, std::move(vec), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    int ret = proxy->EnableApps(uid, std::move(vec), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, app_event_cb, data);
+    return receiver->AddEventHandler(req_key, app_event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_activate_apps(pkgmgr_client *pc, const char **appids,
@@ -842,17 +963,22 @@ API int pkgmgr_client_activate_global_app_for_uid(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->EnableGlobalAppForUid(uid, appid, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->EnableGlobalAppForUid(uid, appid, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, app_event_cb, data);
+    return receiver->AddEventHandler(req_key, app_event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid,
@@ -868,17 +994,22 @@ API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->DisableApp(uid, appid, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->DisableApp(uid, appid, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, app_event_cb, data);
+    return receiver->AddEventHandler(req_key, app_event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid,
@@ -901,22 +1032,27 @@ API int pkgmgr_client_usr_deactivate_apps(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string req_key;
-  std::vector<std::string> vec;
-  for (int i = 0; i < n_apps; i++) {
-    vec.push_back(appids[i]);
-  }
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    std::vector<std::string> vec;
+    for (int i = 0; i < n_apps; i++) {
+      vec.push_back(appids[i]);
+    }
 
-  int ret = proxy->DisableApps(uid, std::move(vec), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    int ret = proxy->DisableApps(uid, std::move(vec), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, app_event_cb, data);
+    return receiver->AddEventHandler(req_key, app_event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_deactivate_apps(pkgmgr_client *pc, const char **appids,
@@ -938,17 +1074,22 @@ API int pkgmgr_client_deactivate_global_app_for_uid(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->DisableGlobalAppForUid(uid, appid, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->DisableGlobalAppForUid(uid, appid, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, app_event_cb, data);
+    return receiver->AddEventHandler(req_key, app_event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
@@ -971,11 +1112,16 @@ API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  return proxy->ClearData(uid, pkgid);
+    return proxy->ClearData(uid, pkgid);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_usr_clear_user_data_with_path(pkgmgr_client *pc,
@@ -993,11 +1139,16 @@ API int pkgmgr_client_usr_clear_user_data_with_path(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  return proxy->ClearDataWithPath(uid, pkgid, file_path);
+    return proxy->ClearDataWithPath(uid, pkgid, file_path);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_clear_user_data_with_path(pkgmgr_client *pc, const char *pkg_type,
@@ -1008,7 +1159,14 @@ API int pkgmgr_client_clear_user_data_with_path(pkgmgr_client *pc, const char *p
 }
 
 API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type) {
-  //TODO
+  if (pc == nullptr) {
+    _E("invalid parameter");
+    return PKGMGR_R_EINVAL;
+  }
+
+  auto* con = static_cast<Connector*>(pc);
+  con->SetStatusType(status_type);
+
   return PKGMGR_R_OK;
 }
 
@@ -1029,7 +1187,7 @@ API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
     const auto& receiver = con->GetSignalReceiver();
     return receiver->AddEventHandler("", event_cb, data);
   } catch (...) {
-    _E("exception occured");
+    _E("Exception occured");
     return PKGMGR_R_ERROR;
   }
 }
@@ -1051,14 +1209,26 @@ API int pkgmgr_client_listen_app_status(pkgmgr_client *pc,
     const auto& receiver = con->GetSignalReceiver();
     return receiver->AddEventHandler("", app_event_cb, data);
   } catch (...) {
-    _E("exception occured");
+    _E("Exception occured");
     return PKGMGR_R_ERROR;
   }
 }
 
 API int pkgmgr_client_remove_listen_status(pkgmgr_client *pc) {
-  //TODO
-  return PKGMGR_R_OK;
+  if (pc == nullptr) {
+    _E("invalid parameter");
+    return PKGMGR_R_EINVAL;
+  }
+
+  auto* con = static_cast<Connector*>(pc);
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    receiver->RemoveEventHandler();
+    return PKGMGR_R_OK;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ERROR;
+  }
 }
 
 API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
@@ -1089,38 +1259,54 @@ API int pkgmgr_client_usr_request_service(
           event_cb, data, uid);
     }
     case PM_REQUEST_GET_SIZE: {
-      auto* con = static_cast<Connector*>(pc);
-      auto* proxy = con->GetInfoProxy();
-      std::string req_key;
-      int ret = proxy->GetSizeSync(uid, pkgid, service_mode, req_key);
-      if (ret != PKGMGR_R_OK)
-        return ret;
-
-      return ResultGetSizeSync(pc, req_key);
+      try {
+        auto* con = static_cast<Connector*>(pc);
+        auto* proxy = con->GetInfoProxy();
+        std::string req_key;
+        int ret = proxy->GetSizeSync(uid, pkgid, service_mode, req_key);
+        if (ret != PKGMGR_R_OK)
+          return ret;
+
+        return ResultGetSizeSync(pc, req_key);
+      } catch (...) {
+        _E("Exception occured");
+        return PKGMGR_R_ESYSTEM;
+      }
     }
     case PM_REQUEST_KILL_APP: {
-      auto* con = static_cast<Connector*>(pc);
-      auto* proxy = con->GetAdminProxy();
-      int pid = 0;
-      int ret = proxy->Kill(uid, pkgid, pid);
-      *(int *)data = pid;
+      try {
+        auto* con = static_cast<Connector*>(pc);
+        auto* proxy = con->GetAdminProxy();
+        int pid = 0;
+        int ret = proxy->Kill(uid, pkgid, pid);
+        *(int *)data = pid;
 
-      return ret;
+        return ret;
+      } catch (...) {
+        _E("Exception occured");
+        return PKGMGR_R_ESYSTEM;
+      }
     }
     case PM_REQUEST_CHECK_APP: {
-      auto* con = static_cast<Connector*>(pc);
-      auto* proxy = con->GetInfoProxy();
-      int pid = 0;
-      int ret = proxy->Check(uid, pkgid, pid);
-      *(int *)data = pid;
+      try {
+        auto* con = static_cast<Connector*>(pc);
+        auto* proxy = con->GetInfoProxy();
+        int pid = 0;
+        int ret = proxy->Check(uid, pkgid, pid);
+        *(int *)data = pid;
 
-      return ret;
+        return ret;
+      } catch (...) {
+        _E("Exception occured");
+        return PKGMGR_R_ESYSTEM;
+      }
     }
     default:
       _E("Wrong Request");
       break;
   }
-  return 0;
+
+  return PKGMGR_R_ERROR;
 }
 
 API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid) {
@@ -1129,15 +1315,20 @@ API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid) {
     return PKGMGR_R_EINVAL;
   }
 
-  auto* con = new Connector(PC_REQUEST);
-  auto* proxy = con->GetCacheProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* con = new Connector(PC_REQUEST);
+    auto* proxy = con->GetCacheProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  int ret = proxy->ClearCache(uid, pkgid);
-  delete con;
+    int ret = proxy->ClearCache(uid, pkgid);
+    delete con;
 
-  return ret;
+    return ret;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_clear_cache_dir(const char *pkgid) {
@@ -1180,17 +1371,23 @@ API int pkgmgr_client_usr_get_size(pkgmgr_client *pc, const char *pkgid,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetInfoProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetInfoProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string req_key;
+    int ret = proxy->GetSize(uid, pkgid, get_type, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  std::string req_key;
-  int ret = proxy->GetSize(uid, pkgid, get_type, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    return receiver->AddEventHandler(req_key, event_cb, data);
 
-  return receiver->AddEventHandler(req_key, event_cb, data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_get_package_size_info(pkgmgr_client *pc,
@@ -1235,19 +1432,24 @@ API int pkgmgr_client_usr_get_package_size_info(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetInfoProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetInfoProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->GetSize(uid, pkgid, get_type, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->GetSize(uid, pkgid, get_type, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  receiver->AddEventHandler(req_key, event_cb, pc, user_data);
+    receiver->AddEventHandler(req_key, event_cb, pc, user_data);
 
-  return PKGMGR_R_OK;
+    return PKGMGR_R_OK;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_generate_license_request(pkgmgr_client *pc,
@@ -1264,24 +1466,29 @@ API int pkgmgr_client_generate_license_request(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
-
-  std::string data;
-  std::string url;
-  std::string req_key;
-  int ret = proxy->GenerateLicenseRequest(resp_data, req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    std::string data;
+    std::string url;
+    std::string req_key;
+    int ret = proxy->GenerateLicenseRequest(resp_data, req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  ret = GetGenerateLicenseResult(pc, req_key, data, url);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    ret = GetGenerateLicenseResult(pc, req_key, data, url);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  *req_data = strdup(data.c_str());
-  *license_url = strdup(url.c_str());
-  return PKGMGR_R_OK;
+    *req_data = strdup(data.c_str());
+    *license_url = strdup(url.c_str());
+    return PKGMGR_R_OK;
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_register_license(pkgmgr_client *pc, const char *resp_data) {
@@ -1296,19 +1503,24 @@ API int pkgmgr_client_register_license(pkgmgr_client *pc, const char *resp_data)
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->RegisterLicense(resp_data, req_key);
+    std::string req_key;
+    int ret = proxy->RegisterLicense(resp_data, req_key);
 
-  if (ret != 0) {
-    _E("Request fail");
-    return ret;
-  }
+    if (ret != 0) {
+      _E("Request fail");
+      return ret;
+    }
 
-  return GetDelayedResult(pc, req_key);
+    return GetDelayedResult(pc, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_decrypt_package(pkgmgr_client *pc,
@@ -1325,19 +1537,24 @@ API int pkgmgr_client_decrypt_package(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  int ret = proxy->DecryptPackage(drm_file_path, decrypted_file_path, req_key);
+    std::string req_key;
+    int ret = proxy->DecryptPackage(drm_file_path, decrypted_file_path, req_key);
 
-  if (ret != 0) {
-    _E("Request fail");
-    return ret;
-  }
+    if (ret != 0) {
+      _E("Request fail");
+      return ret;
+    }
 
-  return GetDelayedResult(pc, req_key);
+    return GetDelayedResult(pc, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_enable_splash_screen(pkgmgr_client *pc, const char *appid) {
@@ -1352,11 +1569,21 @@ API int pkgmgr_client_usr_enable_splash_screen(pkgmgr_client *pc,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
 
-  return proxy->EnableAppSplashScreen(uid, appid);
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    return proxy->EnableAppSplashScreen(uid, appid);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_disable_splash_screen(pkgmgr_client *pc,
@@ -1373,11 +1600,21 @@ API int pkgmgr_client_usr_disable_splash_screen(pkgmgr_client *pc,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
 
-  return proxy->DisableAppSplashScreen(uid, appid);
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    return proxy->DisableAppSplashScreen(uid, appid);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_usr_set_pkg_restriction_mode(pkgmgr_client *pc,
@@ -1531,19 +1768,29 @@ API int pkgmgr_client_usr_set_app_label(pkgmgr_client *pc, char *appid,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
 
-  std::string req_key;
-  int ret = proxy->SetAppLabel(uid, appid, label, req_key);
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  if (ret != 0) {
-    _E("Request fail");
-    return ret;
-  }
+    std::string req_key;
+    int ret = proxy->SetAppLabel(uid, appid, label, req_key);
 
-  return GetDelayedResult(pc, req_key);
+    if (ret != 0) {
+      _E("Request fail");
+      return ret;
+    }
+
+    return GetDelayedResult(pc, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_set_app_label(pkgmgr_client *pc, char *appid, char *label) {
@@ -1558,19 +1805,29 @@ API int pkgmgr_client_usr_set_app_icon(pkgmgr_client *pc, char *appid,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
 
-  std::string req_key;
-  int ret = proxy->SetAppIcon(uid, appid, icon_path, req_key);
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  if (ret != 0) {
-    _E("Request fail");
-    return ret;
-  }
+    std::string req_key;
+    int ret = proxy->SetAppIcon(uid, appid, icon_path, req_key);
+
+    if (ret != 0) {
+      _E("Request fail");
+      return ret;
+    }
 
-  return GetDelayedResult(pc, req_key);
+    return GetDelayedResult(pc, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_set_app_icon(pkgmgr_client *pc, char *appid, char *icon_path) {
@@ -1611,11 +1868,21 @@ API int pkgmgr_client_usr_migrate_external_image(pkgmgr_client *pc,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
 
-  return proxy->MigrateExternalImage(uid, pkgid);
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
+
+    return proxy->MigrateExternalImage(uid, pkgid);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_add_res_copy_path(pkgmgr_client *pc,
@@ -1644,18 +1911,23 @@ API int pkgmgr_client_res_copy(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
 
-  std::string req_key;
-  int ret = proxy->ResCopy(con->GetResCopyPath(), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->ResCopy(con->GetResCopyPath(), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, user_data);
+    return receiver->AddEventHandler(req_key, event_cb, user_data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_add_res_create_dir_path(pkgmgr_client *pc,
@@ -1684,18 +1956,23 @@ API int pkgmgr_client_res_create_dir(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
 
-  std::string req_key;
-  int ret = proxy->ResCreateDir(con->GetResCreateDir(), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->ResCreateDir(con->GetResCreateDir(), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, user_data);
+    return receiver->AddEventHandler(req_key, event_cb, user_data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_add_res_remove_path(pkgmgr_client *pc,
@@ -1724,18 +2001,23 @@ API int pkgmgr_client_res_remove(pkgmgr_client *pc,
     return PKGMGR_R_EINVAL;
   }
 
-  const auto& receiver = con->GetSignalReceiver();
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  try {
+    const auto& receiver = con->GetSignalReceiver();
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
 
-  std::string req_key;
-  int ret = proxy->ResRemove(con->GetResRemovePath(), req_key);
-  if (ret != PKGMGR_R_OK)
-    return ret;
+    std::string req_key;
+    int ret = proxy->ResRemove(con->GetResRemovePath(), req_key);
+    if (ret != PKGMGR_R_OK)
+      return ret;
 
-  return receiver->AddEventHandler(req_key, event_cb, user_data);
+    return receiver->AddEventHandler(req_key, event_cb, user_data);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API int pkgmgr_client_res_uninstall(pkgmgr_client *pc, const char *pkgid) {
@@ -1750,12 +2032,22 @@ API int pkgmgr_client_res_usr_uninstall(pkgmgr_client *pc, const char *pkgid,
   }
 
   auto* con = static_cast<Connector*>(pc);
-  auto* proxy = con->GetAdminProxy();
-  if (proxy == nullptr)
-    return PKGMGR_R_EIO;
+  if (con->GetPcType() != PC_REQUEST) {
+    _E("client type is not PC_REQUEST");
+    return PKGMGR_R_EINVAL;
+  }
+
+  try {
+    auto* proxy = con->GetAdminProxy();
+    if (proxy == nullptr)
+      return PKGMGR_R_EIO;
 
-  std::string req_key;
-  return proxy->ResUninstall(uid, pkgid, req_key);
+    std::string req_key;
+    return proxy->ResUninstall(uid, pkgid, req_key);
+  } catch (...) {
+    _E("Exception occured");
+    return PKGMGR_R_ESYSTEM;
+  }
 }
 
 API pkgmgr_res_event_info *pkgmgr_res_event_info_new() {