From 1638b0ca926e31430f2a7c708d8a763e1552428e Mon Sep 17 00:00:00 2001 From: Yunhee Seo Date: Mon, 22 Apr 2024 20:21:16 +0900 Subject: [PATCH] battery: Replace macro power source definitions to hal_device_battery_power_source_type_e As Power source type macro are replaced by hal_device_battery_power_source_type_e, definition usage logic is also changed. To get hal_device_battery_power_source_type_e string, hal_device_battery_power_get_power_source_name is used. Change-Id: Id7833b6e58d6913b41d27c6ad2053854f293ef66 Signed-off-by: Yunhee Seo --- src/battery.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/battery.c b/src/battery.c index c261a17..96303a5 100644 --- a/src/battery.c +++ b/src/battery.c @@ -137,13 +137,19 @@ int device_battery_get_level_status(device_battery_level_e *status) static void battery_get_info(hal_device_battery_info_s *info, void *data) { struct device_battery_info *bat = data; + const char* power_source_name = NULL; + int ret = 0; if (!info || !bat) return; snprintf(bat->status, sizeof(bat->status), "%s", info->status); snprintf(bat->health, sizeof(bat->health), "%s", info->health); - snprintf(bat->power_source, sizeof(bat->power_source), "%s", info->power_source); + ret = hal_device_battery_get_power_source_name(info->power_source, &power_source_name); + if (ret < 0) + _W("Failed to get battery power source name"); + if (power_source_name) + snprintf(bat->power_source, sizeof(bat->power_source), "%s", power_source_name); bat->online = info->online; bat->present = info->present; bat->capacity = info->capacity; -- 2.7.4