adb 命令监测耗电量

adb 命令监测耗电量

!!!前提,一定要保证:手机跟电脑都处于同一个网络

1、输入手机的ip地址来连接手机,ip地址在手机的wifi设置中
  • adb connect 10.27.1.233
    • 连接成功,显示如下:
      localhost:~ hello$ adb connect 10.27.1.233
      connected to 10.27.1.233:5555		
      
    • 连接失败,显示如下
      localhost:~ hello$ adb connect 10.27.3.233
      failed to connect to '10.27.3.204:5555': Connection refused
      
        失败时的处理方法,请往下继续看👀  ~~
      
2、无线连接失败,来进行这些操作~
  • 使用usb数据连接手机,并重启端口

    1、使用usb数据线,保证手机已经与电脑相连接
    2、输入命令 " adb tcpip 5555 " --> "restarting in TCP mode port: 5555"
    
  • 再次尝试连接手机

    adb connect 10.27.1.233  --> "connected to 10.27.1.233:5555"
    
  • 此时可以断开数据线了,查看设备

     adb devices  --> List of devices attached
    				  10.27.1.233:5555	device 
    
3、设备调试成功,开始查看
  • (1)、需要启用app
  • **(2)、**输入命令,查看被测试的app的uid
    localhost:~ hello$ adb shell ps | grep com.yixia.youguo
    u0_a844      15729   568 1976388 126956 0                   0 S com.yixia.youguo
    u0_a844      15791   568 1654880  70432 0                   0 S com.yixia.youguo:channel
    
      其中u0_a844为应用的uid,后面在查看电池统计报告中需要用到,但是注意要将字段中的下划线“_”去掉,改为  u0a844  ;
      15729为pid(此处暂时不用)
    
  • (3)、查看设备的电池信息
    localhost:~ hello$ adb shell dumpsys battery
    
    • 返回信息:
    Current Battery Service state:
      AC powered: false  			#当前是否在充电
      USB powered: false			#是否连接数据线
      Wireless powered: false		#是否使用无线电源
      Max charging current: 0
      Max charging voltage: 0
      Charge counter: 60000
      status: 3						#2:充电状态,其他数字为非充电状态
      health: 2						#电池健康状态:只有数字2表示good
      present: true					#电池是否安装在机身
      level: 86						#电池电量百分比
      scale: 100					#满电量时电池百分比为100%
      voltage: 4091					#电池电压4.091V
      temperature: 280				#电池温度为28度
      technology: Li-poly			#电池类型为锂电池
    
  • (4)、重置电池统计信息
    localhost:~ hello$ adb shell dumpsys batterystats --reset
    Battery stats reset.
    
  • (5)、操作被测应用,如持续10分钟,使用如下命令来保存电池信息到本地
    localhost:~ hello$ adb shell dumpsys batterystats > /Users/hello/Desktop/battery.log
    
    • 这样就可以在桌面上的batter.log中查看Estimated power use (mAh)相关信息
    • 显示如下:
        Estimated power use (mAh):
          Capacity: 3900, Computed drain: 66.0, actual drain: 0-39.0
          Uid u0a844: 49.2 ( wifi=49.2 sensor=0.0240 ) Including smearing: 50.2 ( proportional=0.993 )
          Screen: 14.8 Excluded from smearing
          Cell standby: 1.08 ( radio=1.08 ) Excluded from smearing
          Idle: 0.433 Excluded from smearing
          Uid u0a125: 0.109 ( wifi=0.109 ) Including smearing: 0.111 ( proportional=0.00220 )
          Uid 2000: 0.0862 ( wifi=0.0862 ) Excluded from smearing
          Wifi: 0.0650 ( wifi=0.0650 ) Including smearing: 0.0663 ( proportional=0.00131 )
          Uid 0: 0.0606 ( wifi=0.0606 ) Excluded from smearing
          Uid 1000: 0.0565 ( wifi=0.0565 ) Excluded from smearing
          Uid 1051: 0.0186 ( wifi=0.0186 ) Excluded from smearing
          Uid u0a649: 0.00175 ( wifi=0.00175 ) Including smearing: 0.00178 ( proportional=0.0000353 )
      
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值