Use PkgQueryInterface in StepCheckRemovable 12/151312/6
authorDamian Pietruchowski <d.pietruchow@samsung.com>
Wed, 20 Sep 2017 11:13:33 +0000 (13:13 +0200)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 28 Nov 2017 05:43:24 +0000 (05:43 +0000)
Change-Id: I07b37dcb2509e833b4b43a448b19c91ee1a074f8
Signed-off-by: Damian Pietruchowski <d.pietruchow@samsung.com>
src/common/step/pkgmgr/step_check_removable.cc

index 7dd0bc8..aad30a4 100644 (file)
@@ -4,9 +4,8 @@
 
 #include "common/step/pkgmgr/step_check_removable.h"
 
-#include <pkgmgr-info.h>
-
 #include "common/app_installer.h"
+#include "common/pkgmgr_query.h"
 
 namespace common_installer {
 namespace pkgmgr {
@@ -15,30 +14,21 @@ Step::Status StepCheckRemovable::process() {
   if (context_->force_remove.get())
       return Status::OK;
 
-  pkgmgrinfo_pkginfo_h handle;
-  int ret =
-      pkgmgrinfo_pkginfo_get_usr_all_pkginfo(context_->pkgid.get().c_str(),
-          context_->uid.get(), &handle);
-  if (ret != PMINFO_R_OK) {
+  PkgQueryInterface pkg_query(context_->pkgid.get().c_str(),
+      context_->uid.get());
+  if (!pkg_query.IsValid()) {
     LOG(ERROR) << "This package is not installed";
     return Status::INVALID_VALUE;
   }
-
-  bool removable;
-  ret = pkgmgrinfo_pkginfo_is_removable(handle, &removable);
-  if (ret != PMINFO_R_OK) {
-    pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+  bool removable = pkg_query.IsRemovablePackage();
+  if (pkg_query.GetLastOperationError() != PMINFO_R_OK)
     return Status::INVALID_VALUE;
-  }
 
   if (!removable) {
     LOG(ERROR) << "This package is not removable";
-    pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
     return Status::OPERATION_NOT_ALLOWED;
   }
 
-  pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
-
   return Status::OK;
 }