* @brief Free GList allocated by privilege_info APIs
* @param [in] list The GList allocated by privilege_info APIs
*/
-void privilege_info_list_free(GList* list);
+EXPORT_API void privilege_info_list_free(GList* list);
/**
* @brief Called to get a privilege group once for specific package.
*/
typedef int (*privilege_info_privileges_cb) (const char *privilege, void* user_data);
+/**
+ * @brief Retrieves privilege group list of the package.
+ * @param [in] package_id The package id
+ * @param [in] uid The uid of the package
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a nonzero error value.
+ * @retval #PRVMGR_ERR_NONE Successful
+ * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
+ * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
+ * @post This function invokes privilege_info_privilege_groups_cb() repeatedly for each application context.
+ * @see privilege_info_privilege_groups_cb()
+ */
+EXPORT_API int privilege_info_foreach_privilege_group_list_by_pkgid_and_uid(const char *package_id, uid_t uid, privilege_info_privilege_groups_cb callback, void* user_data);
+
/**
* @brief Retrieves privilege group list of the package.
* @param [in] package_id The package id
*/
EXPORT_API int privilege_info_foreach_privilege_group_list_by_pkgid(const char *package_id, privilege_info_privilege_groups_cb callback, void* user_data);
+/**
+ * @brief Retrieves privilege list in specific group of the package.
+ * @param [in] package_id The package id
+ * @param [in] uid The uid of the package
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a nonzero error value.
+ * @retval #PRVMGR_ERR_NONE Successful
+ * @retval #PRVMGR_ERR_INTERNAL_ERROR Internal error
+ * @retval #PRVMGR_ERR_INVALID_PARAMETER Invalid parameter
+ * @see privilege_info_privileges_cb()
+ */
+EXPORT_API int privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group_and_uid(const char *package_id, uid_t uid, const char* privilege_group, privilege_info_privileges_cb callback, void* user_data);
+
+
/**
* @brief Retrieves privilege list in specific group of the package.
* @param [in] package_id The package id
return PRVMGR_ERR_NONE;
}
+int privilege_info_foreach_privilege_group_list_by_pkgid_and_uid(const char *package_id, uid_t uid, privilege_info_privilege_groups_cb callback, void *user_data)
+{
+ int groupTable[MAX_PRV_GROUP] = { 0, };
+ int i = 0;
+ int res = PRVMGR_ERR_NONE;
+
+ TryReturn(package_id != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] package_id is NULL");
+ TryReturn(callback != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] callback is NULL");
+
+ pkgmgrinfo_pkginfo_h handle;
+ res = pkgmgrinfo_pkginfo_get_usr_pkginfo(package_id, uid, &handle);
+ TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_get_usr_pkginfo is failed.");
+
+ res = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_info_privilege_list_by_pkgid_callback, &groupTable);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_foreach_privilege is failed.");
+
+ for (i = 0; i < MAX_PRV_GROUP; i++) {
+ if (groupTable[i] == 1) {
+ res = callback(privilege_group_info_table[i].privilege_group, user_data);
+ TryReturn(res >= 0, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] return value of callback function is negative.");
+ }
+ }
+
+ return PRVMGR_ERR_NONE;
+}
+
int privilege_info_foreach_privilege_group_list_by_pkgid(const char *package_id, privilege_info_privilege_groups_cb callback, void *user_data)
{
int groupTable[MAX_PRV_GROUP] = { 0, };
return PRVMGR_ERR_NONE;
}
+int privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group_and_uid(const char *package_id, uid_t uid, const char *privilege_group, privilege_info_privileges_cb callback, void *user_data)
+{
+ int i = 0;
+ int res = PRVMGR_ERR_NONE;
+ privilege_list_cb_data data;
+
+ TryReturn(package_id != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] package_id is NULL");
+ TryReturn(privilege_group != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege_group is NULL");
+ TryReturn(callback != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] callback is NULL");
+
+ data.privilege_group = -1;
+ data.callback = callback;
+ data.user_data = user_data;
+
+ for (i = 0; i < MAX_PRV_GROUP; i++) {
+ if (strcmp(privilege_group_info_table[i].privilege_group, privilege_group) == 0) {
+ data.privilege_group = privilege_group_info_table[i].privilege_group_enum;
+ break;
+ }
+ }
+
+ if (data.privilege_group > -1) {
+ pkgmgrinfo_pkginfo_h handle;
+ res = pkgmgrinfo_pkginfo_get_usr_pkginfo(package_id, uid, &handle);
+ TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_get_usr_pkginfo is failed.");
+ res = pkgmgrinfo_pkginfo_foreach_privilege(handle, privilege_info_privilege_list_callback, &data);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ TryReturn(res == PMINFO_R_OK, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] pkgmgrinfo_pkginfo_foreach_privilege is failed.");
+ }
+
+ return PRVMGR_ERR_NONE;
+}
+
int privilege_info_foreach_privilege_list_by_pkgid_and_privilege_group(const char *package_id, const char *privilege_group, privilege_info_privileges_cb callback, void *user_data)
{
int i = 0;
return ret;
}
-static int __get_pkg_type(const char *pkgid, privilege_manager_package_type_e *pkg_type)
+static int __get_pkg_type(uid_t uid, const char *pkgid, privilege_manager_package_type_e *pkg_type)
{
int ret = 0;
char *type = NULL;
pkgmgrinfo_pkginfo_h handle;
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
if (ret != PMINFO_R_OK) {
- LOGE("failed to get pkginfo handle! pkgid <%s>", pkgid);
+ LOGE("failed to get pkginfo handle! pkgid <%s> uid <%d>", pkgid, uid);
return -1;
}
ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
ret = PRVMGR_ERR_NONE;
} else if (ret == 0) {
privilege_manager_package_type_e pkg_type = PRVMGR_PACKAGE_TYPE_NONE;
- ret = __get_pkg_type(pkgid, &pkg_type);
+ ret = __get_pkg_type(uid, pkgid, &pkg_type);
TryReturn(ret == 0 && pkg_type != PRVMGR_PACKAGE_TYPE_NONE, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] failed to get pkg type of <%s>", pkgid);
bool is_requestable = false;
return PRVMGR_ERR_NONE;
}
-static int __get_pkg_type(const char *pkgid, privilege_manager_package_type_e *pkg_type)
+static int __get_pkg_type(uid_t uid, const char *pkgid, privilege_manager_package_type_e *pkg_type)
{
int ret = 0;
char *type = NULL;
pkgmgrinfo_pkginfo_h handle;
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
if (ret != PMINFO_R_OK) {
LOGE("failed to get pkginfo handle! pkgid <%s>", pkgid);
return -1;
TryReturn(pkgid != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] pkgid must not be NULL.");
privilege_manager_package_type_e pkg_type = PRVMGR_PACKAGE_TYPE_NONE;
- int ret = __get_pkg_type(pkgid, &pkg_type);
+ int ret = __get_pkg_type(uid, pkgid, &pkg_type);
TryReturn(ret == 0 && pkg_type != PRVMGR_PACKAGE_TYPE_NONE, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] failed to get pkg type of <%s>", pkgid);
ret = privilege_db_manager_is_privacy_requestable(uid, pkgid, privilege, pkg_type, is_requestable);