- 如何使用battery history
- 1. 安装Docker
- 2. 检验Docker是否安装成功
- 3. 运行battery historian
- 使用Batterystats收集数据
- Battery Historian图表分析
- 字段描述
Android 官网教程: 使用 Batterystats 和 Battery Historian 分析电池用量
1. 安装Docker- 系统要求
- 先要安装WSL 2(因为docker后端是基于wsl2跑的)
Windows 11 64-bit: Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher.
Windows 10 64-bit: Home or Pro 2004 (build 19041) or higher, or Enterprise or Education 1909 (build 18363) or higher.
64-bit processor with Second Level Address Translation (SLAT)
4GB system RAM
BIOS-level hardware virtualization support must be enabled in the BIOS settings. For more information, see Virtualization. - Hyper-V和容器是否已启用,如没有勾选,则需要勾选并重启电脑
- 检查设备管理器中的Microsoft Hyper-V虚拟机总线提供程序是否有⚠标识,如有可能也是不能安装Docker的
- 先要安装WSL 2(因为docker后端是基于wsl2跑的)
命令行输入"docker version" 或 "docker run hello-world"没有报错说明安装成功!
PS C:\WINDOWS\system32> docker version
Client:
Cloud integration: v1.0.23
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:53:11 2022
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Desktop 4.7.1 (77678)
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:46:14 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
PS C:\WINDOWS\system32> docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
3. 运行battery historian
安装好Docker之后,运行docker – run -p :9999 gcr.io/android-battery-historian/stable:3.0 --port 9999命令,这里的你可以随便写,如1234,然后报了一个连接超时错误,应该是网络访问不了,可是我已经连了FQ网络,还是不行!MMP
PS C:\WINDOWS\system32> docker -- run -p 1234:9999 gcr.io/android-battery-historian/stable:3.0 --port 9999
Unable to find image 'gcr.io/android-battery-historian/stable:3.0' locally
docker: Error response from daemon: Get "https://gcr.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
直接浏览器访问:gcr.io/android-battery-historian/stable:3.0 是没问题的,呃… ,对于这种问题只能说换个网络试试?
使用Batterystats收集数据直接访问:https://bathist.ef.lc/ 也是可以进Bettary Historian的(FQ看到的…)没条件安装Docker,或是没条件上网的同学可以试试这个
Battery Historian只是一个可视化工具,要想查看Battery信息,我们还需要在设备上收集数据。那么,如何收集数据,这里我们就要用到Batterystats
- 确保手机连接电脑,并且开启了开发者模式中的USB调试功能
- adb devices 确认adb能识别到当前设备号
- 重置电池设备收集数据
adb shell dumpsys batterystats --reset
设备始终会在后台收集 Batterystats 和其他调试信息。重置 *** 作会清除旧的电池收集数据。如果不重置,输出内容会非常大。
- 拔掉USB线,因为USB也会给手机供电,这时手机的电源就有2个,为避免给数据收集引入不必要的变量,需要拔掉USB
- 打开APP执行你想要测量功耗数据的 *** 作,例如,你想测量某一拍照算法的功耗,你需要打开APP,确认相关拍照算法已开启,点击拍照,退出相机
- 再次连接USB
- 将battery数据保存到batterystats.txt文件中
adb shell dumpsys batterystats > batterystats.txt
- 使用原始数据生成报告
#Android 7.0及以上 adb bugreport bugreport.zip
- 如果Battery Historian还没运行,请运行下面命令,或者,直接打开https://bathist.ef.lc/
docker -- run -p <port_number>:9999 gcr.io/android-battery-historian:2.1 --port 9999
- 点击 Browse上传.txt 、.zip两个文件,点击Submit
字段 | 描述 |
---|---|
cpu runing | cpu运行 |
kernel only uptime | |
Userspace wakelock | 在 Android 的运行机制里,当手机空闲时会进入到休眠状态。而 wakeloack 的作用就是禁止系统进入休眠,硬件保持高能耗运行从而可以实现关屏唤醒等毒瘤 *** 作。 |
Screen | 屏幕是否点亮 |
Top app | 运行在最上层(用户可见)的app |
GPS | CPS模块是否调用 |
wifi scan | wifi搜索 |
wifi on | wifi是否开启 |
camera | camera是否开启 |
video | video是否开启 |
Pluggled | |
Brightness | 当前屏幕亮度 |
Voltage | 当前电压 |
Charging status | 是否连接电源/USB |
Temperature | 温度 |
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)