Battery Historian Setup


Overview

Users don’t want an app that uses a lot of their energy life because their mobile devices have limited battery life. As a result, testers must keep an eye on the app’s battery use. A variety of native tools are available to test energy use, including Battery Historian, which displays battery consumption details for Android apps in a graphical format.

Battery Historian is a tool that allows you to look into battery-related statistics and events on an Android device running Android 5.0 or later while it’s on battery. It also enables for a side-by-side comparison of two Bug reports, emphasising crucial battery-related parameters that differ.

Install Battery Historian

1.In order to use battery historian , install Docker using below link : https://www.docker.com/community-edition

Note: You may need to enable virtualization in your BIOS if you’re using a Windows system. For further information on how to enable virtualization, consult the manual for your motherboard. Virtualization is already enabled if you are able to run the Android Emulator.

2.Use the following command to start the battery historian. The port number you specify will be used by Battery Historian.

docker –run -p port_number:9999 gcr.io/android-battery-historian:2.1 –port 9999

Navigate to battery historians in your browser using the link : http://localhost/port_number . Depending on your operating system, the address is as follows:

  • For Linux and Mac

Battery Historian is available at http://localhost:port_number.

  • For Windows

Docker will tell you the IP address of the computer it is utilising as soon as you start it.. So, for example, if the IP address is 123.456.50.90, Battery Historian is available at http://123.456.50.90:port_number

If you are able to access this page, you are ready to test the battery usage of your app.

After you’ve installed Docker, you’ll need to install Battery Historian to collect all of your device’s data.

The download link can be found here:  https://github.com/google/battery-historian

To set up Battery historian, clone or download the code from here and follow the instructions on the Github page, or see the instructions below:

  1. Connect your device to the computer.
  2. From a Terminal window, Shut down the running adb server.

adb kill-server

  1. Check for linked devices after restarting adb.

adb devices

  1. Reset battery data gathering.

adb shell dumpsys batterystats –reset

  1. Disconnect your device from the computer so that you are only drawing current from the device’s battery.
  2. Play with your app for some time.
  3. Reconnect your phone.
  4. Make sure your phone is recognisable.

adb devices

  1. Dump all battery data.

adb shell dumpsys batterystats > [path/]batterystats.txt

    Using the optional path argument, the batterystats.txt file is created in the directory you specify. The file will be created in the home directory by default.

  1. Create a report from raw data.

For devices running Android 7.0 and higher:

  1. adb bugreport > [path/]bugreport.zip

For devices running Android 6.0 and lower:

  1. adb bugreport > [path/]bugreport.tx
  2. Next is to run battery historian data using following commands:

docker –run -p port_number:9999 gcr.io/android-battery-historian:2.1 –port 9999

Historian runs at http://localhost/port_number. For Windows, Battery Historian runs athttp://your_IP_address/port_number.)

  1. Click Browse and then choose the bugreport file you created above.
  2. Click Submit. Battery Historian will display a graph based on your data.

Leave A Comment

Your email address will not be published. Required fields are marked *