Reputation: 565
I have developed an Android application and I would like to know the power consumption of my app on an Android device. I came across various threads on Stack Overflow but none of them helped me.
Is there any application in Android which measures the power consumption of my app or any other viable method?
From the answers of this Stack Overflow post:
I used "Battery Historian" and generated batteryinfo.txt and batteryinfo.html
The Batteryinfo.txt is as follows
Battery History:
-3m04s883ms 090 6c120104 status=discharging health=overheat plug=none temp=0 volt=3797 +screen +phone_scanning +wifi +wifi_running +wake_lock +sensor brightness=bright phone_state=out
-3m02s651ms 090 6c1a0104 status=charging plug=usb volt=4123 +plugged
-3m00s087ms 090 6c1a0104 volt=4090
-2m57s951ms 090 6c1a0104 volt=4125
-2m43s775ms 090 6c1a0104 volt=4123
-2m41s563ms 087 6c1a0104
-2m31s787ms 087 6c1a0104 volt=4114
-2m28s300ms 087 6c1a0104 volt=4112
-2m26s037ms 087 6c1a0104 volt=4114
-2m22s891ms 087 6c1a0104 volt=4112
-2m20s797ms 087 6c1a0104 volt=4134
-2m08s632ms 087 6c1a0104 volt=3849
-2m06s567ms 083 6c1a0104 volt=3838
-2m04s370ms 083 6c1a0104 volt=4123
-1m43s700ms 087 6c1a0104 volt=4122
-1m32s936ms 087 6c1a0104 volt=4007
-1m22s724ms 083 6c1a0104 health=good
-1m02s524ms 080 6c1a0104 volt=3957
Per-PID Stats:
PID 166 wake time: +203ms
PID 109 wake time: +2m57s295ms
Statistics since last charge:
System starts: 0, currently on battery: false
Time on battery: 2s 232ms (0.0%) realtime, 2s 232ms (0.0%) uptime
Total run time: 3d 15h 52m 45s 402ms realtime, 1d 9h 16m 33s 630ms uptime,
Screen on: 2s 231ms (100.0%), Input events: 0, Active phone call: 0ms (0.0%)
Screen brightnesses: bright 2s 231ms (100.0%)
Kernel Wake lock "PowerManagerService": 2s 191ms (0 times) realtime
Kernel Wake lock "power-supply": 412ms (1 times) realtime
Kernel Wake lock "main": 2s 191ms (0 times) realtime
Total received: 0B, Total sent: 0B
Total full wakelock time: 2s 197ms , Total partial waklock time: 2s 203ms
Signal levels: none 2s 231ms (100.0%) 0x
Signal scanning time: 2s 231ms
Radio types: none 2s 231ms (100.0%) 0x
Radio data uptime when unplugged: 0 ms
Wifi on: 2s 231ms (100.0%), Wifi running: 2s 231ms (100.0%), Bluetooth on: 0ms (0.0%)
Device battery use since last full charge
Amount discharged (lower bound): 0
Amount discharged (upper bound): 0
Amount discharged while screen on: 0
Amount discharged while screen off: 0
#1000:
User activity: 2 other
Sensor 2: 2s 206ms realtime (0 times)
#1013:
Wake lock AudioIn_369: 2s 203ms partial (1 times) realtime
#10010:
Apk com.android.providers.media:
Service com.android.providers.media.MtpService:
Created for: 0ms uptime
Starts: 1, launches: 1
#10029:
Wake lock Samsung Recognition Service: 2s 197ms full (0 times) realtime
Statistics since last unplugged:
Time on battery: 2s 232ms (1.2%) realtime, 2s 232ms (1.2%) uptime
Total run time: 3m 4s 912ms realtime, 3m 4s 911ms uptime,
Screen on: 2s 232ms (100.0%), Input events: 0, Active phone call: 0ms (0.0%)
Screen brightnesses: bright 2s 232ms (100.0%)
Kernel Wake lock "PowerManagerService": 2s 191ms (0 times) realtime
Kernel Wake lock "power-supply": 412ms (1 times) realtime
Kernel Wake lock "main": 2s 191ms (0 times) realtime
Total received: 0B, Total sent: 0B
Total full wakelock time: 2s 232ms , Total partial waklock time: 2s 232ms
Signal levels: none 2s 232ms (100.0%) 0x
Signal scanning time: 2s 232ms
Radio types: none 2s 232ms (100.0%) 0x
Radio data uptime when unplugged: 0 ms
Wifi on: 2s 232ms (100.0%), Wifi running: 2s 232ms (100.0%), Bluetooth on: 0ms (0.0%)
Device is currently plugged into power
Last discharge cycle start level: 90
Last discharge cycle end level: 90
Amount discharged while screen on: 0
Amount discharged while screen off: 0
#1000:
User activity: 2 other
Sensor 2: 2s 232ms realtime (0 times)
#1013:
Wake lock AudioIn_369: 2s 232ms partial (1 times) realtime
#10010:
Apk com.android.providers.media:
Service com.android.providers.media.MtpService:
Created for: 0ms uptime
Starts: 1, launches: 1
#10029:
Wake lock Samsung Recognition Service: 2s 232ms full (0 times) realtime
When I open Batteryinfo.html it displaying "Cannot Find End Time".
I followed the answers in the below post and commented out the code as mentioned
Battery historian cannot find end time android
This time when I run the command to generate batteryinfo.html from batteryinfo.html it displaying an error (which is referrinf to the commented out code of 3 lines).
NOTE: As my device is not supporting to use batterystats and so am using batteryinfo.
I want to open the batteryinfo.html
with the details.
Upvotes: 5
Views: 6050
Reputation: 101
I don't know what you mean by can't read estimated value in the setting.
Look at my answer in Android App power consumption
" First, the powertutor from Google Play is out of date. I've checked the source code of it, and find that the power estimation model is for some old mobile model. The value from power tutor is way smaller than the actual power consumption.
Therefore, I would recommend to use Battery Historian which is development by google used to estimate battery consumption of each App. But it's written in Python/Go. It will show the hardware invocation in a html file. And you can find battery consumption of each App in a corresponding text file.
https://developer.android.com/studio/profile/battery-historian.html "
It will create a batterystats.txt, showing exactly the same as it in the setting.
Upvotes: 2