4

Is there anyway to get the battery usage info per application per second in API, adb shell, ...?

jimmym715
  • 1,512
  • 1
  • 16
  • 25
Mohammad Moghimi
  • 4,636
  • 14
  • 50
  • 76

2 Answers2

5

Other than the battery usage screen in Settings, there is no API or command-line way to get this information.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I want to get the info that the battery usage screen gets. Is it possible to get it using sdk or ndk? Because that is not part of the public API. – Mohammad Moghimi Mar 01 '11 at 01:31
  • @phoenix7: You can get it via custom firmware -- that is it. – CommonsWare Mar 01 '11 at 01:35
  • For anyone coming here from the future, this post may be helpful: https://stackoverflow.com/a/27821415/275524 – AndrewJC Jul 13 '17 at 18:55
  • This answer is not correct, there is a possibility to access that data, GSam Battery Monitor does that and without any root access either. –  Sep 10 '21 at 09:49
2

just try to read http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/1.6_r2/com/android/settings/fuelgauge/PowerUsageSummary.java/ , then you can get the info shown in the battery usage screen. the key class are IBatteryStats and BatteryStatsImpl.

iss
  • 21
  • 1