Tizen 2.4 SDK Rev6 Release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20160530.220204 submit/tizen_2.4/20160530.023114
authorJaekyu Park <jk7744.park@samsung.com>
Fri, 27 May 2016 07:48:53 +0000 (16:48 +0900)
committerJaekyu Park <jk7744.park@samsung.com>
Fri, 27 May 2016 07:48:53 +0000 (16:48 +0900)
src/common.h
src/display.c
src/power.c

index b747bb8..09cb0e9 100644 (file)
@@ -37,7 +37,7 @@
 
 static inline int errno_to_device_error(int err)
 {
-       if (err == -EACCES)
+       if (err == -EACCES || err == -EPERM || err == -ECOMM)
                return DEVICE_ERROR_PERMISSION_DENIED;
        else if (err == -EBUSY)
                return DEVICE_ERROR_RESOURCE_BUSY;
index 7cc728e..142100a 100644 (file)
@@ -85,8 +85,11 @@ int device_display_get_max_brightness(int display_index, int *max_brightness)
        if (!max_brightness)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
-       if (display_cnt < 0)
-               device_display_get_numbers(&display_cnt);
+       if (display_cnt < 0) {
+               ret = device_display_get_numbers(&display_cnt);
+               if (ret != DEVICE_ERROR_NONE)
+                       return ret;
+       }
 
        if (display_index < 0 || display_index >= display_cnt)
                return DEVICE_ERROR_INVALID_PARAMETER;
@@ -114,8 +117,11 @@ int device_display_get_brightness(int display_index, int *brightness)
        if (!brightness)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
-       if (display_cnt < 0)
-               device_display_get_numbers(&display_cnt);
+       if (display_cnt < 0) {
+               ret = device_display_get_numbers(&display_cnt);
+               if (ret != DEVICE_ERROR_NONE)
+                       return ret;
+       }
 
        if (display_index < 0 || display_index >= display_cnt)
                return DEVICE_ERROR_INVALID_PARAMETER;
@@ -136,8 +142,11 @@ int device_display_set_brightness(int display_index, int brightness)
        char str_val[32];
        int ret, max;
 
-       if (display_cnt < 0)
-               device_display_get_numbers(&display_cnt);
+       if (display_cnt < 0) {
+               ret = device_display_get_numbers(&display_cnt);
+               if (ret != DEVICE_ERROR_NONE)
+                       return ret;
+       }
 
        if (display_index < 0 || display_index >= display_cnt)
                return DEVICE_ERROR_INVALID_PARAMETER;
index 9fcd05f..cef3874 100644 (file)
@@ -92,6 +92,7 @@ static int lock_state(display_state_e state, unsigned int flag, int timeout_ms)
 {
        char *arr[4];
        char str_timeout[32];
+       int ret;
 
        arr[0] = get_state_str(state);
        if (!arr[0])
@@ -109,6 +110,14 @@ static int lock_state(display_state_e state, unsigned int flag, int timeout_ms)
        else
                arr[2] = STR_NULL;
 
+       snprintf(str_timeout, sizeof(str_timeout), "%d", -1);
+       arr[3] = str_timeout;
+       ret = dbus_method_sync(DEVICED_BUS_NAME,
+                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
+                       METHOD_LOCK_STATE, "sssi", arr);
+       if (ret == -EACCES || ret == -ECOMM || ret == -EPERM)
+               return -EACCES;
+
        snprintf(str_timeout, sizeof(str_timeout), "%d", timeout_ms);
        arr[3] = str_timeout;
 
@@ -133,6 +142,15 @@ static void unlock_cb(void *data, GVariant *result, GError *err)
 static int unlock_state(display_state_e state, unsigned int flag)
 {
        char *arr[2];
+       int ret;
+
+       arr[0] = "";
+       arr[1] = "";
+       ret = dbus_method_sync(DEVICED_BUS_NAME,
+                       DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY,
+                       METHOD_UNLOCK_STATE, "ss", arr);
+       if (ret == -EACCES || ret == -ECOMM || ret == -EPERM)
+               return -EACCES;
 
        arr[0] = get_state_str(state);
        if (!arr[0])