1. Reference article: https://developer.android.com/studio/profile/battery-historian.html
This article is about if the Dump power Day file Batterystats.txt, and then use historian.py to convert it to an HTML file, so that developers more directly understand the information.
But historian has been upgraded to 2.0, not using Python for data analysis, but directly using the go language.
For example: The item on Https://github.com/google/battery-historian mentioned above has been updated and the Python script cannot be found.
2. Follow the introduction of the open source project on GitHub and install the project.
3.adb shell dumpsys batterystats --reset 这里如果不如此,后续dump的文件会过大
4、然后锻炼PC和手机的链接,使用自己的App一段时间,可以切换到桌面等
5、再次链接手机
6、
$ adb bugreport > bugreport.txt
7、
$ go run cmd/battery-historian/battery-historian.go [--port <default:9999>],安装github上面的介绍,启动服务
8、在网页上,上传bugreport.txt 文件,即可以看到分析结果。
Android Power Analysis Tool