How does Android measure energy used by individual hardware component? How does Android measure energy used by each individual process?
Answer
Android tracks events that affect battery usage and stores this information in batterystats.bin file. Some examples:
- length of time screen was on with a specific brithness setting
- which application (or non Android app process) and how long held a wake lock (prevents device from sleeping)
- CPU usage per process (Android app or other process)
- phone signal strength
- GPS usage
- etc.
Android computes how much power each Application or component (e.g. screen) uses based on configuration information included on the device by the manufacturer.
Not everything is measured so the statistics can be sometimes misleading, but it gets better with every Android Platform release.
Battery statistics can be dumped from the device using:
adb shell dumpsys batterystats
Here is interesting fragment of a post by Diane Hackborn with more details about wake locks power consumption:
There are two ways power from wake locks is computed.
On some chipsets, simply holding a wake lock needs to prevent the CPU from going to a full deep sleep. In the reported battery usage, this extra power use will be distributed across all apps holding wake locks.
Even if the wake lock itself doesn't cause power use, holding a wake lock in one app can allow other applications to run and CPU when they wouldn't otherwise. (For example, some app may have a { sleep(1); do something; } loop that wouldn't run if no wake locks are held.) To address this, half of the CPU usage of applications is distributed to be blamed on the ones holding wake locks.
No comments:
Post a Comment