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
This commit is contained in:
Benjamin Berg 2022-06-14 17:02:45 +02:00
parent a78ee60390
commit ce24787165

View file

@ -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;