手机连接上电脑。输入adb命令:adb shell dumpsys battery
Current Battery Service state: ####当前电池服务状态
AC powered: false ####交流供电
USB powered: true ####USB供电
Wireless powered: false ####无线供电
status: 2 ####电池状态:2:充电状态 ,其他数字为非充电状态
health: 2 ####电池健康状态:只有数字2表示good
present: true ####电池是否安装在机身
level: 82 ####电量: 百分比
scale: 100 ####规模
voltage: 4500 ####电池电压
temperature: 378 ####电池温度,单位是0.1摄氏度
current now: -335232 #-------电流值,负数表示正在充电
technology: Li-ion ####电池种类=
切换手机电池为非充电状态: adb shell dumpsys battery set status 1
让手机电量显示百分百: adb shell dumpsys battery set level 100
让手机电量显示1: adb shell dumpsys battery set level 1
软件角度模拟断开充电(实际上是充进电):adb shell dumpsys battery unplug (注意:必须在andorid 6.0以上的版本)
获取整个设备的电量消耗信息: adb shell dumpsys batterystats | more获取某个apk的电量消耗信息: adb shell dumpsys batterystats 包名 | more
Battery History: ####电池的历史
-1d05h55m26s454ms START
-1d05h54m26s454ms START
-1d05h53m26s454ms START
-1d05h53m26s083ms 055 240a0000 status=charging health=good plug=usb temp=301 volt=4332 +plugged +wifi +wifi_running +sensor
-1d05h53m23s913ms 055 640a0002 +wake_lock brightness=medium #####设备锁的亮度:中等
-1d05h53m21s859ms 055 640a0002
-1d05h53m02s873ms 055 640a0032 signal_strength=good #####信号强度:好
-1d05h52m27s845ms 055 640a0030 brightness=dark #####亮度:暗
-1d05h05m58s933ms 055 640a0032 brightness=medium #####亮度:中等
-1d05h04m44s708ms 055 640a0030 brightness=dark
-1d04h25m24s489ms 055 640a0032 brightness=medium
-1d04h24m26s409ms 055 640a0030 brightness=dark
-1d04h23m26s408ms START
-1d04h23m22s033ms 064 640a0002 temp=392 volt=4891 +plugged +wifi +wifi_running +wake_lock +sensor brightness=medium
-1d04h23m03s613ms 064 640a0032 signal_strength=good
-1d04h22m24s596ms 064 640a0030 brightness=dark
-1d04h21m06s862ms 064 640a0032 brightness=medium
-1d04h20m12s489ms 064 640a0030 brightness=dark
-1d04h05m03s041ms 064 640a0032 brightness=medium
-1d04h04m01s905ms 064 640a0030 brightness=dark
-1d04h02m59s330ms 064 640a0032 brightness=medium
-1d04h01m16s339ms 064 640a0030 brightness=dark
-1d03h42m54s214ms 064 640a0032 brightness=medium
-1d03h41m54s516ms 064 640a0030 brightness=dark
-- More --
数字的左边的是时间线,在这个文件的记录中,电池消耗是以时间为线索的。
中间的 数字 是剩余电池电量,在正常使用情况下,会随着时间减少。
数字的右边表示在该时间发生了什么事,一般都是与耗电相关的事件的重要节点。比如+wake_lock是某个应用获取了唤醒锁,-wake_lock是释放了唤醒锁。+running则表示CPU被某段程序占用,-running则表示该段程序运行完了等等,意思都是比较字面化的。而u0a78等符号则表示应用id,一个id对应一个应用,应用的id列表可以在这个文件内找到。