Bug 495493 - applet lies about battery life
Summary: applet lies about battery life
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: DeviceKit-power
Version: 11
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Richard Hughes
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-13 12:54 UTC by David Woodhouse
Modified: 2013-01-10 07:59 UTC (History)
4 users (show)

Fixed In Version: 008-1.fc11
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-06-16 02:24:40 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description David Woodhouse 2009-04-13 12:54:26 UTC
I'm told that my battery has 12½ hours remaining (91%).

I find this unlikely.

udi = '/org/freedesktop/Hal/devices/computer_power_supply_battery_BAT0'
  battery.charge_level.current = 22680  (0x5898)  (int)
  battery.charge_level.design = 63000  (0xf618)  (int)
  battery.charge_level.last_full = 62460  (0xf3fc)  (int)
  battery.charge_level.percentage = 36  (0x24)  (int)
  battery.charge_level.rate = 33862  (0x8446)  (int)
  battery.is_rechargeable = true  (bool)
  battery.model = 'ASMB014'  (string)
  battery.present = true  (bool)
  battery.rechargeable.is_charging = false  (bool)
  battery.rechargeable.is_discharging = true  (bool)
  battery.remaining_time = 2411  (0x96b)  (int)
  battery.reporting.current = 22680  (0x5898)  (int)
  battery.reporting.design = 63000  (0xf618)  (int)
  battery.reporting.last_full = 62460  (0xf3fc)  (int)
  battery.reporting.rate = 33862  (0x8446)  (int)
  battery.reporting.technology = 'Unknown'  (string)
  battery.reporting.unit = 'mWh'  (string)
  battery.serial = ''  (string)
  battery.technology = 'unknown'  (string)
  battery.type = 'primary'  (string)
  battery.vendor = 'SMPN014'  (string)
  battery.voltage.current = 10487  (0x28f7)  (int)
  battery.voltage.design = 10800  (0x2a30)  (int)
  battery.voltage.unit = 'mV'  (string)
  info.capabilities = {'battery'} (string list)
  info.category = 'battery'  (string)
  info.parent = '/org/freedesktop/Hal/devices/computer'  (string)
  info.product = 'ASMB014'  (string)
  info.subsystem = 'power_supply'  (string)
  info.udi = '/org/freedesktop/Hal/devices/computer_power_supply_battery_BAT0'  
