Add privilege_info_has_privacy_attr() 28/243728/1
authorYunjin Lee <yunjin-.lee@samsung.com>
Wed, 9 Sep 2020 10:24:13 +0000 (19:24 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Wed, 9 Sep 2020 10:24:13 +0000 (19:24 +0900)
- Add API to check whether the given privilege has privacy attribute.
(privilege_info_is_privacy() can return different result according to
 the environment whether privacy is enabled or not, but it doesn't.)

Change-Id: I678651ee9f8400282621d787fa8346a55597b1c6
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
capi/include/privilege_info.h
capi/src/privilege_info.c
test/tc-privilege-info.c

index 993d3a6572cd26084d1c0e00b89b5d839650657a..ff1efa06acf867c3474072988537fc00a8eda834 100644 (file)
@@ -198,11 +198,19 @@ EXPORT_API int privilege_info_is_internal(const char *privilege);
 
 /**
  * @brief Determines whether the given privilege is privacy related or not.
+ * @remarks If privacy is disabled then all privileges are not privacy related.
  * @param [in]  privilege The privilege
  * @return 1 if true(=is privacy related privilege), 0 if false, and -1 on error
  */
 EXPORT_API int privilege_info_is_privacy(const char *privilege);
 
+/**
+ * @brief Check if the given privilege has privacy attribute or not.
+ * @param [in] privilege The privilege
+ * @return 1 if true(=has privacy attr), 0 if false, and -1 on error
+ */
+EXPORT_API int privilege_info_has_privacy_attr(const char *privilege);
+
 /**
  * @brief Determines whether the privacy of given pkgid is user-settable
  * @param [in]  pkgid The package id
index 84c86649c89679a56f890295250427ddd44e9c20..b224d3824755fc07cbde05bbca468eadf603c260 100755 (executable)
@@ -459,6 +459,13 @@ int privilege_info_is_privacy(const char* privilege)
        return ret;
 }
 
+int privilege_info_has_privacy_attr(const char* privilege)
+{
+       TryReturn(privilege != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] privilege is NULL");
+       int ret = privilege_db_manager_is('p', privilege);
+       return (ret != 0 && ret != 1) ? -1 : ret;
+}
+
 static int __get_pkg_type(uid_t uid, const char *pkgid, privilege_manager_package_type_e *pkg_type)
 {
        int ret = 0;
index 1f76ffae39e5fd38eba09924c326fc734fe0a752..ed32c3979953684454638ebeaa6ec47b88cbecef 100755 (executable)
@@ -834,6 +834,8 @@ int main()
 
        //TODO: add testcase for privilege_info_get_privilege_noti_info_list() & privilege_info_free_privilege_noti_info_list()
 
+       //TODO: add testcase for privilege_info_has_privacy_attr()
+
        printf_green("Test Complete\n");
        printf_green("success : %d, ", success_cnt);