From: lokilee73 Date: Thu, 11 Oct 2018 08:03:12 +0000 (+0900) Subject: Add display related feature to disable below API in TV X-Git-Tag: accepted/tizen/unified/20181012.083533^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02493894609b4ffad3b22a0a10a5ff5f5cb208f0;p=platform%2Fcore%2Fapi%2Fdevice.git Add display related feature to disable below API in TV ex) device_power_wakeup, device_display_change_state Change-Id: I1ac4d9d8000c5c37539975e9469bb534d1c14d3f Signed-off-by: lokilee73 --- diff --git a/doc/device_doc.h b/doc/device_doc.h index 881d650..d30459e 100755 --- a/doc/device_doc.h +++ b/doc/device_doc.h @@ -87,6 +87,18 @@ * 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 Feature List. + * */ /** @@ -154,6 +166,18 @@ * 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 Feature List. + * */ /** diff --git a/include/display.h b/include/display.h index b3b1c94..ac1624c 100755 --- a/include/display.h +++ b/include/display.h @@ -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 diff --git a/include/power.h b/include/power.h index 6bd135c..9eaf2d4 100755 --- a/include/power.h +++ b/include/power.h @@ -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; diff --git a/src/common.c b/src/common.c index 7e69038..5f801b7 100755 --- a/src/common.c +++ b/src/common.c @@ -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; +} diff --git a/src/common.h b/src/common.h index 43da9f9..4e720d6 100755 --- a/src/common.h +++ b/src/common.h @@ -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__ */ diff --git a/src/display.c b/src/display.c index de915c0..f8d958f 100755 --- a/src/display.c +++ b/src/display.c @@ -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); diff --git a/src/power.c b/src/power.c index 58c1bbf..92499d2 100755 --- a/src/power.c +++ b/src/power.c @@ -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);