Battery-Historian是谷歌推出的一款专门分析Bugreport的工具,是谷歌2015年I/O大会上推出的一款检测运行在android5.0(Lollipop)及以后版本的设备上电池的相关信息和事件的工具,是一款对于分析手机状态,历史运行情况很好的可视化分析工具,当设备在使用电池的时候,它可以使用开发者们看到系统级和应用级事件图表,在图表时间轴上可以缩放和平移,能够直观的看到自上一次充满电到现在设备电池的统计汇总信息,它可以选中一个应用程序来检查该应用影响电池电量的一些参数,并且可以对比两个bugreport文件信息分析,并对其电池关键区别点做高亮显示。
下面我们就battery-historian分析结果的分析做一些简单的介绍
将bugreport提交后battery-historian会自动进行分析,下面是分析结果页面最主要的内容:
1. 上图横坐标是时间轴,上图的7:15 7:30就是时间,说明时间间隔是15分钟,当然可以通过鼠标滚轮去放大和缩小时间间隔
2. 纵轴
1)CPU running
CPU的运行状态,黑色是running状态,空白表示CPU处于空闲状态。
2)Kernel only uptime
kernel运行时间,kernel
3)Userspace wakelock
代表应用持有wakelock锁的总时间,但是不会精确到某个app持有wakelock的时间。
kernel
4) Long Wakelocks
Wakelocks are currently logged as being held for a long time if they have been held for more than a minute.
The time shown here is the total amount of the wakelock was held.
5)Screen
屏幕状态,红色:亮屏,空白:灭屏。
6)Top app
当前时刻当前运行的是那个应用,可以用来判断某一个app对于整体手机电量的影响。
7)Activity Manager Proc
activity的进程信息,包括该进程的开始时间和结束时间。
8)Doze
Doze模式的状态
9)JobScheduler
JobScheduler是Android L版本新引入的API,JobScheduler,顾名思义,是用来调度工作。工作被调度的条件包括网络变化,充电插拔,周期执行等。使用场景包括wifi条件下数据下载上传等等。
10)GPS
GPS的使用情况,红色:使用,空白:闲置。
11)Network connectivity
点击可以查看各个颜色代表的不同含义。
12)Mobile signal strength
移动信号,绿色:great,黄色:good,橘色:moderate,红色:poor,空白:none。
13)Wifi scan
Wifi扫描状态,绿色:在扫描,空白:没有扫描。
14)Wifi supplicant
无线客户端,底层的一个demo,在wifi运行的时候,这个也会运行。
15)Wifi signal strength
Wifi信号强度,绿色:great,黄色:good,橘色:moderate,红色:poor,空白:none。
16)Wifi running
wifi运行状态
17)Wifi on
wifi是否开启
18)Package install
安装软件是的状态信息。
19)Battery level
电池电量水平
20)Plugged
插入充电器的时段
21)Charging on
充电时段
22)Temperature
电池温度
下面是官网上的一些信息
- battery_level: When the battery level was recorded and logged. Reported in percent, where 093 is 93%. Provides an overall measure of how fast the battery is draining.
- top: The application running at the top; usually, the application that is visible to the user. If you want to measure battery drain while your app is active, make sure it's the top app. If you want to measure battery drain while your app is in the background, make sure it's not the top app.
- wifi_running: Shows that the Wi-Fi network connection was active.
- screen: Screen is turned on.
- phone_in_call: Recorded when the phone is in a call.
- wake_lock: App wakes up, grabs a lock, does small work, then goes back to sleep. This is one of the most important pieces of information. Waking up the phone is expensive, so if you see lots of short bars here, that might be a problem.
- running: Shows when the CPU is awake. Check whether it is awake and asleep when you expect it to be.
- wake_reason: The last thing that caused the kernel to wake up. If it's your app, determine whether it was necessary.
- mobile_radio: Shows when the radio was on. Starting the radio is battery expensive. Many narrow bars close to each other can indicate opportunities for batching and other optimizations.
- gps: Indicates when the GPS was on. Make sure this is what you expect.
- sync: Shows when an app was syncing with a backend. The sync bar also shows which app did the syncing. For users, this can show apps where they might turn syncing off to save battery. Developers should sync as little as possible and only as often as necessary.
Note: Not every chart will show every category.