How Much Power Does My Android Device Consume?
Android devices have a very powerful menu setting called “Battery” that tells you which apps are causing battery drain. AT&T’s ARO can help developers get better ratings on this menu. Have you ever wondered how your phone knows how much power apps are using? Let’s dig in, and find out more.
There is an app that is part of the OS framework called (appropriately enough) Framework-res.apk that holds the details of device power drain. To learn the settings, we need to get this file off of the device, and then read the contents of the file. To get this information from your device, you need the Android SDK to copy files from your device, APKtool (a free app that helps you decompile Android apps), and a little patience.
Inside the SDK, open the Android device monitor and browse to view File Explorer, and then System/Frameworks . There you will find an app called frameworks-res.apk. Copy this to your PC.
Now you have the apk. As you may know, apk files are zips, so by renaming to zip, you can go in and find res/xml/power_profile.xml but, since the app is not decompiled, it is mostly gibberish. In order to read it, you must decompile the application and so, on to decompiling. Download the APKtool and open a command line window and browse to the folder with APKtool.
In the command line, Type:
Apktool if framework-res.apk
(lots of stuff happens)
Now to decompile:
apktool d framework-res.apk
Now there is a framework-res folder in the same directory as the APKtool. If you browse to the power_profile.xml file, you’ll find the power values for your device. It will look something like this (all power numbers are in mA):
AT&T’s ARO tool uses measured values for these hardware components, so I thought it would be interesting to see if the values added by the device manufacturer matched those used by ARO. In general, the numbers were close. There are some OEMs who took more care in providing power drain numbers than others (note that every value in this file is exactly the same).
I thought it might be neat to check the power profile over several generations of phones. Here are the Samsung S2-S5 devices:
We can see a general increase of battery capacity generation over generation. Radio.active (the cellular radio being on) as generally decreased, and screen power has decreased or remained constant – which is pretty amazing, considering that the screens have grown immensely over the same devices.
How do these numbers compare with those measured in ARO? Actually, pretty well. Some are a bit higher, some lower, but if you are looking to create a unique power profile for your device in ARO, this is a good way to start and a lot faster than creating a profile manually!.