temperature: adopt direct hal api 56/262056/1 accepted/tizen/unified/20210804.085711 submit/tizen/20210802.064402
authorYoungjae Cho <y0.cho@samsung.com>
Mon, 2 Aug 2021 05:55:23 +0000 (14:55 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 2 Aug 2021 05:59:57 +0000 (14:59 +0900)
Change-Id: I8e6d654a57895a327930f9dd966c830c76e7de9e
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/temperature.c

index db8ab17..8931461 100644 (file)
 #include <glib.h>
 #include <system_info.h>
 #include <libsyscommon/libgdbus.h>
+#include <hal/device/hal-thermal.h>
 
 #include "common.h"
 #include "temperature.h"
 
-#define METHOD_GET_TEMPERATURE   "GetTemperature"
-
 #define THERMAL_AP_FEATURE             "http://tizen.org/feature/thermistor.ap"
 #define THERMAL_CP_FEATURE             "http://tizen.org/feature/thermistor.cp"
 #define THERMAL_BATTERY_FEATURE                "http://tizen.org/feature/thermistor.battery"
@@ -59,24 +58,32 @@ static int is_temperature_supported(device_thermal_e type)
 
 int device_thermal_get_temperature(device_thermal_e type, int *temp)
 {
-       int ret_val, val;
+       int ret_val;
+       struct thermal_info info;
+       hal_device_thermal_e haltype;
 
-       if (type > DEVICE_THERMAL_BATTERY)
+       if (!temp)
+               return DEVICE_ERROR_INVALID_PARAMETER;
+
+       if (type == DEVICE_THERMAL_AP)
+               haltype = HAL_DEVICE_THERMAL_AP;
+       else if (type == DEVICE_THERMAL_CP)
+               haltype = HAL_DEVICE_THERMAL_CP;
+       else if (type == DEVICE_THERMAL_BATTERY)
+               haltype = HAL_DEVICE_THERMAL_BATTERY;
+       else
                return DEVICE_ERROR_INVALID_PARAMETER;
 
        ret_val = is_temperature_supported(type);
        if (!ret_val)
                return DEVICE_ERROR_NOT_SUPPORTED;
 
-       ret_val = gdbus_call_sync_with_reply_int(DEVICED_BUS_NAME,
-                       DEVICED_PATH_TEMPERATURE,
-                       DEVICED_INTERFACE_TEMPERATURE,
-                       METHOD_GET_TEMPERATURE, g_variant_new("(i)", type),
-                       &val);
+       ret_val = hal_device_thermal_get_info(haltype, &info);
        if (ret_val < 0)
                return errno_to_device_error(ret_val); //LCOV_EXCL_LINE System Error
 
-       *temp = val;
+       *temp = info.temp;
+
        return DEVICE_ERROR_NONE;
 }