手机电量的捕捉和耗电量的捕捉

为什么学习:

  自动化平台中捕获脚本运行后的耗电量情况和手机的实时电量

手机实时电量:

  

adb shell dumpsys battery
Current Battery Service state:
  AC powered: false
  USB powered: true
  Wireless powered: false
  Max charging current: 0
  Max charging voltage: 0
  Charge counter: 0
  status: 2
  health: 2
  present: true
  level: 76
  scale: 100
  voltage: 4144
  temperature: 307
  technology: Li-poly

提取level就为当前手机的电量等级

adb shell dumpsys battery | findstr level

连接手机到电脑上默认为充电状态,影响脚本运行过程中的耗电量的捕捉

adb shell dumpsys battery set status 1

切换电池到非充电状态

adb shell dumpsys batterystatus |more
adb shell dumpsys batterystatus packagename |more

获取电量消耗信息

猜你喜欢

转载自www.cnblogs.com/newliu/p/9164816.html