buglabs / android

This is the top-level git repo for the Android on BUG 2.0 project. Refer to the start page for further details:
http://buglabs.github.com/android/
5 stars 1 forks source link

BUG Battery, AC, and charging state information should be available in Android UI #5

Closed kgilmer closed 13 years ago

kgilmer commented 13 years ago

The android userspace battery/AC info comes from sysfs. Specifically it looks in /sys/class/power_supply. It is hardcoded to look for three children: AC, USB, and Battery. It reads nodes in these directories to determine state.

The kernel as is reports the battery by it's device name, bq27200 (plus an index). Changing the driver such that the name is Battery provides a few details to userspace, but not enough to make a user-level change.

A primary file that's needed is 'status'. In R2.0.2 this status is properly set to "full" when the device is plugged in, and the charging information seems accurate. However after merging this driver code into the froyo kernel, status always returns 'Discharging' and time_to_empty_now returns -1. This causes Android to immediately go into shutdown mode directly after loading the UI.

I attempted merging in various subsystems and drivers from the 2.6.31 BL kernel into the froyo one. There were bmi changes, i2c changes, pwm changes, TWL4030 changes. Regardless of my modifications I was unable to get /sys/class/power_supply/Battery/status to report "Full".

kgilmer commented 13 years ago

Links and files of interest regarding this issue: http://www.android-x86.org/documents/howtoconfigurebatteryservice

/base-bl/services/java/com/android/server/BatteryService.java /base-bl/services/jni/com_android_server_BatteryService.cpp

kgilmer commented 13 years ago

Matt Isaac's commit https://github.com/buglabs/android-froyo-kernel/commit/de23cf352a75c00b989d92cb32da3c0d005d4309 has updated the sysfs entries to the degree that battery/AC state information can be determined. The Android userspace now needs to be tweaked to read these sysfs entries properly to report battery/AC status in the UI.

kgilmer commented 13 years ago

Userspace now is able to read the battery/AC state information from sysfs. On boot this works however events are not being received by the BatteryService. I'm not exactly sure why this is but since other event types seem to be received I would suspect that the bq27x00 battery driver is not emitting uevents. From my research, it seems that the Android init program picks up uevents from the kernel over a socket. See https://github.com/buglabs/android-buglabs-system-core/blob/froyo/init/devices.c. The kernel configuration item CONFIG_UEVENT_HELPER_PATH is not used.

Steps to reproduce this issue:

  1. boot Android, note icon shows state of AC/battery and charging state.
  2. Attach/remove ac cable, note that AC/battery charging icon does not change.
  3. Reboot and see that icon has now been changed
kgilmer commented 13 years ago

Verified the toggle PM fix has fixed the status messages in the UI.

bcruskie commented 13 years ago

In build 89 I see the state reversed for this.

When AC power is attached battery icon is displayed When AC power is detached Battery icon shows charging (to further verify press and release power button to show charging status on lock screen)

bcruskie commented 13 years ago

I'm going to close this issue for DP1 and open the last comment as a new defect for DP2