连接多个设备,在指定设备运行adb命令
1
adb -s <serialNumber> <command> # serialNumber: adb devices 获取的设备ID号
无线adb连接
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25shadow@shadow MINGW64 ~/Desktop
$ adb devices # 连接手机,获取设备ID号
List of devices attached
8XV5T15A20009865 device
shadow@shadow MINGW64 ~/Desktop
$ adb tcpip 5566 # 开启无线端口号:5566(数字任选,不冲突就OK)
restarting in TCP mode port: 5566
shadow@shadow MINGW64 ~/Desktop
$ adb connect 192.168.1.104:5566 # adb连接手机无线端口,IP地址为手机获取的局域网地址
adb server is out of date. killing...
* daemon started successfully *
connected to 192.168.1.104:5566
shadow@shadow MINGW64 ~/Desktop
$ adb devices # 再次获取连接的设备,可以看到adb无线连接的设备
List of devices attached
192.168.1.104:5566 device
8XV5T15A20009865 device
shadow@shadow MINGW64 ~/Desktop
$ adb devices # 拔掉USB线后,留下无线adb连接的设备,和有线连接一样,可以执行各种adb命令
List of devices attached
192.168.1.104:5566 device记录无线通讯日志
1
2adb shell
logcat -b radio获取系统占用信息
1
adb shell top
通过adb获取CPU的值
1
2
3
4
5adb shell dumpsys cpuinfo
adb shell dumpsys cpuinfo | grep packagename # 获取指定应用的CPU值
adb shell top -m 5 -s cpu # 查看前5个进程cup的使用情况
adb shell top -n l | grep packagename
adb -s #udid# shell dumpsys cpuinfo|grep #filter#|awk '{print '$(date +%Y%m%d%H%M%S)',$1,$2}'|grep #pid#通过adb获取内存
1
2
3
4
5adb shell dumpsys meminfo
adb shell dumpsys meminfo packagename or Pid # 获取指定应用的内存占用
adb shell dumpsys meminfo packagename | grep TOTAL # 获取指定应用的最大内存限制
adb shell getprop | grep heapgrowthlimit # 查看单个应用程序的最大内存限制
adb shell procrank # 取系统所有应用的内存限制数值1 内存PSS抓取命令
1
adb -s #udid# shell dumpsys meminfo|awk '/process:/,/adjustment:/{if(i>1)print x;x=$0;i++}'|grep #filter#|grep #pid#|awk '{print '$(date +%Y%m%d%H%M%S)',$1,$3}'
2 查看USS和PSS
1
adb shell procrank | grep packagename
通过adb获取流量
1
2
3
4adb shell cat /proc/"+Pid+"/net/dev
adb shell cat /proc/5432/net/dev
adb shell cat /proc/net/xt qtaguid/stats | grep uid # 取单个uid的流量情况
adb -s 8XV5T15A20009865 shell cat /proc/net/xt qtaguid/stats | grep 123451 抓取下行流量
1
adb -s #udid# shell cat /proc/net/xt_qtaguid/stats|grep #uid#|awk '{tx_bytes+=$6}END{print '$(date +%Y%m%d%H%M%S)',tx_bytes}
2 抓取上行流量
1
adb -s #udid# shell cat /proc/net/xt_qtaguid/stats|grep #uid#|awk '{tx_bytes+=$8}END{print '$(date +%Y%m%d%H%M%S)',tx_bytes}
3 抓取上行和下行流量
1
adb -s #udid# shell cat /proc/net/xt_qtaguid/stats|grep #uid#|awk '{rx_bytes+=$6}{tx_bytes+=$8}END{print '$(date +%Y%m%d%H%M%S)',rx_bytes,tx_bytes}