[application] get package size using pkgmgr-info CAPI
authorRafal Galka <r.galka@samsung.com>
Wed, 2 Sep 2015 13:42:48 +0000 (15:42 +0200)
committerRafal Galka <r.galka@samsung.com>
Wed, 2 Sep 2015 13:50:02 +0000 (15:50 +0200)
Change-Id: I559d1291d03f590d2816d03dae932f0392a00a37
Signed-off-by: Rafal Galka <r.galka@samsung.com>
src/application/application_manager.cc
src/application/application_utils.cc

index 6f2a179..c368cd0 100755 (executable)
@@ -31,6 +31,7 @@
 #include "common/current_application.h"
 #include "common/logger.h"
 #include "common/platform_result.h"
+#include "common/scope_exit.h"
 #include "common/task-queue.h"
 
 using namespace common;
@@ -1286,21 +1287,24 @@ void ApplicationManager::GetApplicationInformationSize(const picojson::value& ar
 
   const std::string& package_id_str = package_id.get<std::string>();
 
-  // get installed size from package server (to solve smack issue)
-  pkgmgr_client* pc = pkgmgr_client_new(PC_REQUEST);
   int size = -1;
+  pkgmgrinfo_pkginfo_h handle;
+  int ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(package_id_str.c_str(), getuid(), &handle);
+  if (ret != PMINFO_R_OK) {
+    LoggerE("Failed to create package handler");
+    ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to create package handler"), out);
+    return;
+  }
 
-  if (nullptr == pc) {
-    LoggerE("Failed to create pkgmgr client");
-  } else {
-    size = pkgmgr_client_request_service(PM_REQUEST_GET_SIZE, PM_GET_TOTAL_SIZE, pc, NULL,
-                                         package_id_str.c_str(), NULL, NULL, NULL);
-
-    if (size < 0) {
-      LoggerE("Failed to get installed size");
-    }
+  SCOPE_EXIT {
+    pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+  };
 
-    pkgmgr_client_free(pc);
+  ret = pkgmgrinfo_pkginfo_get_package_size(handle, &size);
+  if (ret != PMINFO_R_OK) {
+    LoggerE("Failed to get package size");
+    ReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Failed to get package size"), out);
+    return;
   }
 
   picojson::value result = picojson::value(picojson::object());
index e2fa81e..b47f203 100755 (executable)
@@ -13,7 +13,7 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
+
 #include "application_utils.h"
 
 #include <memory>