Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

How does Android measure energy used by individual hardware component? How does Android measure energy used by each individual process?

share|improve this question
    
I guess how many instructions are performed in 1 sec. –  AZ_ Mar 1 '12 at 9:25
5  
@Algo: It will be totally misleading to assume a background application that uses a lot of CPU is more battery hungry than another application that uses little CPU but a lot of Wifi and GPS and display. –  Lie Ryan Mar 1 '12 at 10:11
    
If so then you can get hint from the number of permissions that an application acquired.. just an idea. –  AZ_ Mar 2 '12 at 7:49
    
@LieRyan in the battery stats, isn't wifi, gps, bluetooth, etc, calculated as their own "consumer" of the battery? –  Ryan Conrad Mar 2 '12 at 15:53

1 Answer 1

up vote 6 down vote accepted

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 batteryinfo

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.

  1. 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.

  2. 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.

share|improve this answer
    
can you provide sources/reference that proof your answer ? –  diimdeep Mar 10 '12 at 5:19
    
All information is from the provided link to google+ thread by Google developer familiar with this area. –  Paweł Nadolski Mar 10 '12 at 13:26
    
The correct command for new devices (not sure from which API) should be : adb shell dumpsys batterystats , or (in case you want it inside a file) : adb shell dumpsys batterystats > batterystats.txt –  android developer Aug 29 at 14:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.