(string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'power_supply'  (string)
  linux.sysfs_path = '/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply
/BAT0'  (string)



$ grep ^ /sys/class/power_supply/BAT0/*
/sys/class/power_supply/BAT0/alarm:0
/sys/class/power_supply/BAT0/current_now:32951000
/sys/class/power_supply/BAT0/energy_full:62460000
/sys/class/power_supply/BAT0/energy_full_design:63000000
/sys/class/power_supply/BAT0/energy_now:21150000
/sys/class/power_supply/BAT0/manufacturer:SMPN014
/sys/class/power_supply/BAT0/model_name:ASMB014
/sys/class/power_supply/BAT0/present:1
/sys/class/power_supply/BAT0/serial_number:
/sys/class/power_supply/BAT0/status:Discharging
/sys/class/power_supply/BAT0/technology:Unknown
/sys/class/power_supply/BAT0/type:Battery
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_NAME=BAT0
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_TYPE=Battery
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_STATUS=Discharging
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_PRESENT=1
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_TECHNOLOGY=Unknown
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_VOLTAGE_NOW=10464000
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_CURRENT_NOW=32951000
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_ENERGY_FULL_DESIGN=63000000
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_ENERGY_FULL=62460000
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_ENERGY_NOW=21150000
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_MODEL_NAME=ASMB014
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_MANUFACTURER=SMPN014
/sys/class/power_supply/BAT0/uevent:POWER_SUPPLY_SERIAL_NUMBER=
/sys/class/power_supply/BAT0/voltage_min_design:10800000
/sys/class/power_supply/BAT0/voltage_now:10464000


If I bring up the statistics window by right-clicking on the applet and selecting 'power history', it claims the current energy is 57Wh, and voltage 12.2V. Is it not updating?

Comment 1 Richard Hughes 2009-04-14 08:14:09 UTC
Can you grab devkit-power --dump and the matching kernel data when this happens please. Thanks.

Comment 2 David Woodhouse 2009-04-19 09:28:01 UTC
Was using it on battery for a while. Then as soon as I plugged it into the AC again, it suddenly told me it had only 2.7% battery and was about to hibernate.

(Thankfully it didn't actually hibernate. Although it _did_ hibernate the other day when I first booted it up with a completely flat battery. I booted with AC connected, logged in to GNOME, and watched it go straight to sleep.)

It looks like it's missing updates -- note the 'updated: 622 seconds ago' in the devkit-power output.

Since ACPI doesn't give the kernel any events on battery level change, the kernel doesn't generate uevents either. Something's expected to poll... I'm not sure we ever finished the discussion about precisely how that should be handled?

udi = '/org/freedesktop/Hal/devices/computer_power_supply_battery_BAT0'
  battery.charge_level.current = 6300  (0x189c)  (int)
  battery.charge_level.design = 63000  (0xf618)  (int)
  battery.charge_level.last_full = 62110  (0xf29e)  (int)
  battery.charge_level.percentage = 10  (0xa)  (int)
  battery.charge_level.rate = 19298  (0x4b62)  (int)
  battery.is_rechargeable = true  (bool)
  battery.model = 'ASMB014'  (string)
  battery.present = true  (bool)
  battery.rechargeable.is_charging = true  (bool)
  battery.rechargeable.is_discharging = false  (bool)
  battery.remaining_time = 10411  (0x28ab)  (int)
  battery.reporting.current = 6300  (0x189c)  (int)
  battery.reporting.design = 63000  (0xf618)  (int)
  battery.reporting.last_full = 62110  (0xf29e)  (int)
  battery.reporting.rate = 19298  (0x4b62)  (int)
  battery.reporting.technology = 'Unknown'  (string)
  battery.reporting.unit = 'mWh'  (string)
  battery.serial = ''  (string)
  battery.technology = 'unknown'  (string)
  battery.type = 'primary'  (string)
  battery.vendor = 'SMPN014'  (string)
  battery.voltage.current = 10763  (0x2a0b)  (int)
  battery.voltage.design = 10800  (0x2a30)  (int)
  battery.voltage.unit = 'mV'  (string)
  info.capabilities = {'battery'} (string list)
  info.category = 'battery'  (string)
  info.parent = '/org/freedesktop/Hal/devices/computer'  (string)
  info.product = 'ASMB014'  (string)
  info.subsystem = 'power_supply'  (string)
  info.udi = '/org/freedesktop/Hal/devices/computer_power_supply_battery_BAT0'  (string)
  linux.hotplug_type = 2  (0x2)  (int)
  linux.subsystem = 'power_supply'  (string)
  linux.sysfs_path = '/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0'  (string)

Device: /org/freedesktop/DeviceKit/Power/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0
  vendor:               SMPN014
  model:                ASMB014
  serial:               
  power supply:         yes
  updated:              Sun Apr 19 10:08:55 2009 (622 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    energy:              1.7 Wh
    energy-empty:        0 Wh
    energy-full:         62.11 Wh
    energy-full-design:  0 Wh
    energy-rate:         2.398 W
    voltage:             10.119 V
    time to full:        0 seconds
    time to empty:       0 seconds
    percentage:          2.73708%
    capacity:            98.5873%
    technology:          unknown
  History (charge):
    1240132135	2.737	charging
  History (rate):
    1240132135	2.398	charging

Daemon:
  daemon-version:  008
  can-suspend:     yes
  can-hibernate    yes
  on-battery:      no
  on-low-battery:  no

Comment 3 David Woodhouse 2009-05-08 23:36:21 UTC
Ug. Laptop just powered itself off at 0% battery, because it hadn't noticed and warned me the battery was getting low. I was only about 10 yards from a power cable...

Any chance of this being fixed by F-11 release?

Comment 4 Richard Hughes 2009-05-09 08:09:24 UTC
(In reply to comment #2)
> Since ACPI doesn't give the kernel any events on battery level change, the
> kernel doesn't generate uevents either. Something's expected to poll...

Surely, if something in sysfs changes, we should get the uevents... I get updates for all the hardware I've got here...

Richard.

Comment 5 David Woodhouse 2009-05-09 09:36:39 UTC
But "something in sysfs" doesn't change. We only use ACPI to obtain the battery status when we're _asked_ to by userspace reading the sysfs file.

The kernel doesn't poll for changes in the values; where do you expect your uevents to come from?

Comment 6 David Woodhouse 2009-05-13 12:06:11 UTC
I see where you're doing the polling. And you're only doing it when the state is 'charging' or 'discharging'. But when I disconnect or reconnect my AC adapter, my battery is in 'Unknown' state for a little while before it reports itself as 'charging' or 'uncharging'. And when it's in 'unknown' state, you don't set the timer again (in dkp_supply_refresh()). So it never updates again.

 - No updates on supply /org/freedesktop/DeviceKit/Power/devices/battery_BAT0 for 30 seconds; forcing update
TI:13:00:47	TH:0x24e7390	FI:dkp-supply.c	FN:dkp_supply_refresh_battery,375
 - unknown status string: Unknown
TI:13:00:47	TH:0x24e7390	FI:dkp-supply.c	FN:dkp_supply_refresh,558
 - state 0; no set timer
TI:13:03:41	TH:0x24e7390	FI:dkp-device.c	FN:dkp_device_emit_changed,733
 - emitting changed on /sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0
^CTI:13:05:19	TH:0x24e7390	FI:dkp-main.c	FN:dkp_main_sigint_handler,107
 - Handling SIGINT
Segmentation fault

Comment 7 Richard Hughes 2009-05-13 16:49:05 UTC
Something like this?: http://cgit.freedesktop.org/DeviceKit/DeviceKit-power/commit/?id=648ca7103439e44e7f83035fa701994a408f8d01

I'm guessing it works for me because my battery doesn't use the unknown state...

Richard.

Comment 8 David Woodhouse 2009-05-13 18:11:04 UTC
Yeah, that's what I did here and it seems to be fine.

I wonder if it should be 'state != DKP_DEVICE_STATE_FULLY_CHARGED' though.

I suspect there may be cases where you see DKP_DEVICE_STATE_EMPTY while you've _just_ plugged the charger in.

Comment 9 Richard Hughes 2009-05-13 18:47:51 UTC
(In reply to comment #8)
> I wonder if it should be 'state != DKP_DEVICE_STATE_FULLY_CHARGED' though.

Sure, good plan. I've changed that in git master. I'll roll a new snapshot in rawhide now. Thanks for testing this.

Comment 10 Richard Hughes 2009-05-13 18:59:22 UTC
Could you give the F12 builds here a go please: http://koji.fedoraproject.org/koji/taskinfo?taskID=1353466 -- they should install fine on F11

Comment 11 David Woodhouse 2009-05-13 21:16:22 UTC
It's updating every two seconds now -- that may be a little excessive. Especially on crappy ACPI-infested machines where you may lose hundreds of milliseconds in SMM code each time, rather than having proper access to the battery.

And it's still saying 'No updates on supply %s for 30 seconds' each time :)

Comment 12 Matthew Garrett 2009-05-19 18:36:28 UTC
Can you test the build at http://koji.fedoraproject.org/koji/taskinfo?taskID=1364226 ? This only does the rapid polling while the battery state is unknown, and then slows down.

Comment 13 Fedora Update System 2009-06-01 11:33:26 UTC
DeviceKit-power-008-1.fc11 has been submitted as an update for Fedora 11.
http://admin.fedoraproject.org/updates/DeviceKit-power-008-1.fc11

Comment 14 Fedora Update System 2009-06-02 14:19:15 UTC
DeviceKit-power-008-1.fc11 has been pushed to the Fedora 11 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update DeviceKit-power'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F11/FEDORA-2009-5728

Comment 15 Bug Zapper 2009-06-09 13:44:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 11 development cycle.
Changing version to '11'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 16 Fedora Update System 2009-06-16 02:24:30 UTC
DeviceKit-power-008-1.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 How 2009-06-18 08:48:56 UTC
Still doesnt work. Plug in AC it says "is on battery" gpm icon does not update battery life info.

Comment 18 How 2009-06-18 09:07:54 UTC
devkit-power --monitor keep on saying
"device changed": /org/freedsktop/DeviceKit/Power/devices/battery_BAT0" when the system is idle


Note You need to log in before you can comment on or make changes to this bug.