capi-system-device: Add restriction on led flash api 56/39756/1
authorJiyoung Yun <jy910.yun@samsung.com>
Fri, 22 May 2015 04:26:35 +0000 (13:26 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Fri, 22 May 2015 04:26:35 +0000 (13:26 +0900)
Flash led can't control camera flash when camera API preempted flash.
In this case, led api will return DEVICE_ERROR_RESOURCE_BUSY error.

Change-Id: I13c1cbccb854be5a0309711145a69a010adfe94c
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
include/device-error.h
include/led.h
src/common.h
src/led.c

index cfdaa52..6cbe279 100755 (executable)
@@ -42,6 +42,7 @@ typedef enum
        DEVICE_ERROR_INVALID_PARAMETER   = TIZEN_ERROR_INVALID_PARAMETER,   /**< Invalid parameter */
        DEVICE_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_ALREADY_IN_PROGRESS, /**< Operation already in progress */
        DEVICE_ERROR_NOT_SUPPORTED       = TIZEN_ERROR_NOT_SUPPORTED,       /**< Not supported in this device */
+       DEVICE_ERROR_RESOURCE_BUSY       = TIZEN_ERROR_RESOURCE_BUSY,       /**< Device or resource busy */
        DEVICE_ERROR_NOT_INITIALIZED     = TIZEN_ERROR_DEVICE | 0x13,       /**< Not initialized */
 } device_error_e;
 
index 7a659af..e1ffc72 100755 (executable)
@@ -77,6 +77,8 @@ int device_flash_get_brightness(int *brightness);
  * @privlevel public
  * @privilege %http://tizen.org/privilege/led
  *
+ * @remarks Since 2.4, this API check camera flash status whether camera API preempted flash or not, so it could be failed if flash was preempted by camera API. In this case, API will return #DEVICE_ERROR_RESOURCE_BUSY error.
+ *
  * @param[in] brightness The brightness value of LED (@c 0 ~ MAX)
  *
  * @return @c 0 on success,
@@ -87,6 +89,7 @@ int device_flash_get_brightness(int *brightness);
  * @retval #DEVICE_ERROR_PERMISSION_DENIED  Permission denied
  * @retval #DEVICE_ERROR_OPERATION_FAILED   Operation failed
  * @retval #DEVICE_ERROR_NOT_SUPPORTED      Not supported device
+ * @retval #DEVICE_ERROR_RESOURCE_BUSY      Device or resource busy
  */
 int device_flash_set_brightness(int brightness);
 
index 2c1cbb8..b747bb8 100644 (file)
@@ -39,6 +39,8 @@ static inline int errno_to_device_error(int err)
 {
        if (err == -EACCES)
                return DEVICE_ERROR_PERMISSION_DENIED;
+       else if (err == -EBUSY)
+               return DEVICE_ERROR_RESOURCE_BUSY;
        else if (err == -ENOTSUP || err == -ENODEV || err == -ENOENT)
                return DEVICE_ERROR_NOT_SUPPORTED;
        else if (err < 0)
index c1718fb..f0245b3 100644 (file)
--- a/src/led.c
+++ b/src/led.c
@@ -112,6 +112,7 @@ int device_flash_set_brightness(int brightness)
        snprintf(buf_noti, sizeof(buf_noti), "%d", 0);
        arr[1] = buf_noti;
 
+       /* if camera API preempt a flash device, it will return -EBUSY error. */
        ret = dbus_method_sync(DEVICED_BUS_NAME,
                        DEVICED_PATH_LED, DEVICED_INTERFACE_LED,
                        METHOD_SET_BRIGHTNESS, "ii", arr);