wadestrikers
wadestrikers

Reputation: 147

Android How to measure app power consumption when plugged

How to measure app power consumption when I connect my device with my pc?

I've read about batterystats from Android Studio. And I've followed the instructions and get a batterystats dumpsys. However, I can't not let my device consistently plugged on usb port because the result of dumpsys will have a missing part called "Estimated power use". Which is the most important part of the whole test because the app power consumption it contained.

I've tried using StopCharge app to interrupt phone charging. But the prerequisite is that the device need to get ROOT.

Other options like power tutor is outdated. Information out from the application can't quite fit my request(Android 6.0 or upper).

Is it possible to get the power consumption measurement of an application when it's charging or is my mind out of the roof?

Thank you in advance!

p.s the following is a sample of the method of Android Studio batterystats

Estimated power use (mAh)
Capacity: 2930, Computed drain: 43.9, actual drain: 58.6-87.9
Screen: 35.6
Unaccounted: 14.7 ( )
Uid u0a2618: 2.91 ( cpu=2.17 wake=0.657 wifi=0.00656 sensor=0.0732 )

Upvotes: 1

Views: 2486

Answers (1)

Lucas Queiroz Ribeiro
Lucas Queiroz Ribeiro

Reputation: 735

I think when you plug, the battery stats are not very accurate. There's two ways i usually do:

  1. Connect the adb by wi-fi and run batterystats

    • In Android Studio go to preferences->Plugins and search for Wi-fi, this way you connect the device on USB, go to plugin and he do the wifi connection

Or if you don't wanna a new plugin

  • Run adb tcpip 5555 and adb connect 192.168.0.101:5555 if you already have usb access (More info.)

-

  1. Use the Google Battery Historian:

    • In this link, download the project following the guidelines
    • In your adb, run adb shell dumpsys batterystats --reset to clear all the history
    • Use your App for some time
    • Go back on ADB an generate the log: adb bugreport > bugreport.txt
    • Then Upload the file to the Battery Historian site that you will host by following the instructions, and you are done.

Image of the Battery Historian:Screenshot of the Battery Historian

Upvotes: 3

Related Questions