Add isPowerSupply support to PowerDevil

Review Request #110384 - Created May 10, 2013 and submitted

Information
Kai Uwe Broulik
kdelibs
Reviewers
solid
This patch adds support for the "power supply" property in UPower batteries that tells if a battery is actually powering the machine (ie. laptop battery) or just inside a peripheral device (ie. mouse, keyboard, ..)

In the UDev backend it reads the power supply property, in HAL, which doesn't support this, we're assuming that primary battery and UPS battery are power supply and others are not (which is the current way PowerDevil for example determins whether a computer has a battery or not). Can be somewhat problematic as not all mice report themselves as mouse battery.

This patch will in the end allow for example Plasma's battery monitor to only average battery percentage of batteries that are actually powering the machine, or PowerDevil to emit a separate message when your mouse battery goes low.
After adjusting Plasma's powermanagement dataengine and battery monitor, I had it show two batteries (laptop battery and bluetooth mouse) and only take the laptop battery for battery percentage.

Issues

  • 0
  • 2
  • 2
  • 4
Description From Last Updated
Kai Uwe Broulik
Kai Uwe Broulik
Àlex Fiestas
Kai Uwe Broulik
Lukáš Tinkl
Dario Freddi
Commit Hook
Kai Uwe Broulik
Review request changed

Status: Closed (submitted)

Kurt Hindenburg
I think this commit is causing build failures on MacOSX - kdelibs/4.11 branch

[ 21%] Building CXX object solid/solid/CMakeFiles/solid.dir/backends/iokit/iokitdevice.o                                                                        
/Volumes/Projects/kde/src/kde/kdelibs/solid/solid/backends/iokit/iokitdevice.cpp:235:25: error: 
      allocating an object of abstract class type
      'Solid::Backends::IOKit::Battery'
            iface = new Battery(this);
                        ^
/Volumes/Projects/kde/src/kde/kdelibs/solid/solid/ifaces/battery.h:78:21: note: 
      unimplemented pure virtual method 'capacity' in 'Battery'
        virtual int capacity() const = 0;
                    ^
/Volumes/Projects/kde/src/kde/kdelibs/solid/solid/ifaces/battery.h:93:22: note: 
      unimplemented pure virtual method 'isPowerSupply' in 'Battery'
        virtual bool isPowerSupply() const = 0;
                     ^
/Volumes/Projects/kde/src/kde/kdelibs/solid/solid/ifaces/battery.h:122:22: note: 
      unimplemented pure virtual method 'capacityChanged' in 'Battery'
        virtual void capacityChanged(int value, const QString &udi) = 0;
                     ^
/Volumes/Projects/kde/src/kde/kdelibs/solid/solid/ifaces/battery.h:152:22: note: 
      unimplemented pure virtual method 'powerSupplyStateChanged' in 'Battery'
        virtual void powerSupplyStateChanged(bool newState, const...
                     ^
/Volumes/Projects/kde/src/kde/kdelibs/solid/solid/backends/iokit/iokitdevice.cpp:216:13: warning: 
      18 enumeration values not handled in switch: 'Unknown', 'Block',
      'StorageAccess'... [-Wswitch]
    switch (type)
            ^
1 warning and 1 error generated.
make[2]: *** [solid/solid/CMakeFiles/solid.dir/backends/iokit/iokitdevice.o] Error 1
  1. I wasn't aware there was another backend. Can you point me to some docs on IOKit? Will look into this, sorry for the inconvenience.
  2. Looking at the logs, the iokit stuff hasn't been touched in 3 years.  I have no idea how to resolve this at this time.
    https://projects.kde.org/projects/kde/kdelibs/repository/show/solid/solid/backends/iokit?rev=KDE%2F4.11
  3. I found this to be the most relevant API: http://developer.apple.com/library/mac/#documentation/IOKit/Reference/IOPowerSources_header_reference/Reference/reference.html#//apple_ref/doc/uid/TP40011509
Loading...