From 9bc66af96f65ec7777ac565ab29e9d35dd69c3ea Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 18 Oct 2013 16:11:15 +0200 Subject: linux: Fix Bluetooth devices appearing with 0% battery When switching off Bluetooth devices, and before they timeout, we won't be able to read the battery percentage, so don't overwrite the previous value with "0%", but set the state to unknown instead. https://bugs.freedesktop.org/show_bug.cgi?id=70325 --- src/linux/up-device-supply.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/linux') diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c index 6edf420..85c6f9f 100644 --- a/src/linux/up-device-supply.c +++ b/src/linux/up-device-supply.c @@ -851,7 +851,13 @@ up_device_supply_refresh_device (UpDeviceSupply *supply) } /* get a precise percentage */ - percentage = sysfs_get_double (native_path, "capacity"); + percentage = sysfs_get_double_with_error (native_path, "capacity"); + if (percentage < 0.0) { + /* Probably talking to the device over Bluetooth */ + state = UP_DEVICE_STATE_UNKNOWN; + g_object_set (device, "state", state, NULL); + return FALSE; + } state = up_device_supply_get_state (native_path); -- cgit v1.2.1