summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Paulo Rechi Vita <jprvita@endlessm.com>2018-11-26 13:12:18 -0800
committerJoão Paulo Rechi Vita <jprvita@endlessm.com>2018-12-18 17:17:32 -0800
commita953401420e816d3660c90e1cfbac73866756499 (patch)
tree478d4a00ba4959d30d584fde306ac8bb8c2ba2b1
parent888c9121f090a1128562edb9c06dcd6b564578c7 (diff)
downloadupower-a953401420e816d3660c90e1cfbac73866756499.tar.gz
linux: Map pending-charge to fully-charged when charge is 100%
Some devices report "Not charging" when the battery is full and AC power is connected. In this situation we should report fully-charged instead of pending-charge. Closes: #86.
-rw-r--r--src/linux/up-device-supply.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index 1644665..4936247 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -732,6 +732,12 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
percentage = CLAMP(percentage, 0.0f, 100.0f);
}
+ /* Some devices report "Not charging" when the battery is full and AC
+ * power is connected. In this situation we should report fully-charged
+ * instead of pending-charge. */
+ if (state == UP_DEVICE_STATE_PENDING_CHARGE && percentage == 100.0)
+ state = UP_DEVICE_STATE_FULLY_CHARGED;
+
/* the battery isn't charging or discharging, it's just
* sitting there half full doing nothing: try to guess a state */
if (state == UP_DEVICE_STATE_UNKNOWN && supply->priv->is_power_supply) {