supply-battery: Assume battery is present if the attr is missing

Fixes: #208
This commit is contained in:
Benjamin Berg 2022-09-08 21:09:22 +02:00
parent b1edcc7cbb
commit c2e48aa9c2

View file

@ -145,7 +145,9 @@ up_device_supply_battery_refresh (UpDevice *device,
* we can restrict this to updates other than UP_REFRESH_POLL.
* NOTE: Only energy.full and cycle_count can change for a battery.
*/
info.present = g_udev_device_get_sysfs_attr_as_boolean_uncached (native, "present");
info.present = TRUE;
if (g_udev_device_has_sysfs_attr (native, "present"))
info.present = g_udev_device_get_sysfs_attr_as_boolean_uncached (native, "present");
if (!info.present) {
up_device_battery_update_info (battery, &info);
return TRUE;