This is a creation in Article, where the information may have evolved or changed.
The latest in the optimization of Android power consumption, the use of battery historain tools, configuration process also encountered some small pits, record, the people behind the quick fix this thing.
First, configure the Go language environment
Because battery Historain is developed using the Go language, you need to configure the Go language development environment
The download address for the Go Language installation package under Mac is as follows:
https://golang.org/dl/
Choose one of the red boxes in the download, the first is the compression package, the download after the decompression, I use this way, the advantage is to be able to specify the installation directory. When you configure environment variables, you don't have to look for the installation.
Configuring Environment variables
Goroot=/users/xsdsd/develop/go
Export Goroot
Export path= $PATH: $GOROOT/bin
After the configuration is complete, enter go directly at the command line, return
If the following prompt appears, the Go Language development environment has been successfully configured
Ii. download and install battery Historain
The command is as follows:
Go get-u Github.com/golang/protobuf/proto
Go get-u github.com/golang/protobuf/protoc-gen-go
Go get-u Github.com/google/battery-histrizan
CD $GOPATH/src/github.com/google/battery-historian/
Go Run setup.go
Go Run cmd/battery-historian/battery-historian.go
If you can carry out the above steps successfully, then congratulations, battery Historain has successfully installed
I ran into a problem with the third step, and the prompt failed, as shown in
I tried to use SSH to login to GitHub, but there was a problem, the final solution is to create a new Gihub.com/google folder in the SRC directory of Go, and then use the git clone command to drop the code for battery Historain.
Third, the use of battery historain
A prompt appears after you finish executing the Go run cmd/battery-historian/battery-historian.go command
Listening on port:9999
Note that battery Historain has been successfully launched.
Open Browser Input http://localhost:9999
Remember the need to turn over the wall, or not open the use of normal
Then you need to produce bugreport files
Android7.0 above phone use the following command
$ adb bugreport bugreport.zip
Android6.0 and below the phone use the following command
$ adb bugreport > Bugreport.txt
The corresponding bugreport file is generated in the directory where the command is executed after the command execution completes
Use the page you just opened to see the effect
Of course, the battery Historain tool provides only the underlying data, and if you want to optimize for power consumption, you need to process the data yourself.