ADB 命令
-
adb connect (ip): 通过IP地址连接设备(局域网内),默认端口5555;
shell$ adb connect 192.168.2.214 connected to 192.168.2.214:5555
-
adb tcpip 5555 设置设备端口(USB连接并开启调试)
-
adb disconnect (ip): 断开连接;
shell#already connected to 192.168.2.214:5555 $ adb disconnect 192.168.2.214 disconnected 192.168.2.214
-
adb devices: 列出相关设备(左边的是serialNumber)(devices, offline, unknown);
shell$ adb devices List of devices attached 192.168.2.214:5555 device
###pc 端文件可直接拖拽###
-
adb install (-r) : 将apk安装到设备(-r 覆盖安装);
-
adb uninstall (-k) : 卸载软件包(-k 保留配置和缓存文件)
-
adb push : 复制本地文件或文件夹到设备上;
-
adb pull : 复制设备上文件或文件夹到本地;
-
adb get-serialno: 获取设备序列号;
shell$ adb get-serialno 192.168.2.214:5555
-
adb [-d|-e|-s ] : 对指定设备进行操作;
-
adb bugreport: 查看bug 报告;
-
adb help: 查看adb 命令;
-
adb version: 查看adb 版本信息;
-
adb start-server: 启动服务(未启动时调用);
-
adb kill-server: 停止服务;
-
adb root: 使shell 操作获取root权限;
Shell 指令:对连接设备进行操作
-
adb shell: 进入设备shell; (主要是linux命令)[exit 退出]
shell$ adb shell root@Hi3798CV200:/ #
-
adb shell pm list packages [-3]: 列出设备上的(第三方)安装包
shell$ adb shell pm list packages -3 package:cimov.com.testrendertee package:com.harine.station
-
adb shell pm clear : 清除某应用程序的数据与缓存;
-
adb shell am start [-a|-c|-n] : 启动指定activity; (-n 指定activity)
-
adb shell am startservice [-a|-c|-n] : 启动指定service;
-
adb shell am broadcast [-a|-c|-n] : 发送广播;
-
adb shell am force-stop : 强制停止应用;
-
adb shell input [source] :
shell$ adb shell input keyevent <keycode> :[键值或键名: KEYCODE_HOME = 3] $ adb shell input text <content>
查看设备信息:
-
adb shell getprop (ro.product.modle): 型号;
-
adb shell dumpsys battery:
-
adb shell dumpsys window displays; 显示屏参数;
-
adb shell wm size; 屏幕分辨率;
-
adb shell wm density; 屏幕密度;
-
adb shell ifconfig; (互联网IP) ifconfig wlan0; (WiFi IP)
-
adb shell cat /proc/cpuinfo; CPU 信息
-
adb shell cat /proc/meminfo; 内存信息;
-
adb shell screencap -p <path_name>: 截屏保存到本地指定路径;(-p .png)
-
adb shell exec-out screencap -p > path_name; 截屏保存到指定路径(pc端)
-
adb shell screenrecord <path_name>: 录频保存到本地指定路径;(180秒)
- ---size WIDTHxHEIGHT 设置屏幕宽高;
- ---time-limit TIME 设置录制时间,默认最大时长180秒;
- --rotate
-
adb shell settings put system screen_brightness 150
-
adb shell cat /proc/net/xt_qtaguid/stats | grep (uid#) : 流量速率
adb shell getprop|grep dalvik.vm.heapstartsize 应用启动后分配的初始内存
adb shell getprop|grep heapgrowthlimit 单个标准应用程序最大内存限制(没设置android:largeHeap)
adb shell getprop|grep dalvik.vm.heapsize 单个dalvik虚拟机最大的内存限制(设置了android:largeHeap)#获取某程序使用流量情况:
- adb connect xxx;
- adb shell;
- top -n 1 -> 找到目标程序的pid;
- cat /proc/pid/status -> 找到uid;
- cd /proc/uid_stat/uid;
- ls -> tcp_rcv:接收值,tcp_snd:发送值;
每个数字与keycode对应表如下:
- 0 --> "KEYCODE_UNKNOWN"
- 1 --> "KEYCODE_MENU"
- 2 --> "KEYCODE_SOFT_RIGHT"
- 3 --> "KEYCODE_HOME"
- 4 --> "KEYCODE_BACK"
- 5 --> "KEYCODE_CALL"
- 6 --> "KEYCODE_ENDCALL"
- 7 --> "KEYCODE_0"
- 8 --> "KEYCODE_1"
- 9 --> "KEYCODE_2"
- 10 --> "KEYCODE_3"
- 11 --> "KEYCODE_4"
- 12 --> "KEYCODE_5"
- 13 --> "KEYCODE_6"
- 14 --> "KEYCODE_7"
- 15 --> "KEYCODE_8"
- 16 --> "KEYCODE_9"
- 17 --> "KEYCODE_STAR"
- 18 --> "KEYCODE_POUND"
- 19 --> "KEYCODE_DPAD_UP"
- 20 --> "KEYCODE_DPAD_DOWN"
- 21 --> "KEYCODE_DPAD_LEFT"
- 22 --> "KEYCODE_DPAD_RIGHT"
- 23 --> "KEYCODE_DPAD_CENTER"
- 24 --> "KEYCODE_VOLUME_UP"
- 25 --> "KEYCODE_VOLUME_DOWN"
- 26 --> "KEYCODE_POWER"
- 27 --> "KEYCODE_CAMERA"
- 28 --> "KEYCODE_CLEAR"
- 29 --> "KEYCODE_A"
- 30 --> "KEYCODE_B"
- 31 --> "KEYCODE_C"
- 32 --> "KEYCODE_D"
- 33 --> "KEYCODE_E"
- 34 --> "KEYCODE_F"
- 35 --> "KEYCODE_G"
- 36 --> "KEYCODE_H"
- 37 --> "KEYCODE_I"
- 38 --> "KEYCODE_J"
- 39 --> "KEYCODE_K"
- 40 --> "KEYCODE_L"
- 41 --> "KEYCODE_M"
- 42 --> "KEYCODE_N"
- 43 --> "KEYCODE_O"
- 44 --> "KEYCODE_P"
- 45 --> "KEYCODE_Q"
- 46 --> "KEYCODE_R"
- 47 --> "KEYCODE_S"
- 48 --> "KEYCODE_T"
- 49 --> "KEYCODE_U"
- 50 --> "KEYCODE_V"
- 51 --> "KEYCODE_W"
- 52 --> "KEYCODE_X"
- 53 --> "KEYCODE_Y"
- 54 --> "KEYCODE_Z"
- 55 --> "KEYCODE_COMMA"
- 56 --> "KEYCODE_PERIOD"
- 57 --> "KEYCODE_ALT_LEFT"
- 58 --> "KEYCODE_ALT_RIGHT"
- 59 --> "KEYCODE_SHIFT_LEFT"
- 60 --> "KEYCODE_SHIFT_RIGHT"
- 61 --> "KEYCODE_TAB"
- 62 --> "KEYCODE_SPACE"
- 63 --> "KEYCODE_SYM"
- 64 --> "KEYCODE_EXPLORER"
- 65 --> "KEYCODE_ENVELOPE"
- 66 --> "KEYCODE_ENTER"
- 67 --> "KEYCODE_DEL"
- 68 --> "KEYCODE_GRAVE"
- 69 --> "KEYCODE_MINUS"
- 70 --> "KEYCODE_EQUALS"
- 71 --> "KEYCODE_LEFT_BRACKET"
- 72 --> "KEYCODE_RIGHT_BRACKET"
- 73 --> "KEYCODE_BACKSLASH"
- 74 --> "KEYCODE_SEMICOLON"
- 75 --> "KEYCODE_APOSTROPHE"
- 76 --> "KEYCODE_SLASH"
- 77 --> "KEYCODE_AT"
- 78 --> "KEYCODE_NUM"
- 79 --> "KEYCODE_HEADSETHOOK"
- 80 --> "KEYCODE_FOCUS"
- 81 --> "KEYCODE_PLUS"
- 82 --> "KEYCODE_MENU"
- 83 --> "KEYCODE_NOTIFICATION"
- 84 --> "KEYCODE_SEARCH"
- 85 --> "TAG_LAST_KEYCODE"