1、Battery Historian测试所需环境:Go+Git+Python+Java+Battery Historian源码git
下载Battery Historian源码而且运行的步骤以下:github
1.打开Git Bash 输入命令行go get -d -u github.com/google/battery-historian/... (注意:命令后面有三个点)shell
2.进入到$GOPATH/src/github.com/google/battery-historian目录下方浏览器
3.运行Battery Historian,命令:go run setup.goapp
2、打开浏览器,访问地址
http://localhost:9999/测试
3、生成adb采集日志文件txt, 执行步骤
1.adb shell dumpsys batterystats --enable full-wake-history
2.adb shell dumpsys batterystats --reset
3.拔出USB
4.执行测试用例
5.adb bugreport > filename.txt
6.adb shell dumpsys batterystats --disable full-wake-historygoogle
4、将filename.txt文件上传到http://localhost:9999/ 的“Power Monitor File” 提交后会自动分析命令行
5、关注Battery Level 曲线,在app Selection选择测试的app,在右侧查看App Stats,关注如下指标值日志
--Devices estimated power useblog
--Foreground
--Services下方的相关进程
--Process info