版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chunlongyuan/article/details/79258408
安装 项目主页
方法一 使用dock容器 (推荐该方法)
- 下载安装dock 官网
- 部署
Battery Historian
docker run -p 9999:9999 gcr.io/android-battery-historian/stable:3.0 --port 9999
- 后面再次运行的时候就不需要再部署了,只需要在docker里直接运行即可
❯ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d8ae0c9c924c gcr.io/android-battery-historian/stable:3.0 "battery-historian..." 3 hours ago Exited (2) 17 seconds ago heuristic_lamarr
❯ docker start d8ae0c9c924c
d8ae0c9c924c
❯ docker stop d8ae0c9c924c
d8ae0c9c924c
❯ docker logs -f d8ae0c9c924c
方法二 使用go、python、git
- 下载安装golong
- 配置环境变量到
/etc/profile
文件里
export GOPATH=$HOME/work
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
- 拉取项目
go get -d -u github.com/google/battery-historian/...
- 拉取成功后运行
Battery Historian
$ cd $GOPATH/src/github.com/google/battery-historian
# Compile Javascript files using the Closure compiler
$ go run setup.go
# Run Historian on your machine (make sure $PATH contains $GOBIN)
$ go run cmd/battery-historian/battery-historian.go [--port <default:9999>]
抓取手机信息
- To obtain a bug report from your development device running Android 7.0 and higher:
$ adb shell dumpsys batterystats --enable full-wake-history
$ adb shell dumpsys batterystats --reset
$ adb bugreport bugreport.zip
- For devices 6.0 and lower:
$ adb bugreport > bugreport.txt
查看分析结果
- 打开
http://localhost:9999
- 选择上面生成的文件并进行分析