mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2025-12-25 04:30:03 +01:00
linux: up-device-supply-battery: reset the status to discharging when current_now is negative
For some USB battery solutions, the kernel reports charging when connecting a charger but in reality, the battery discharges and current_now is negative. This work reset the battery status to "Discharging" when current_now is negative and line power is online. Resolves: #276 Signed-off-by: Kate Hsuan <hpa@redhat.com>
This commit is contained in:
parent
9d754d8b2f
commit
d7ff457784
1 changed files with 8 additions and 1 deletions
|
|
@ -292,7 +292,14 @@ up_device_supply_battery_refresh (UpDevice *device,
|
||||||
values.percentage = CLAMP(values.percentage, 0.0f, 100.0f);
|
values.percentage = CLAMP(values.percentage, 0.0f, 100.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
values.state = up_device_supply_get_state (native);
|
/* For some battery solutions, for example axp20x-battery, the kernel reports
|
||||||
|
* status = charging but the battery actually discharges when connecting a
|
||||||
|
* charger. Upower reports the battery is "discharging" when current_now is
|
||||||
|
* found and is a negative value.*/
|
||||||
|
if (g_udev_device_get_sysfs_attr_as_double_uncached (native, "current_now") < 0.0)
|
||||||
|
values.state = UP_DEVICE_STATE_DISCHARGING;
|
||||||
|
else
|
||||||
|
values.state = up_device_supply_get_state (native);
|
||||||
|
|
||||||
values.temperature = g_udev_device_get_sysfs_attr_as_double_uncached (native, "temp") / 10.0;
|
values.temperature = g_udev_device_get_sysfs_attr_as_double_uncached (native, "temp") / 10.0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue