From 770d04fbdea400e4fb4b7560d2a1e9f4c062397f Mon Sep 17 00:00:00 2001 From: Pawel Kowalski Date: Thu, 30 Aug 2018 10:05:53 +0200 Subject: [PATCH] New API: check permission of app with given app_id (definitions) 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 | 54 ++++++++++++++++++++++++ src/capi/test/privacy_privilege_manager_test.cpp | 13 +++--- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/capi/include/privacy_privilege_manager.h b/src/capi/include/privacy_privilege_manager.h index 2c7c55b..69ff685 100644 --- a/src/capi/include/privacy_privilege_manager.h +++ b/src/capi/include/privacy_privilege_manager.h @@ -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 diff --git a/src/capi/test/privacy_privilege_manager_test.cpp b/src/capi/test/privacy_privilege_manager_test.cpp index 299dffd..da16dfe 100644 --- a/src/capi/test/privacy_privilege_manager_test.cpp +++ b/src/capi/test/privacy_privilege_manager_test.cpp @@ -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; } } -- 2.7.4