一、获取电池信息
命令:
adb shell dumpsys battery
示例:
D:\adb>adb shell dumpsys battery
Current Battery Service state:
AC powered: false
USB powered: true
Wireless powered: false
Max charging current: 500000
status: 2
health: 2
present: true
level: 100
scale: 100
voltage: 4414
temperature: 310
technology: Li-poly
这将返回当前设备有关电池的所有信息。
参数说明
Current Battery Service state | 当前电池服务状态 |
---|---|
AC powered: false | 交流供电 |
USB powered: true | USB供电 |
Wireless powered: false | 无线供电 |
Max charging current: 500000 | 最大充电电流 |
Max charging voltage: 4713000 | 最大充电电压 |
Charge counter: 29000 | 电荷计数器?? |
status: 2 | 电池状态: 2:正充电;3:没插充电器;4:不充电; 5:电池充满 |
health: 2 | 电池健康状态:2:良好; 3:过热; 4:无用的; 5:超压; 7:温度过低 |
present: true | 电池是否安装在机身 |
level: 82 | 电量: 百分比 |
scale: 100 | 规模 |
voltage: 4500 | 电池电压 |
temperature: 378 | 电池温度,单位是0.1摄氏度 |
current now: -335232 | 电流值,负数表示正在充电 |
technology: Li-ion | 电池种类 |
二、修改电池信息
1、修改充电状态
D:\adb>adb shell dumpsys battery set status 1 :非充电状态
D:\adb>adb shell dumpsys battery set status 2 :充电状态
没有返回值,便是成功!
2、修改电量百分比
D:\adb>adb shell dumpsys battery set level 100 :修改电量为100%
三、恢复电池信息
D:\adb>adb shell dumpsys battery reset