• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Q] Has anyone played with the Android L battery-historian tool?

Search This thread

thomase00

Senior Member
Sep 25, 2012
57
16
FYI, I don't have a Nexus 5, but I've been following the Android L news for the past few weeks and have yet to see any reports on the battery historian developer tool. I'm really curious to see detailed battery usage reports for apps that are known to cause frequent wakeups from deep sleep (e.g. facebook). From what I can tell, you need 3 things to use this tool:

1.) adb

2.) The actual Python script: https://raw.githubusercontent.com/google/battery-historian/master/historian.py (just right-click and "Save as" to the directory from which you run 'adb')

3.) Also need to install Python 2.7 on your system (for Window users): https://www.python.org/download/

4.) Obviously, a browser to view the generated html.

There are some comments at the beginning of historian.py script that describe how to generate the required data with adb. Note for Windows users: open up the file in Wordpad, not Notepad.

Also for Windows users: assuming you have installed Python 2.7 in c:\Python27, use the following command line to run the script:

c:\Python27\python.exe historian.py [OPTIONS] [FILE]

Also note that this tool is NOT part of the built-in Android battery settings/stats and there is no native Android UI for it. It is meant to be a developer tool. However, this doesn't mean that users with access to 'adb' can't play with it...
 

pikachukaki

Senior Member
Jan 27, 2012
5,046
2,749
Thessaloníki, Greece
I manage to get this work...even i have no idea about development...

First it need python 2.7 not 3.4
After that you have to mix some commands from the OT and the info inside the .py file...so what i do

After installing python 2.7 i use the command to get a bugreport from the phone...

Code:
adb bugreport > bugreport.txt

then i use the OT command to make the bugreport to an html file with a bit of change

Code:
c:\Python27\python.exe historian.py -a bugreport.txt > battery.html

Thats it...now..i don't know if it has the correct data...im just achived the html look of what we saw on I/O

I think first you need to use this command

Code:
adb shell dumpsys batterystats --enable full-wake-history

To let the phone start dumping stats...and then after some use time to gather the bugreport from your phone....anyone with better knowlage im sure it will figure it out!!!

On the attachment i use the command

Code:
adb shell dumpsys batterystats --reset

to reset my values cause im not using my L rom...

Oh btw this will work only on L....
 

Attachments

  • Untitled.png
    Untitled.png
    52 KB · Views: 2,036
Last edited:

k-matoo777

New member
Jul 24, 2014
1
0
I can't use "--enable" option.

I can't use this command.

Code:
adb shell dumpsys batterystats --enable full-wake-history

Please tell me how to use "--enable" option.

My phone is Android4.4.2.
("--enable" option is Android "L" only ??)
 

Daimonion1980

Senior Member
Feb 13, 2009
160
14
Yep, i think this is the most recent problems the two guys from project Volta have. They have to be rely on the help of the programmers which develop the software.
 

makapav

Senior Member
Nov 14, 2013
52
11
Yep, i think this is the most recent problems the two guys from project Volta have. They have to be rely on the help of the programmers which develop the software.

They have to rely on Developer to use JobScheduler API but not for finding you bad apps that are killing the battery. And to that effect, those guys are doing a terrible job with a botched tool.

It's amazing how there is NOTHING on the Internet about the Battery Historian tool. It's like no one has used it. In my case, I can't get the command to builds the html file from the bugreport. It keeps giving me a invalid html error.
 
  • Like
Reactions: Daimonion1980

cjwilliams

New member
Apr 23, 2015
1
0
Using battery historian

After playing with this for a while I've figured out how to use the basic function (this is part of project volta, so it will only work on Android 5.0+)

enable full wake history and then output your batterystats to a text file
./adb shell dumpsys batterystats --enable full-wake-history
./adb shell dumpsys batterystats > batterystats.txt

navigate to wherever you placed historian.py and output the data to a html file (you need python 2.7)
./historian.py [location of batterystats.txt] > batterystats.html

open the batterystats.html file and you're done! For basic use at least. I'm still figuring out the rest myself.
 
Last edited:

Daimonion1980

