capi-system-device: Remove deviced dependency 96/38096/1 accepted/tizen/common/20150414.100026 accepted/tizen/mobile/20150415.015004 accepted/tizen/tv/20150415.012530 accepted/tizen/wearable/20150415.013751 submit/tizen/20150413.081634
authorJiyoung Yun <jy910.yun@samsung.com>
Mon, 13 Apr 2015 02:30:47 +0000 (11:30 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Mon, 13 Apr 2015 03:05:03 +0000 (12:05 +0900)
The capi-system-device can invoke dbus method without deviced dependency.
Some function of device header file is deprecated.

Change-Id: If0da743246ea30e87bfddf1604d04790c7f61d7a
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
CMakeLists.txt
packaging/capi-system-device.spec
src/device.c

index acefee1..974e587 100755 (executable)
@@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 SET(INC_DIR include)
 INCLUDE_DIRECTORIES(${INC_DIR})
 
-SET(dependents "deviced dlog vconf dbus-1 dbus-glib-1 capi-base-common capi-system-info")
+SET(dependents "dlog vconf dbus-1 dbus-glib-1 capi-base-common capi-system-info")
 SET(pc_dependents "capi-base-common")
 
 INCLUDE(FindPkgConfig)
index 895b1ef..52e176e 100644 (file)
@@ -7,7 +7,6 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    capi-system-device.manifest
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(deviced)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires:  pkgconfig(dlog)
index 4fdb11e..a58f2d1 100644 (file)
@@ -18,8 +18,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#include <dd-display.h>
-#include <dd-battery.h>
 #include <vconf.h>
 
 #include "device.h"
 
 int device_get_display_numbers(int* device_number)
 {
-       if(device_number == NULL)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       *device_number = display_get_count();
-       CHECK_ERR(*device_number);
-
-       return DEVICE_ERROR_NONE;
+       return device_display_get_numbers(device_number);
 }
 
 int device_get_brightness(int disp_idx, int* value)
 {
-       int val, max_id, ret;
-
-       if(value == NULL)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = device_get_display_numbers(&max_id);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(disp_idx < 0 || disp_idx >= max_id)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       val = display_get_brightness();
-       CHECK_ERR(val);
-
-       *value = val;
-       return DEVICE_ERROR_NONE;
+       return device_display_get_brightness(disp_idx, value);
 }
 
 int device_set_brightness(int disp_idx, int new_value)
 {
-       int max_value, val, max_id, ret;
-
-       if(new_value < 0)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = device_get_display_numbers(&max_id);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(disp_idx < 0 || disp_idx >= max_id)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = device_get_max_brightness(disp_idx, &max_value);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(new_value > max_value)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       val = display_set_brightness(new_value);
-       CHECK_ERR(val);
-
-       return DEVICE_ERROR_NONE;
+       _E("Deprecated api.");
+       return DEVICE_ERROR_NOT_SUPPORTED;
 }
 
 int device_get_max_brightness(int disp_idx, int* max_value)
 {
-       int val, max_id, ret;
-
-       if(max_value == NULL)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = device_get_display_numbers(&max_id);
-       _E("max id : %d", max_id);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(disp_idx < 0 || disp_idx >= max_id)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       val = display_get_max_brightness();
-       CHECK_ERR(val);
-
-       *max_value = val;
-       return DEVICE_ERROR_NONE;
+       return device_display_get_max_brightness(disp_idx, max_value);
 }
 
 int device_set_brightness_from_settings(int disp_idx)
 {
-       int max_id, val, ret;
-
-       ret = device_get_display_numbers(&max_id);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(disp_idx < 0 || disp_idx >= max_id)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       val = display_release_brightness();
-       CHECK_ERR(val);
-
-       return DEVICE_ERROR_NONE;
+       _E("Deprecated api.");
+       return DEVICE_ERROR_NOT_SUPPORTED;
 }
 
 int device_set_brightness_to_settings(int disp_idx, int new_value)
 {
-       int max_value, val, max_id, ret;
-
-       if(new_value < 0)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = device_get_display_numbers(&max_id);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(disp_idx < 0 || disp_idx >= max_id)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       ret = device_get_max_brightness(disp_idx, &max_value);
-       if (ret != DEVICE_ERROR_NONE)
-               return ret;
-
-       if(new_value > max_value)
-               return DEVICE_ERROR_INVALID_PARAMETER;
-
-       val = display_set_brightness_with_setting(new_value);
-       CHECK_ERR(val);
-
-       return DEVICE_ERROR_NONE;
+       return device_display_set_brightness(disp_idx, new_value);
 }
 
 int device_battery_get_detail(int *percent)
@@ -167,13 +72,20 @@ int device_battery_get_detail(int *percent)
 
 int device_battery_is_full(bool* full)
 {
+       device_battery_level_e status;
+       int ret;
+
        if (full == NULL)
                return DEVICE_ERROR_INVALID_PARAMETER;
 
-       int f = battery_is_full();
-       CHECK_ERR(f);
+       ret = device_battery_get_level_status(&status);
+       CHECK_ERR(ret);
+
+       if (status == DEVICE_BATTERY_LEVEL_FULL)
+               *full = true;
+       else
+               *full = false;
 
-       *full = (f == 1) ? true : false;
        return DEVICE_ERROR_NONE;
 }