summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-06-14 17:02:45 +0200
committerBenjamin Berg <bberg@redhat.com>2022-06-14 17:02:45 +0200
commitce2478716517df002175d0c4f57c057a0977ccb3 (patch)
treebedbfdf8e6be680bc2217a34c142e0166b447c76
parenta78ee6039054770b466749f8ec4bfbe4c278d697 (diff)
downloadupower-ce2478716517df002175d0c4f57c057a0977ccb3.tar.gz
supply: Use percentage to guess empty STATE
Using energy is broken as the value might be zero if it is not provided. However, either energy or percentage ("capacity") should have been read from the sysfs. And, in both cases the percentage should reflect something reasonable. Related: #146
-rw-r--r--src/linux/up-device-supply.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index f20ce07..ffa4ad6 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -676,7 +676,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
state = UP_DEVICE_STATE_FULLY_CHARGED;
/* if empty, and BIOS does not know what to do */
- if (state == UP_DEVICE_STATE_UNKNOWN && energy < 0.01) {
+ if (state == UP_DEVICE_STATE_UNKNOWN && percentage < 1) {
g_warning ("Setting %s state empty as unknown and very low",
g_udev_device_get_sysfs_path (native));
state = UP_DEVICE_STATE_EMPTY;