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.
parent 888c9121
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment