Make battery indicator work on Android

Bug #1270451 reported by Felix Krull on 2014-01-18
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Dustin Kirkland 

Bug Description

Long story short, I'm running byobu in a Debian chroot on an Android system and noticed that the battery status notification doesn't work with the battery information this Android kernel spits out. In particular, /sys/class/power_supply/battery/uevent has fewer variables and POWER_SUPPLY_STATUS sometimes contains a space ("not charging") so sourcing breaks. For the record, this is on an HTC Wildfire with CyanogenMod 7.2 (Android 2.3.7, Linux 2.6.35-14).

So I fixed it, see attached patch (against trunk). Notable changes include:

* "uevent" is now read more smartly so that spaces don't break everything
* I've preferred POWER_SUPPLY_CAPACITY get the current charge in percent since both Android and an ACPI x86 notebook I've checked had that
* strings from "uevent" are now lowercased to accommodate for differences in that regard
* I added a configuration variable (BATTERY_SHOW_WHEN_FULL) to display the battery indicator even when the battery is full since I found the original behaviour slightly surprising (the default is still as before though)

I admit that I didn't test the patch on other devices, but it should support a superset of devices and implementations.

Felix Krull (fkrull) wrote :
Changed in byobu:
status: New → In Progress
importance: Undecided → Wishlist
assignee: nobody → Dustin Kirkland  (kirkland)
Dustin Kirkland  (kirkland) wrote :

Hi Felix,

Thanks for the patch!

I did some basic testing here, and it seems that something in your code has changed the logic, and regressed the battery status support on at least my Thinkpad.

I'll take a closer look and see if I can see what exactly has failed.

Dustin Kirkland  (kirkland) wrote :

Okay, I've reworked your patch a bit. It's working for me now, on my Thinkpad. Hopefully I preserved enough of it to support your Android device. Please do test it out and let me know.


Dustin Kirkland  (kirkland) wrote :

bzr commit -m '* usr/lib/byobu/battery: LP: #1270451
  - add support for yet another batter type (Android)
  - thanks to Felix Krull for the initial patch' --fixes 'lp:1270451'
Committing to: /home/local/media/source/byobu/byobu/
modified debian/changelog
modified usr/lib/byobu/battery
Committed revision 2295.

Changed in byobu:
status: In Progress → Fix Committed
Changed in byobu:
status: Fix Committed → Fix Released
Felix Krull (fkrull) wrote :

Sorry about the lack of feedback. I don't have the original device on hand anymore, but I've now checked on a different, newer Android device (running Debian jessie on top of a Linux 3.4.10) and the first issue unfortunately remains, i.e. uevent still has variables with spaces ("not charging" in particular). I've made a cut-down patch with just the different uevent parsing and detection for the "not charging" string. This modified version (against 5.77 originally, but it seems the file hasn't changed since then) works both the Android device and my Thinkpad (with Ubuntu 14.04), so I hope it's working universally now.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers