From 2fc07e7d61f1e37aa3160c756c751e94586ad114 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Mon, 2 Aug 2021 14:55:23 +0900 Subject: [PATCH] temperature: adopt direct hal api Change-Id: I8e6d654a57895a327930f9dd966c830c76e7de9e Signed-off-by: Youngjae Cho --- src/temperature.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/temperature.c b/src/temperature.c index db8ab17..8931461 100644 --- a/src/temperature.c +++ b/src/temperature.c @@ -22,12 +22,11 @@ #include #include #include +#include #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; } -- 2.7.4