#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"
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;
}