Bug 300787 - libsolid-upower is not taking into account power-supply field
Summary: libsolid-upower is not taking into account power-supply field
Status: RESOLVED INTENTIONAL
Alias: None
Product: solid
Classification: Frameworks and Libraries
Component: libsolid-upower (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Lukáš Tinkl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-29 00:17 UTC by Daniel Nicoletti
Modified: 2013-05-13 15:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Nicoletti 2012-05-29 00:17:00 UTC
Starting from Kernel 3.4 a patch I wrote to probe
HID devices that have a capability to report battery
status is available, however the powermanagement
infrastructure does not take in account the power-supply field
exposed by upower that tells that my mouse/keyboard
does not power my computer, thus preventing it from hibernation
if I remove theirs batteries or if they are at low level.

Also when this is the case the the plasmoid should make use
the batteries name instead of battery 0, battery 1...

Here how upower -d command outputs this info:

daniel@Hommer:~/code/hid$ upower -d
Device: /org/freedesktop/UPower/devices/battery_hid_00o22o41oD9o18oE7_battery
  native-path:          /sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:1/0005:05AC:022C.0007/power_supply/hid-00:22:41:D9:18:E7-battery
  model:                MacAdmins keyboard
  power supply:         no
  updated:              Mon May 28 21:00:24 2012 (1 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              0 Wh
    energy-empty:        0 Wh
    energy-full:         0 Wh
    energy-full-design:  0 Wh
    energy-rate:         0 W
    percentage:          67%
    capacity:            100%
  History (charge):
    1338249623  67.000  discharging
    1338249622  0.000   unknown
  History (rate):
    1338249622  0.000   unknown

Device: /org/freedesktop/UPower/devices/battery_hid_70oCDo60oF5oFFo3F_battery
  native-path:          /sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3/1-1.3:1.0/bluetooth/hci0/hci0:2/0005:05AC:030E.0008/power_supply/hid-70:CD:60:F5:FF:3F-battery
  model:                nexxs Trackpad
  power supply:         no
  updated:              Mon May 28 21:00:24 2012 (1 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              0 Wh
    energy-empty:        0 Wh
    energy-full:         0 Wh
    energy-full-design:  0 Wh
    energy-rate:         0 W
    percentage:          15%
    capacity:            100%
  History (charge):
    1338249624  15.000  discharging

Daemon:
  daemon-version:  0.9.16
  can-suspend:     yes
  can-hibernate    no
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  no
  is-docked:       no

Reproducible: Always
Comment 1 Lukáš Tinkl 2012-05-29 14:51:31 UTC
daniel@Hommer:~$ solid-hardware details /org/freedesktop/UPower/devices/battery_hid_00o22o41oD9o18oE7_battery
udi = '/org/freedesktop/UPower/devices/battery_hid_00o22o41oD9o18oE7_battery'
  parent = '/org/freedesktop/UPower'  (string)
  vendor = ''  (string)
  product = 'MacAdmins keyboard'  (string)
  description = 'Unknown Battery'  (string)
  Battery.plugged = true  (bool)
  Battery.type = 'PrimaryBattery'  (0x3)  (enum)
  Battery.chargePercent = 62  (0x3e)  (int)
  Battery.rechargeable = true  (bool)
  Battery.chargeState = 'Discharging'  (0x2)  (enum)
Comment 2 Lukáš Tinkl 2012-05-29 15:04:37 UTC
Git commit d1661d1638851fd950c5926fb2040ea2abe2a8f0 by Lukas Tinkl.
Committed on 29/05/2012 at 17:03.
Pushed by lukas into branch 'KDE/4.8'.

don't consider external batteries (mice, keyboard, BT) as primary

dantti will test later today

M  +5    -2    solid/solid/backends/upower/upowerbattery.cpp

http://commits.kde.org/kdelibs/d1661d1638851fd950c5926fb2040ea2abe2a8f0
Comment 3 Lukáš Tinkl 2012-06-06 13:50:38 UTC
Git commit 7f8c750541790de5a380409466cf07cfe19c3651 by Lukas Tinkl.
Committed on 06/06/2012 at 15:47.
Pushed by lukas into branch 'KDE/4.8'.

Revert "don't consider external batteries (mice, keyboard, BT) as primary"

This reverts commit d1661d1638851fd950c5926fb2040ea2abe2a8f0.

This causes more trouble than expected, newer kernels/upower contain a bug that (in my case
and many others) marks ALL batteries as non-powersupply.
Related: bug 301033

M  +2    -5    solid/solid/backends/upower/upowerbattery.cpp

http://commits.kde.org/kdelibs/7f8c750541790de5a380409466cf07cfe19c3651
Comment 4 Dirk Mueller 2012-06-06 20:56:53 UTC
Git commit 240411008dce4557d9dd536cc517471394219a80 by Dirk Mueller, on behalf of Lukas Tinkl.
Committed on 06/06/2012 at 15:47.
Pushed by mueller into branch 'KDE/4.8.x'.

Revert "don't consider external batteries (mice, keyboard, BT) as primary"

This reverts commit d1661d1638851fd950c5926fb2040ea2abe2a8f0.

This causes more trouble than expected, newer kernels/upower contain a bug that (in my case
and many others) marks ALL batteries as non-powersupply.
Related: bug 301033

M  +2    -5    solid/solid/backends/upower/upowerbattery.cpp

http://commits.kde.org/kdelibs/240411008dce4557d9dd536cc517471394219a80
Comment 5 Lukáš Tinkl 2012-06-14 13:35:23 UTC
Thinking more about this bug... the patch you added to kernel/upower should never mark auxiliary batteries as Primary (see comment #1). Fixing that should also cure the recent bug with remaining time missing in the battery applet and prevent bugs such as #301033
Comment 6 Daniel Nicoletti 2012-06-14 13:57:32 UTC
That is the main problem, the assumption if they are primary or not should be exclusive to "power-supply" field, any other assumption is a hack, if upower reports a keyboard as power-supply it's a bug in upower, which isn't the current case since any /sys...power named hid-{MAC}-battery is marked as not power-supply.
Comment 7 Lukáš Tinkl 2012-06-18 05:23:52 UTC
No, the problem is that NO batteries at all are marked as power-supply ;)
Comment 8 Daniel Nicoletti 2012-06-18 06:59:42 UTC
Then please paste your's upower -d output, since
here it works well, also note that upower can tell if you are
on battery, which is buggy on my output but I have just fixed the
issue so instead of iterating over all baterries to know
if you are on battery power you can just ask upower
for that.
Comment 9 Lukáš Tinkl 2012-06-18 07:14:57 UTC
We are using the on-battery property, no prob with that...  

upower --dump:
[root@goblin ~]# upower --dump
Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/ACPI0003:00/power_supply/AC
  power supply:         no
  updated:              Mon Jun 18 09:14:34 2012 (0 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    online:             no

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          /sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0
  vendor:               Panasonic
  model:                42T4620
  serial:               509
  power supply:         no
  updated:              Mon Jun 18 09:14:34 2012 (0 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    energy:              66.48 Wh
    energy-empty:        0 Wh
    energy-full:         69.79 Wh
    energy-full-design:  84.24 Wh
    energy-rate:         0 W
    voltage:             12.383 V
    percentage:          95.2572%
    capacity:            82.8466%
    technology:          lithium-ion

Daemon:
  daemon-version:  0.9.16
  can-suspend:     yes
  can-hibernate    yes
  on-battery:      yes
  on-low-battery:  no
  lid-is-closed:   no
  lid-is-present:  yes
  is-docked:       no
Comment 10 Kai Uwe Broulik 2013-05-13 15:38:20 UTC
Git commit b86adffd69a972f612e0fb00f8c4e8154142c730 by Kai Uwe Broulik.
Committed on 13/05/2013 at 17:34.
Pushed by broulik into branch 'master'.

Add support for the Power Supply property of UPower which indicates if a battery
is actually powering the machine (ie. laptop battery) or just reported by one
of your peripherals (eg. mouse, keyboard).
This will eventually allow other parties such as the battery notifier to disregard
them when calculating overall battery percentage or PowerDevil to notify about

REVIEW: 110384

M  +5    -0    solid/solid/backends/fakehw/fakebattery.cpp
M  +1    -0    solid/solid/backends/fakehw/fakebattery.h
M  +14   -1    solid/solid/backends/fakehw/fakecomputer.xml
M  +11   -0    solid/solid/backends/hal/halbattery.cpp
M  +2    -0    solid/solid/backends/hal/halbattery.h
M  +12   -0    solid/solid/backends/upower/upowerbattery.cpp
M  +3    -0    solid/solid/backends/upower/upowerbattery.h
M  +1    -1    solid/solid/backends/upower/upowerdevice.cpp
M  +6    -0    solid/solid/battery.cpp
M  +8    -0    solid/solid/battery.h
M  +7    -0    solid/solid/ifaces/battery.h

http://commits.kde.org/kdelibs/b86adffd69a972f612e0fb00f8c4e8154142c730