[package] fix issue of web TCT 80/103180/1
authorHyunjin Park <hj.na.park@samsung.com>
Wed, 7 Dec 2016 11:57:03 +0000 (20:57 +0900)
committerHyunjin Park <hj.na.park@samsung.com>
Wed, 7 Dec 2016 11:59:27 +0000 (20:59 +0900)
- cause : native API is changed not to throw invalid parameter in no db case.
- solution : add code to check package db

[verification] test result of Web TCT is 100% pass rate.

Change-Id: If2b1c1aa9a83f5df8dee725e2015963d24da4c48

src/package/package_instance.cc

index 8125076..3a24edb 100644 (file)
@@ -366,22 +366,31 @@ void PackageInstance::PackageManagerUninstall(
     return;
   }
 
-  int request_id = 0;
-  int ret = package_manager_request_uninstall(request_, id.c_str(), &request_id);
+  package_info_h pkg_info;
+  int ret = package_manager_get_package_info(id.c_str(), &pkg_info);
   if ( ret != PACKAGE_MANAGER_ERROR_NONE ) {
-    if ( ret == PACKAGE_MANAGER_ERROR_INVALID_PARAMETER ) {
-      LoggerE("The package is not found at the specified location");
-      InvokeErrorCallbackAsync(callback_id,
-        NotFoundException(
-            "The package is not found at the specified location"));
+    if ( ret == PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE ) {
+        LoggerE("The package is not found at the specified location");
+        InvokeErrorCallbackAsync(callback_id,
+          NotFoundException(
+              "The package is not found at the specified location"));
     } else {
-      LoggerE("Failed to uninstall package: %d (%s)", ret, get_error_message(ret));
-      InvokeErrorCallbackAsync(callback_id, UnknownException(
-          "It is not allowed to install the package by the platform or " \
-          "any other platform error occurs"));
+        LoggerE("Failed to get package info: %d (%s)", ret, get_error_message(ret));
+        InvokeErrorCallbackAsync(callback_id, UnknownException(
+            "It is not allowed to get package information by the platform or " \
+            "any other platform error occurs"));
     }
   } else {
-    RegisterCallback(request_id, callback_id);
+    int request_id = 0;
+    int ret = package_manager_request_uninstall(request_, id.c_str(), &request_id);
+    if ( ret != PACKAGE_MANAGER_ERROR_NONE ) {
+        LoggerE("Failed to uninstall package: %d (%s)", ret, get_error_message(ret));
+        InvokeErrorCallbackAsync(callback_id, UnknownException(
+            "It is not allowed to install the package by the platform or " \
+            "any other platform error occurs"));
+    } else {
+      RegisterCallback(request_id, callback_id);
+    }
   }
 
   ReportSuccess(out);