首先是整体的格式:
adb shell dumpsys battery
set [ac|usb|wireless|status|level|invalid]
unplug //模拟断开充电
reset //复位
具体操作
- 查看电池所有相关信息
adb shell dumpsys battery
- 模拟充电状态
adb shell dumpsys battery set status 2
- 模拟非充电状态
adb shell dumpsys battery set status 1
- 设置AC/USB/Wireless模式充电
adb shell dumpsys battery set ac/usb/wireless 1 – 开启ac/usb/wireless充电
adb shell dumpsys battery set ac/usb/wireless 0 – 关闭ac/usb/wireless充电
- 模拟电池电量
adb shell dumpsys battery set level x – x表示电量 0-100之间取值
- 模拟断开充电(Android6.0以上)
adb shell dumpsys battery unplug
- 复位,恢复实际状态
adb shell dumpsys battery reset