• markuso's avatar
    Implement device::BatteryStatus support for UPower daemon 0.99.x · 472a020d
    markuso authored
    The org.freedesktop.UPower API was changed when upgrading the UPower daemon
    from version 0.9.23 to 0.99.x. The BatteryStatusManagerLinux used the
    "Changed" signal which was replaced by the "PropertyChanged" signal.
    
    Change the BatteryStatusManagerLinux to use the new UPower API
    (and keep compatibility with the 0.9.23 version, which is still used in
    Ubuntu 14.04 LTS).
    
    1. use dbus::PropertySet: the dbus::PropertySet provides simple access to
    the properties and connection to the property-changed notifications.
    
    2. Use UPower method GetDisplayDevice:
    The 'DisplayDevice' is a composite battery device. That was added in UPower
    version 0.99.0. If we don't get that device or if it is no battery, then we
    continue to enumerate all devices.
    
    3. Listen to 'DeviceAdded' and 'DeviceRemoved' signals:
    Re-enumerate battery devices if a device is added/removed.
    
    4. Compatibility with UPower version < 0.99
    Only old UPower versions need to connect to the 'Changed' signal.
    
    5. Rewrite the existing unittests to use a BatteryStatusManagerLinux instance
    with a dbus::MockBus and mock the dbus-methods/properties for the test.
    Add more unittests:
    - for changing device properties
    - for the DisplayDevice
    - for enumerating devices
    - for the DeviceAdded and DeviceRemoved signals
    
    Review-Url: https://codereview.chromium.org/2066503002
    Cr-Commit-Position: refs/heads/master@{#413745}
    472a020d
battery.gyp 5.95 KB