Add display related feature to disable below API in TV 91/191091/3 accepted/tizen/unified/20181012.083533 submit/tizen/20181012.024418
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 11 Oct 2018 08:03:12 +0000 (17:03 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 11 Oct 2018 11:22:07 +0000 (20:22 +0900)
ex) device_power_wakeup, device_display_change_state

Change-Id: I1ac4d9d8000c5c37539975e9469bb534d1c14d3f
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
doc/device_doc.h
include/display.h
include/power.h
src/common.c
src/common.h
src/display.c
src/power.c

index 881d650..d30459e 100755 (executable)
  * It also supports the API to set the display brightness.
  * Application can receive the display event by callback function from the system.
  *
+ * @section CAPI_SYSTEM_DEVICE_DISPLAY_MODULE__FEATURE Related Features
+ * This API is related with the following features:\n
+ * - %http://tizen.org/feature/display.state\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, thereby controlling the procedure of your application.\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 List</b>.</a>
+ *
  */
 
 /**
  * The Power API provides the way to control the power service.
  * It can be made to hold the specific state to avoid changing display and CPU state internally.
  *
+ * @section CAPI_SYSTEM_DEVICE_POWER_MODULE__FEATURE Related Features
+ * This API is related with the following features:\n
+ * - %http://tizen.org/feature/display.state\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, thereby controlling the procedure of your application.\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 List</b>.</a>
+ *
  */
 
 /**
index b3b1c94..ac1624c 100755 (executable)
@@ -160,6 +160,7 @@ int device_display_get_state(display_state_e *state);
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
  * @see device_power_request_lock()
  * @see device_power_release_lock()
  * @see device_add_callback
index 6bd135c..9eaf2d4 100755 (executable)
@@ -108,6 +108,7 @@ int device_power_release_lock(power_lock_e type);
  * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied
  * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed
+ * @retval #DEVICE_ERROR_NOT_SUPPORTED Not supported device
  * @post The device will be in #DISPLAY_STATE_NORMAL state.
  */
 int device_power_wakeup(bool dim) TIZEN_DEPRECATED_API;
index 7e69038..5f801b7 100755 (executable)
@@ -30,6 +30,7 @@
 
 #define MODEL_NAME      "http://tizen.org/system/model_name"
 #define MODEL_EMULATOR  "Emulator"
+#define DISPLAY_STATE_FEATURE     "http://tizen.org/feature/display.state"
 
 static inline char *trim_str(char *s)
 {
@@ -239,3 +240,19 @@ bool is_emulator(void)
 
        return emul;
 }
+
+int is_display_state_supported(void)
+{
+       int ret;
+       bool display_state_avail;
+
+       ret = system_info_get_platform_bool(DISPLAY_STATE_FEATURE, &display_state_avail);
+       if (ret < 0) {
+               _E("Failed to get value of display state feature");
+               return false;
+       } else if (ret == 0 && !display_state_avail) {
+               _D("Display state feature is not supported");
+               return false;
+       } else
+               return true;
+}
index 43da9f9..4e720d6 100755 (executable)
@@ -83,4 +83,5 @@ int check_async_call_rate(void);
 #define TIZEN_FEATURE_TRACKER (_get_tizen_profile() == TIZEN_PROFILE_TV)
 
 bool is_emulator(void);
+int is_display_state_supported(void);
 #endif /* __COMMON_H__ */
index de915c0..f8d958f 100755 (executable)
@@ -244,6 +244,10 @@ int device_display_change_state(display_state_e state)
        int ret;
        static int privilege = -1;
 
+       ret = is_display_state_supported();
+       if (!ret)
+               return DEVICE_ERROR_NOT_SUPPORTED;
+
        if (check_async_call_rate() < 0) {
                _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
                                , CHECK_RATE_THRESHOLD);
index 58c1bbf..92499d2 100755 (executable)
@@ -498,6 +498,12 @@ int device_power_release_lock(power_lock_e type)
 
 int device_power_wakeup(bool dim)
 {
+       int ret;
+
+       ret = is_display_state_supported();
+       if (!ret)
+               return DEVICE_ERROR_NOT_SUPPORTED;
+
        if (dim)
                return device_display_change_state(DISPLAY_STATE_SCREEN_DIM);