Ubuntu Touch // upowerd question re OnBattery property

Florian Leeber florian at ubports.com
Sun Mar 7 22:09:36 UTC 2021


Hi guys,

I am Florian from UBports, the community behind Ubuntu Touch, doing
alternative mobile OS for Android- and Non-Android hardware :)

We are using a customized version of Ubuntu, running off the rather
outdated 16.04 LTS (but switching now to 20.04 soon). Therefore, also
upower tools are installed, and working fine in general for most of our
devices. With a DBus connection data from upowerd is transferred into
repowerd and also the desktop indicator-power, which will display status
of charging, percentage etc.

Now it turns out that with more recent hardware (Lets say Android phones
after 8.0) the charging state is no longer detect correctly. Lets see
this code for the main detection routine in repowerd to determine power
state:

    auto const result = g_dbus_connection_call_sync(
        dbus_connection,
        dbus_upower_name,
        "/org/freedesktop/UPower",
        "org.freedesktop.DBus.Properties",
        "Get",
        g_variant_new("(ss)", "org.freedesktop.UPower", "OnBattery"),
        G_VARIANT_TYPE("(v)"),
        G_DBUS_CALL_FLAGS_NONE,
        timeout,
        null_cancellable,
        error);

this function will return always true, no matter what real status the
"battery_battery" device would show. Also the DisplayDevice seems to
transition correctly. Do you have any ideas how I can debug this?

It might get confused by the multitude of devices in the system:
root at ubuntu-phablet:/etc/init# upower -e
/org/freedesktop/UPower/devices/battery_battery
/org/freedesktop/UPower/devices/line_power_dc
/org/freedesktop/UPower/devices/battery_main
/org/freedesktop/UPower/devices/line_power_pc_port
/org/freedesktop/UPower/devices/line_power_usb
/org/freedesktop/UPower/devices/battery_bms
/org/freedesktop/UPower/devices/DisplayDevice

Thanks!
BR Florian



More information about the devkit-devel mailing list