1

I'm trying to estimate system level power usage from within an ordinary app on a non-rooted Android phone.

There are a variety of apps on the Play store that accomplish this, e.g. GSam Battery Monitor and AccuBattery. So the problem has been solved in principle. As far as I can tell, these applications use the OEM-provided power_profile.xml file (see documentation).

The principle of how the power profile works is clear to me, you can calculate current currant draw by multiplying current system usage of CPU, camera etc. by the respective entry in the profile.

But I don't know how to get this system level usage data from within my app. Where do I get information on whether radio.active, bluetooth.active etc? What code do I need to get these values from within an app? I guess the answer is simple, since no one bothers to document it together with the power profile.

Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55
  • For CPU frequency, there are solutions on SO already: https://stackoverflow.com/questions/3021054/how-to-read-cpu-frequency-on-android-device Not sure this is the right way to do brigthness: https://stackoverflow.com/questions/33063718/getting-the-current-screen-brightness?noredirect=1&lq=1 – Cornelius Roemer Dec 13 '19 at 18:55
  • 1
    I've been doing entry-level research on the subject of energy management on Android for a little while. I've used the files in your first link to get the data from current draw for the battery. But AFAIK the other components (e.g. bluetooth, radio, wi-fi, etc) don't have a specific sensor on the device. So the only way to model it's energy consumption is either using a model based on perfomance counters (registers) or by using external sensors. – Eduardo macedo Dec 13 '19 at 21:11
  • Actually I've used the files in `sys/class/power_supply/battery/current_now` and `sys/class/power_supply/battery/current_avg`. You can see it on my [repo](https://gitlab.com/edujtm/kwatts/blob/master/src/main/kotlin/edu/ufrn/lapps/system/BatterySys.kt). (Just ignore my horrible code) – Eduardo macedo Dec 13 '19 at 21:20
  • This [thesis](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.571.6052&rep=rep1&type=pdf) talks about energy profiles using an external sensor, but it's kinda long and not well written. I believe AccuBattery only uses the files on sysfs to generate all those graphs. If I find more definitive info, I'll answer your question. – Eduardo macedo Dec 13 '19 at 21:34

0 Answers0