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;