upower checks battery too soon after resume and assumes empty
Submitted by Samuel Sieb
Assigned to Richard Hughes @hughsient
Description
Originally filed at https://bugzilla.redhat.com/show_bug.cgi?id=1027059
Upower polls the battery too soon after resuming from suspend. The /sys tree for the battery isn't there yet. This causes the reads to fail, but the reading code doesn't detect errors so just returns 0. This means that upower thinks the battery is empty and triggers an immediate hibernate.
There are log entries like this: Nov 5 09:35:12 worklap upowerd[1131]: (upowerd:1131): GLib-CRITICAL **: g_ascii_strcasecmp: assertion `s1 != NULL' failed Nov 5 09:35:12 worklap upowerd[1131]: (upowerd:1131): UPower-Linux-WARNING **: unknown status string:
The output from "upower -d" looks like this: Device: /org/freedesktop/UPower/devices/battery_BAT0 native-path: /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0 power supply: yes updated: Fri Nov 8 12:25:09 2013 (0 seconds ago) has history: yes has statistics: yes battery present: yes rechargeable: yes state: empty energy: 0 Wh energy-empty: 0 Wh energy-full: 0 Wh energy-full-design: 0 Wh energy-rate: 0 W percentage: 0% capacity: 100% History (rate): 1383942309 15.250 discharging 1383942309 0.000 unknown 1383942309 0.000 empty 1383942220 15.962 discharging 1383942198 17.302 discharging