Senior Member
Feb 13, 2009
160
14
So after having problems on lollipop with mobile radio active bug (https://code.google.com/p/android/i...id&colspec=ID+Type+Status+Owner+Summary+Stars)
i managed to get an dump from battery historian. But at the moment a see not the culprit in my log. The only thing i see is that my device although it was not heavily used this morning has a tons of wakelocks.... and an running par between 10:45 and 10:55 where i don't know it's coming from......

Have a look at it:
http://picture-diamonds.de/private/Thomas/Dumpsys.html

Is anyone able to interpret this chart?
 
Last edited:

thomase00

Senior Member
Sep 25, 2012
57
16
I finally got 5.1 on my Verizon Moto X (1st gen). One of the first things I did was collect battery stats and run Battery Historian 2.0. The following guide was very helpful in getting this set up on Windows 7:

http://ph0b.com/battery-historian-2-0-windows/

Anyway, it turns out that while sitting untouched on my desk at work, the phone pretty consistently wakes up about once per minute (only for a second or 2), with the partial wakelock held by GOOGLE_SERVICES. Most of the time, it seems to be related to location reporting. This doesn't sound like a lot, but I think there is a relatively big cost associated with powering the up and down.

Other than location, the ONLY reason I can think of for waking up the phone periodically is for TCP keep-alive (to keep GCM push notifications working), but once per minute seems kind of excessive even for that. My theory is that there is an app using the Google Play Services Geofencing API, and I just happen to be parked near a geofence boundary. According to my understanding, the Google geofencing service adjusts location polling frequency according to your distance from a geofence. If I am correct, the problem is that it is not smart enough to understand that you are stationary and therefore avoid excessive polling.

I'll try to collect more stats from different locations.

I'm sure this ground has been tread before...
 

makapav

Senior Member
Nov 14, 2013
52
11
I finally got 5.1 on my Verizon Moto X (1st gen). One of the first things I did was collect battery stats and run Battery Historian 2.0. The following guide was very helpful in getting this set up on Windows 7:

http://ph0b.com/battery-historian-2-0-windows/

Anyway, it turns out that while sitting untouched on my desk at work, the phone pretty consistently wakes up about once per minute (only for a second or 2), with the partial wakelock held by GOOGLE_SERVICES. Most of the time, it seems to be related to location reporting. This doesn't sound like a lot, but I think there is a relatively big cost associated with powering the up and down.

Other than location, the ONLY reason I can think of for waking up the phone periodically is for TCP keep-alive (to keep GCM push notifications working), but once per minute seems kind of excessive even for that. My theory is that there is an app using the Google Play Services Geofencing API, and I just happen to be parked near a geofence boundary. According to my understanding, the Google geofencing service adjusts location polling frequency according to your distance from a geofence. If I am correct, the problem is that it is not smart enough to understand that you are stationary and therefore avoid excessive polling.

I'll try to collect more stats from different locations.

I'm sure this ground has been tread before...

Thanks for sharing ph0b's work here with Battery Historian.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 3
    FYI, I don't have a Nexus 5, but I've been following the Android L news for the past few weeks and have yet to see any reports on the battery historian developer tool. I'm really curious to see detailed battery usage reports for apps that are known to cause frequent wakeups from deep sleep (e.g. facebook). From what I can tell, you need 3 things to use this tool:

    1.) adb

    2.) The actual Python script: https://raw.githubusercontent.com/google/battery-historian/master/historian.py (just right-click and "Save as" to the directory from which you run 'adb')

    3.) Also need to install Python 2.7 on your system (for Window users): https://www.python.org/download/

    4.) Obviously, a browser to view the generated html.

    There are some comments at the beginning of historian.py script that describe how to generate the required data with adb. Note for Windows users: open up the file in Wordpad, not Notepad.

    Also for Windows users: assuming you have installed Python 2.7 in c:\Python27, use the following command line to run the script:

    c:\Python27\python.exe historian.py [OPTIONS] [FILE]

    Also note that this tool is NOT part of the built-in Android battery settings/stats and there is no native Android UI for it. It is meant to be a developer tool. However, this doesn't mean that users with access to 'adb' can't play with it...
    3
    I manage to get this work...even i have no idea about development...

    First it need python 2.7 not 3.4
    After that you have to mix some commands from the OT and the info inside the .py file...so what i do

    After installing python 2.7 i use the command to get a bugreport from the phone...

    Code:
    adb bugreport > bugreport.txt

    then i use the OT command to make the bugreport to an html file with a bit of change

    Code:
    c:\Python27\python.exe historian.py -a bugreport.txt > battery.html

    Thats it...now..i don't know if it has the correct data...im just achived the html look of what we saw on I/O

    I think first you need to use this command

    Code:
    adb shell dumpsys batterystats --enable full-wake-history

    To let the phone start dumping stats...and then after some use time to gather the bugreport from your phone....anyone with better knowlage im sure it will figure it out!!!

    On the attachment i use the command

    Code:
    adb shell dumpsys batterystats --reset

    to reset my values cause im not using my L rom...

    Oh btw this will work only on L....
    1
    Yep, i think this is the most recent problems the two guys from project Volta have. They have to be rely on the help of the programmers which develop the software.

    They have to rely on Developer to use JobScheduler API but not for finding you bad apps that are killing the battery. And to that effect, those guys are doing a terrible job with a botched tool.

    It's amazing how there is NOTHING on the Internet about the Battery Historian tool. It's like no one has used it. In my case, I can't get the command to builds the html file from the bugreport. It keeps giving me a invalid html error.