New API: check permission of app with given app_id (definitions) 42/188042/5
authorPawel Kowalski <p.kowalski2@partner.samsung.com>
Thu, 30 Aug 2018 08:05:53 +0000 (10:05 +0200)
committerPawel Kowalski <p.kowalski2@partner.samsung.com>
Mon, 24 Sep 2018 12:27:03 +0000 (14:27 +0200)
The new API provides a possibility of checking the privacy status of
the app with its app_id (the Smack label of the app may be different
than the caller's Smack label).

Required privilege:
- http://tizen.org/privilege/permission.check

Change-Id: I21ff5590dbcc30bd1bf38fdd2e06546f182c46a0

src/capi/include/privacy_privilege_manager.h
src/capi/test/privacy_privilege_manager_test.cpp

index 2c7c55b..69ff685 100644 (file)
@@ -44,6 +44,8 @@ typedef enum
     PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS  = TIZEN_ERROR_ALREADY_IN_PROGRESS,
     /** Out of memory */
     PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY        = TIZEN_ERROR_OUT_OF_MEMORY,
+    /** Permission denied */
+    PRIVACY_PRIVILEGE_MANAGER_ERROR_PERMISSION_DENIED    = TIZEN_ERROR_PERMISSION_DENIED,
     /** Unknown error */
     PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN              = TIZEN_ERROR_UNKNOWN,
 } ppm_error_e;
@@ -150,6 +152,30 @@ typedef void (*ppm_request_multiple_response_cb) (ppm_call_cause_e cause,
 int ppm_check_permission(const char *privilege, ppm_check_result_e *result);
 
 /**
+ * @platform
+ * @brief Checks if an application, with given app_id, has permission to use the
+ * given privilege.
+ *
+ * @since_tizen 5.0
+ *
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/permission.check
+ *
+ * @param[in]   app_id      The app_id of the app that is to be checked.
+ * @param[in]   privilege   The privilege that is to be checked.
+ * @param[out]  result      The result of the privilege check.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE               Successful
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR           I/O error
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN            Unknown error
+ */
+int ppm_check_app_permission(const char *app_id, const char *privilege, ppm_check_result_e *result);
+
+/**
  * @brief Checks if an application, which calls this function, has permission to use the
  * given privileges.
  *
@@ -172,6 +198,34 @@ int ppm_check_permissions(const char **privileges, size_t privileges_count,
                           ppm_check_result_e *results);
 
 /**
+ * @platform
+ * @brief Checks if an application, with given app_id, has permission to use the
+ * given privileges.
+ *
+ * @since_tizen 5.0
+ *
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/permission.check
+ *
+ * @param[in]   app_id            The app_id of the app that is to be checked.
+ * @param[in]   privileges        The privileges array that is to be checked.
+ * @param[in]   privileges_count  The number of elements in the privileges and results arrays.
+ * @param[out]  results           The results of the privilege check. Caller is responsible for
+ *                                allocating this array with proper size and freeing it afterwards.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE               Successful
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR           I/O error
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER  Non unique privileges passed
+ * in first argument, privileges_count is more than 100 or other invalid parameter
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY      Out of memory
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_PERMISSION_DENIED  Permission denied
+ * @retval #PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN            Unknown error
+ */
+int ppm_check_app_permissions(const char *app_id, const char **privileges, size_t privileges_count,
+                              ppm_check_result_e *results);
+
+/**
  * @brief Requests a user's response to obtain permission for using the given privilege.
  *
  * @details When this function is called, an underlying service may show an appropriate
index 299dffd..da16dfe 100644 (file)
@@ -149,18 +149,21 @@ void printClientError(ppm_error_e error)
         case PRIVACY_PRIVILEGE_MANAGER_ERROR_IO_ERROR:
             printf("I/O error\n");
             break;
-        case  PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER:
-            printf("Invalid parameters\n");
+        case PRIVACY_PRIVILEGE_MANAGER_ERROR_INVALID_PARAMETER:
+            printf("Invalid parameter\n");
+            break;
+        case PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS:
+            printf("Operation already in progress\n");
             break;
         case PRIVACY_PRIVILEGE_MANAGER_ERROR_OUT_OF_MEMORY:
             printf("Out of memory\n");
             break;
+        case PRIVACY_PRIVILEGE_MANAGER_ERROR_PERMISSION_DENIED:
+            printf("Permission denied\n");
+            break;
         case PRIVACY_PRIVILEGE_MANAGER_ERROR_UNKNOWN:
             printf("Unknown error\n");
             break;
-        case PRIVACY_PRIVILEGE_MANAGER_ERROR_ALREADY_IN_PROGRESS:
-            printf("Operation already in progress\n");
-            break;
     }
 }