Support display changestate by reason as internal api 75/221875/2 accepted/tizen/5.5/unified/20200109.063402 submit/tizen_5.5/20200108.103818
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 6 Jan 2020 08:09:38 +0000 (17:09 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 8 Jan 2020 07:53:20 +0000 (07:53 +0000)
Change-Id: I525b1367845ad3ccc6ee0068504c73492d5efd10
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
(cherry picked from commit 343cb6eaf68faea3235f27a655451a255a489344)

include/display-enum.h [new file with mode: 0644]
include/display-internal.h
include/display.h
src/display.c

diff --git a/include/display-enum.h b/include/display-enum.h
new file mode 100644 (file)
index 0000000..3b55dbc
--- /dev/null
@@ -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
index a1c4ba6..84612f9 100644 (file)
 
 
 #ifndef __TIZEN_SYSTEM_DISPLAY_INTERNAL_H__
-#define __TIZEN_SYSTEM_LED_INTERNAL_H__
+#define __TIZEN_SYSTEM_DISPLAY_INTERNAL_H__
 
 
-#include "device-error.h"
+#include <gio/gio.h>
 
+#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__
-
index 04b5eb5..5d1502a 100644 (file)
@@ -20,7 +20,7 @@
 
 
 #include "device-error.h"
-
+#include "display-enum.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -128,18 +128,6 @@ 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
  * @remarks #DEVICE_ERROR_NOT_SUPPORTED is returned, when the following feature is not supported: %http://tizen.org/feature/display
index 351febf..fc46032 100644 (file)
 #include <vconf.h>
 
 #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