Battery Historian 2.0 사용 방법


Google I/O 2015에서 battery historian 2.0으로 개선된 것이 공개 되었다.

기존의 1.0은 python만 설치하면 동작 했었지만 2.0은 설치방법과 사용방법이 그것보다는 약간 더 복잡한 상황이다.

이것에 대해서 다루도록 한다.


GiHub 주소: Battery-Historian



Battery Historian 2.0에서의  사용방법



<요구사항>

android 5.0 이상

android API 21+

2.0에 오면서 go와 javascript를 이용해서 다시 작성 되었다.


<Go Download>

download (다른 운영체제)

Linux: go1.5.linux-amd64.tar.gz


tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

export PATH=$PATH:/usr/local/go/bin

또는 profile에 추가.



<Workspace 생성> - 필수적으로 해야함 -

#디렉터리 생성

$HOME은 나의경우 /root 이다.

mkdir $HOME/go-worksapce/goCode

#GOPATH 설정

export GOPATH=$HOME/work

#GOBIN 설정

export GOBIN=$GOPATH/bin



< install Go support for Protocol Buffers by running go get>

# Grab the code from the repository and install the proto package.

$ go get -u github.com/golang/protobuf/proto

$ go get -u github.com/golang/protobuf/protoc-gen-go

#이것을 설치하면, $GOBIN으로 설정한 곳에 설치가 된다. 따라서 이것을 하기전에 $GOBIN의 PATH 설정을 필수 이다.



실행 결과로 bin과 pkg에 각각의 파일들이 생성 된다. 핵심은 해당 디렉터리는 $GOPATH로 설정한 곳이라는 것이다.




<download the battery historian 2.0 code>

$ go get -u github.com/google/battery-historian

$ cd $GOPATH/src/github.com/google/battery-historian




<Compile Javascript files using the Closure compiler>

$ bash setup.sh





<Run Historian on your machine (make sure PATH contains GOBIN)

$ go run cmd/battery-historian/battery-historian.go [--port <default:9999>]

주의: $GOPATH/src/github.com/google/battery-historian 항상 이곳에서 실행 해야 한다.

#그다음 웹브라우저로 실행 한다.

http://localhost:9999





<프로파일링 로그 생성>

# bugreport 파일은 dumpsys, dumpstate, locat 파일을 모두 포함 한다.

$ adb bugreport > bugreport.txt

# 로그를 초기화 한다.

$ adb shell dumpsys batterystats --reset


#full wake lock을 활성화 시키고 싶으면 아래의 옵션을 활성화 시킨다.

$ adb shell dumpsys batterystats --enable full-wake-history






이전 version에서의 사용 방법 (Summary)


> adb kill-server

> adb devices

> adb shell dumpsys batterystats --reset


<disconnect and play with app>...<reconnect> (연결 되면 배터리 충전 되므로 이러한 방법을 사용 함).


>adb devices

>adb shell dumpsys batterystats > batterystats.txt

> python historian.py batterystats.txt > batterystats.html




+ Recent posts