diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-10-18 16:11:15 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2013-10-18 16:16:54 +0200 |
commit | 9bc66af96f65ec7777ac565ab29e9d35dd69c3ea (patch) | |
tree | 61566ec5cc15a6092441d27d55f8f1d82635b887 /src/linux | |
parent | 4b4caf187f590efc41a10646e0f35d6a70098103 (diff) | |
download | upower-9bc66af96f65ec7777ac565ab29e9d35dd69c3ea.tar.gz |
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
Diffstat (limited to 'src/linux')
-rw-r--r-- | src/linux/up-device-supply.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); |