Add privacy feature and deprecate redundant API 29/172029/10 accepted/tizen_5.0_unified accepted/tizen/5.0/unified/20181102.020511 accepted/tizen/unified/20180508.071603 submit/tizen/20180503.050452 submit/tizen/20180508.005813 submit/tizen/20180508.011915 submit/tizen_5.0/20181101.000004
authorYunjin Lee <yunjin-.lee@samsung.com>
Fri, 9 Mar 2018 05:33:51 +0000 (14:33 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Tue, 24 Apr 2018 07:55:11 +0000 (16:55 +0900)
- Add privacy feature to distinguish profiles that are not supporting
privacy feature

- Add error enum PRVINFO_ERROR_NOT_SUPPORTED

- Deprecate privilege_info_get_privacy_privilege_status() since the same
function is provided at privacy_privilege_manager(ppm_check_permission()).

Change-Id: Ica1cd1eef95f9ff00f951bc96f50b5d45b90c4cb
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
doc/privilege-info_doc.h
packaging/privilege-info.spec
src/CMakeLists.txt
src/include/privilege_information.h
src/privilege_info.c
test/tc_privilege_info.c

index d65741a..816e384 100755 (executable)
  * A library for reading privilege information of the given privilege and API issue version.
  * It provides the display name or description of privileges.
  * If there's no matching privilege then it shows last token of given privilege or description string for undefined privileges.
+ *
+ * @section CAPI_SECURITY_FRAMEWORK_PRIVILEGE_INFO_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/security.privacy_privilege\n
+ * It is recommended to design feature related codes in your application for reliability.\n
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly.\n
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ * More details on featuring your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
  */
 
 
index 2c9c646..b23542c 100644 (file)
@@ -1,6 +1,6 @@
 Name:    privilege-info
 Summary: Privilege Information
-Version: 0.0.1
+Version: 0.0.2
 Release: 1
 Group:   Security/API
 License: Apache-2.0
@@ -17,6 +17,7 @@ BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-session)
 BuildRequires: pkgconfig(libsmack)
 BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(capi-system-info)
 
 %description
 Provides Privilege Information(Privilege Info) API
index 9ef2023..2103600 100755 (executable)
@@ -8,7 +8,7 @@ SET(PRIV_INFO_SOURCES
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
 
-SET(requires glib-2.0 dlog security-privilege-manager cynara-client cynara-session libsmack)
+SET(requires glib-2.0 dlog security-privilege-manager cynara-client cynara-session libsmack capi-system-info)
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires})
 FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
index b6c47af..fbfad92 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
  * you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ typedef enum {
        PRVINFO_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
        PRVINFO_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
        PRVINFO_ERROR_INTERNAL_ERROR = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
+       PRVINFO_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not supported (Since 5.0) */
 } privilege_info_error_e;
 
 
@@ -130,11 +131,13 @@ int privilege_info_get_description_by_pkgtype(const char *package_type, const ch
  * @retval #PRVINFO_ERROR_OUT_OF_MEMORY Out of memory
  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ * @retval #PRVINFO_ERROR_NOT_SUPPORTED Not supported
  */
 int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_name);
 
 
 /**
+ * @deprecated Deprecated since 5.0. Use ppm_check_permission() instead. You can refer to @ref CAPI_PRIVACY_PRIVILEGE_MANAGER_MODULE.
  * @brief Gets the status of the given privacy related privilege.
  * @since_tizen 3.0
  * @remarks @a privilege must be privacy related, otherwise #PRVINFO_ERROR_INVALID_PARAMETER is returned.
@@ -147,6 +150,7 @@ int privilege_info_get_privacy_display_name(const char *privilege, char **privac
  * @retval #PRVINFO_ERROR_NONE Successful
  * @retval #PRVINFO_ERROR_INVALID_PARAMETER Invalid function parameter
  * @retval #PRVINFO_ERROR_INTERNAL_ERROR Unknown error
+ * @retval #PRVINFO_ERROR_NOT_SUPPORTED Not supported
  */
 int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status);
 
index a300b00..79b2ea7 100755 (executable)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 2014-2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <libintl.h>
 #include <cynara-client.h>
 #include <unistd.h>
 #include <sys/smack.h>
+#include <system_info.h>
 #include "privilege_information.h"
 #ifdef LOG_TAG
 #undef LOG_TAG
 #define LOG_TAG "PRIVILEGE_INFO"
 #endif
 
+#define PRIVACY_FEATURE "http://tizen.org/feature/security.privacy_privilege"
+#define CHECK_FEATURE_SUPPORTED(feature_name) \
+       do { \
+               bool is_supported = false; \
+               int ret = system_info_get_platform_bool(feature_name, &is_supported); \
+               if (ret != SYSTEM_INFO_ERROR_NONE) { \
+                       LOGE("system_info_get_platform_bool failed. ret = %d", ret); \
+                       return PRVINFO_ERROR_INTERNAL_ERROR; \
+               } \
+               if (!is_supported) { \
+                       LOGE("%s is disabled", feature_name); \
+                       return PRVINFO_ERROR_NOT_SUPPORTED; \
+               } \
+       } while (0)
+
 #define UIDMAXLEN 10
 
 #define TryReturn(condition, expr, returnValue, ...)  \
@@ -235,6 +267,7 @@ int privilege_info_get_description_by_pkgtype(const char *package_type, const ch
 PI_API
 int privilege_info_get_privacy_display_name(const char *privilege, char **privacy_display_name)
 {
+       CHECK_FEATURE_SUPPORTED(PRIVACY_FEATURE);
        TryReturn(privilege != NULL, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
        TryReturn(privilege_db_manager_is('p', privilege) == 1, , PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related");
 
@@ -255,6 +288,7 @@ int privilege_info_get_privacy_display_name(const char *privilege, char **privac
 PI_API
 int privilege_info_get_privacy_privilege_status(const char *privilege, bool *status)
 {
+       CHECK_FEATURE_SUPPORTED(PRIVACY_FEATURE);
        TryReturn(privilege != NULL, *status = true, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege is NULL");
        TryReturn(privilege_db_manager_is('p', privilege) == 1, *status = true, PRVINFO_ERROR_INVALID_PARAMETER, "[PRVINFO_ERROR_INVALID_PARAMETER] privilege does not exist or is not a privacy related");
 
@@ -291,4 +325,3 @@ int privilege_info_get_privacy_privilege_status(const char *privilege, bool *sta
 
        return ret;
 }
-
index 08de15d..fb7e7c6 100755 (executable)
@@ -41,6 +41,8 @@ static const char* __get_result_string(privilege_info_error_e ret)
                return "PRVINFO_ERROR_OUT_OF_MEMORY";
        else if (ret == PRVINFO_ERROR_INTERNAL_ERROR)
                return "PRVINFO_ERROR_INTERNAL_ERROR";
+       else if (ret == PRVINFO_ERROR_NOT_SUPPORTED)
+               return "PRVINFO_ERROR_NOT_SUPPORTED";
 
        return "PRVINFO_ERROR_NO_MATCHED_ERROR_MESSAGE";
 }