Android battery service was developed with only one type of battery and power management in mind. When running Android on the different hardware platforms, the battery status often shows up incorrectly. To resolve this issue, we have developed an easier method of supporting different platforms and battery types. This document explains how to configure the android-x86 platform to support different type of batteries.
In Linux, applications collect the battery status through sysfs, where the battery status is located in /sys/class/power_supply/. Different platforms, however, may give you a different directory layout under /sys/class/power_supply/, but Android hardcodes the directory layout to /sys/class/power_supply/. To resolve this issue, I have added new entries in vendor/asus/eeepc/system.prop, where the user can change the value of these entries to correctly configure the sysfs directory layout for different platforms.
These entries are:
There is another issue with vold. vold catches the uevent for power supplier type changing events. Unfortunately, on different platforms, the name of the uevent may be different, but Android vold hardcodes the uevent name. To resolve this issue, I have added an additional two entries in the system.prop to allow vold to use the uevent names based on the user configuration. These two new entries are:
The X86 platform often connects the battery through ACPI, therefore the exposure of the battery status follows the ACPI standard. Very important is how the battery energy level is calculated. Below is what I've copied from ACPI spec:
To implement your own battery status handling code, simply re-implement the IBatteryServiceStatus class in frameworks/base/libs/utils/IBatteryServiceStatus.cpp, replacing frameworks/base/libs/utils/BatteryServiceStatus.cpp with your own implementation.