battery: Replace macro power source definitions to hal_device_battery_power_source_type_e 99/310099/5
authorYunhee Seo <yuni.seo@samsung.com>
Mon, 22 Apr 2024 11:21:16 +0000 (20:21 +0900)
committerYunhee Seo <yuni.seo@samsung.com>
Tue, 23 Apr 2024 11:40:17 +0000 (20:40 +0900)
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 <yuni.seo@samsung.com>
src/battery.c

index c261a17..96303a5 100644 (file)
@@ -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;