From: Youngjae Cho Date: Mon, 6 Jan 2020 08:09:38 +0000 (+0900) Subject: Support display changestate by reason as internal api X-Git-Tag: submit/tizen/20200108.103615^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=343cb6eaf68faea3235f27a655451a255a489344;p=platform%2Fcore%2Fapi%2Fdevice.git Support display changestate by reason as internal api Change-Id: I525b1367845ad3ccc6ee0068504c73492d5efd10 Signed-off-by: Youngjae Cho --- diff --git a/include/display-enum.h b/include/display-enum.h new file mode 100644 index 0000000..3b55dbc --- /dev/null +++ b/include/display-enum.h @@ -0,0 +1,15 @@ +#ifndef __TIZEN_SYSTEM_DISPLAY_ENUM_H__ +#define __TIZEN_SYSTEM_DISPLAY_ENUM_H__ + +/** + * @brief Enumeration for the available display states. + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + */ +typedef enum +{ + DISPLAY_STATE_NORMAL, /**< Normal state */ + DISPLAY_STATE_SCREEN_DIM, /**< Screen dim state */ + DISPLAY_STATE_SCREEN_OFF, /**< Screen off state */ +} display_state_e; + +#endif diff --git a/include/display-internal.h b/include/display-internal.h index a1c4ba6..84612f9 100644 --- a/include/display-internal.h +++ b/include/display-internal.h @@ -16,17 +16,18 @@ #ifndef __TIZEN_SYSTEM_DISPLAY_INTERNAL_H__ -#define __TIZEN_SYSTEM_LED_INTERNAL_H__ +#define __TIZEN_SYSTEM_DISPLAY_INTERNAL_H__ -#include "device-error.h" +#include +#include "device-error.h" +#include "display-enum.h" #ifdef __cplusplus extern "C" { #endif - /** * @brief Gets the display brightness value. * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif @@ -96,11 +97,31 @@ int device_display_get_max_brightness_state(int display_index, display_state_e s */ int device_display_set_brightness_state(int display_index, display_state_e state, int brightness); +typedef void (*dbus_pending_cb)(void *data, GVariant *result, GError *err); +/** + * @brief Change display state by a specific reason + * @since_tizen @if MOBILE 5.0 @elseif WEARABLE 5.0 @endif + * @privlevel public + * @privilege %http://tizen.org/privilege/display + * @param[in] type The type is display state to change\n + * DISPLAY_STATE_NORMAL : change to normal\n + * DISPLAY_STATE_SCREEN_OFF: change to off\n + * @param[in] reason Reason that causes display chage state\n + * @param[in] timeout Timeout to change state\n + * @param[in] cb Callback function for handling result of dbus method call\n + * @return @c 0 on success, + * otherwise a negative error value + * @retval #DEVICE_ERROR_NONE Successful + * @retval #DEVICE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #DEVICE_ERROR_PERMISSION_DENIED Permission denied + * @retval #DEVICE_ERROR_OPERATION_FAILED Operation failed + * @see device_display_change_state_by_reason() + */ +int device_display_change_state_by_reason(display_state_e type, char *reason, int timeout, dbus_pending_cb cb); #ifdef __cplusplus } #endif #endif // __TIZEN_SYSTEM_DISPLAY_INTERNAL_H__ - diff --git a/include/display.h b/include/display.h index 04b5eb5..5d1502a 100644 --- a/include/display.h +++ b/include/display.h @@ -20,7 +20,7 @@ #include "device-error.h" - +#include "display-enum.h" #ifdef __cplusplus extern "C" { @@ -127,18 +127,6 @@ int device_display_get_brightness(int display_index, int *brightness); int device_display_set_brightness(int display_index, int brightness); -/** - * @brief Enumeration for the available display states. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif - */ -typedef enum -{ - DISPLAY_STATE_NORMAL, /**< Normal state */ - DISPLAY_STATE_SCREEN_DIM, /**< Screen dim state */ - DISPLAY_STATE_SCREEN_OFF, /**< Screen off state */ -} display_state_e; - - /** * @brief Gets the current display state. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif diff --git a/src/display.c b/src/display.c index 351febf..fc46032 100644 --- a/src/display.c +++ b/src/display.c @@ -20,14 +20,16 @@ #include #include "display.h" +#include "display-internal.h" #include "common.h" #include "dbus.h" -#define METHOD_GET_DISPLAY_COUNT "GetDisplayCount" -#define METHOD_GET_MAX_BRIGHTNESS "GetMaxBrightness" -#define METHOD_GET_BRIGHTNESS "GetBrightness" -#define METHOD_SET_BRIGHTNESS "SetBrightness" -#define METHOD_CHANGE_STATE "changestate" +#define METHOD_GET_DISPLAY_COUNT "GetDisplayCount" +#define METHOD_GET_MAX_BRIGHTNESS "GetMaxBrightness" +#define METHOD_GET_BRIGHTNESS "GetBrightness" +#define METHOD_SET_BRIGHTNESS "SetBrightness" +#define METHOD_CHANGE_STATE "changestate" +#define METHOD_CHANGE_STATE_BY_REASON "ChangeStateByReason" #define STR_LCD_OFF "lcdoff" #define STR_LCD_DIM "lcddim" @@ -459,4 +461,26 @@ int device_display_set_brightness_state(int display_index, display_state_e state return DEVICE_ERROR_NONE; } + +int device_display_change_state_by_reason(display_state_e type, char *reason, int timeout, dbus_pending_cb cb) +{ + char *arr[3]; + char _type[32]; + char _timeout[32]; + int ret; + + snprintf(_type, sizeof(_type), "%d", type); + snprintf(_timeout, sizeof(_timeout), "%d", timeout); + + arr[0] = _type; + arr[1] = reason; + arr[2] = _timeout; + + ret = dbus_method_async_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, + METHOD_CHANGE_STATE_BY_REASON, "isi", arr, cb, -1, NULL); + + return errno_to_device_error(ret); +} + //LCOV_EXCL_STOP