From c2e48aa9c29cff92bda60607266dbe4da10b95fd Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Thu, 8 Sep 2022 21:09:22 +0200 Subject: supply-battery: Assume battery is present if the attr is missing Fixes: #208 --- src/linux/up-device-supply-battery.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/linux/up-device-supply-battery.c b/src/linux/up-device-supply-battery.c index bef5857..f37c8a4 100644 --- a/src/linux/up-device-supply-battery.c +++ b/src/linux/up-device-supply-battery.c @@ -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; -- cgit v1.2.1