Battery historian cannot find end time android

流过昼夜 提交于 2019-12-01 08:19:15

Looks as if something within the parse_end_time function try and except statement is causing _end_time to not get defined, I'm looking here. Line 646 is where the actual error is being produced. If I had to take a guess, I'd say it's this line line = line.split("dumpstate: ", 1)[1]. Looks like line is coming from your input file for line in fileinput.input(input_file):, does your batterystats.txt have this dumpstate line? You could try commenting out lines 646-648 that stop the script and see if having the "end time" is really necessary or not.

Edit: Whoops, your batterystats.txt was included- and no "dumpstate" line... Which means that if "dumpstate:" in line: (line 640) was never True, and _end_time was never defined. Hope this helps you in some way. Let me know.

Although its late but, for current version of battery-historian.py solution is to use Android 5.0+ API, different versions supported different formats of battery statistics log. Current historian.py is working well with 5.0+, below versions and it will crash or will not display charts (this is tested on 6.0).

If you know python, and how to read battery stats file, you can edit code for your flavour of android, but it is time consuming task. You can also write your own parser in another language but it will be like re-inventing the wheel.

One thing I did not try was to clone an older version of battery-historian repo, maybe if there is available, it might work with older version of android depending how old the repo is. (not tested)

UPDATE:

On looking at the commit history of battery-historian repo, I can see there are commits as old as June 2014, while Android L (5.0) Developer Preview release was in August 2014, so there is a fair chance that commits older than Android 5.0 will work on devices that are <5.0.

This is not the exact solution for the above question but it will help to monitor the same stuff that you are trying to figure out with dumpsys batterystats. Please go through this link in which Colt has mentioned the other way round to get the stats.Colt's Unofficial guide to getting started with Battery Historian

And in his comment he has mentioned

Historian only works from the bugreport content

  • Using Battery Historian The battery historian tool will process a battery stats dump, and create the visual report for you.

    • Recording data adb shell dumpsys batterystats --reset Reset the battery data

    • "Do your work here" Pro-Tip: Unplug your device for this work, that way you’ll see true battery draw numbers. (remember to plug it back in before the next step!)

    • Grab the data adb bugreport >bugreport.txt

    • Convert to battery historian python historian.py bugreport.txt >out.html

I'd be grateful for any feedback or criticism that I can learn from or use to help me improve my answer. Thank you

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!