ADB 指令

ADB 命令

  1. adb connect (ip): 通过IP地址连接设备(局域网内),默认端口5555;

    shell 复制代码
    $ adb connect 192.168.2.214
    connected to 192.168.2.214:5555
  2. adb tcpip 5555 设置设备端口(USB连接并开启调试)

  3. adb disconnect (ip): 断开连接;

    shell 复制代码
    #already connected to 192.168.2.214:5555
    $ adb disconnect 192.168.2.214
    disconnected 192.168.2.214
  4. adb devices: 列出相关设备(左边的是serialNumber)(devices, offline, unknown);

    shell 复制代码
    $ adb devices
    List of devices attached
    192.168.2.214:5555      device

​ ###pc 端文件可直接拖拽###

  1. adb install (-r) : 将apk安装到设备(-r 覆盖安装);

  2. adb uninstall (-k) : 卸载软件包(-k 保留配置和缓存文件)

  3. adb push : 复制本地文件或文件夹到设备上;

  4. adb pull : 复制设备上文件或文件夹到本地;

  5. adb get-serialno: 获取设备序列号;

    shell 复制代码
    $ adb get-serialno
    192.168.2.214:5555
  6. adb [-d|-e|-s ] : 对指定设备进行操作;

  7. adb bugreport: 查看bug 报告;

  8. adb help: 查看adb 命令;

  9. adb version: 查看adb 版本信息;

  10. adb start-server: 启动服务(未启动时调用);

  11. adb kill-server: 停止服务;

  12. adb root: 使shell 操作获取root权限;

Shell 指令:对连接设备进行操作

  1. adb shell: 进入设备shell; (主要是linux命令)[exit 退出]

    shell 复制代码
    $ adb shell
    root@Hi3798CV200:/ #
  2. adb shell pm list packages [-3]: 列出设备上的(第三方)安装包

    shell 复制代码
    $ adb shell pm list packages -3
    package:cimov.com.testrendertee
    package:com.harine.station
  3. adb shell pm clear : 清除某应用程序的数据与缓存;

  4. adb shell am start [-a|-c|-n] : 启动指定activity; (-n 指定activity)

  5. adb shell am startservice [-a|-c|-n] : 启动指定service;

  6. adb shell am broadcast [-a|-c|-n] : 发送广播;

  7. adb shell am force-stop : 强制停止应用;

  8. adb shell input [source] :

    shell 复制代码
    $ adb shell input keyevent <keycode> :[键值或键名: KEYCODE_HOME = 3]
    $ adb shell input text <content>

    : https://blog.csdn.net/calykong/article/details/105744459?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

查看设备信息:

  1. adb shell getprop (ro.product.modle): 型号;

  2. adb shell dumpsys battery:

  3. adb shell dumpsys window displays; 显示屏参数;

  4. adb shell wm size; 屏幕分辨率;

  5. adb shell wm density; 屏幕密度;

  6. adb shell ifconfig; (互联网IP) ifconfig wlan0; (WiFi IP)

  7. adb shell cat /proc/cpuinfo; CPU 信息

  8. adb shell cat /proc/meminfo; 内存信息;

  9. adb shell screencap -p <path_name>: 截屏保存到本地指定路径;(-p .png)

  10. adb shell exec-out screencap -p > path_name; 截屏保存到指定路径(pc端)

  11. adb shell screenrecord <path_name>: 录频保存到本地指定路径;(180秒)

    1. ---size WIDTHxHEIGHT 设置屏幕宽高;
    2. ---time-limit TIME 设置录制时间,默认最大时长180秒;
    3. --rotate
  12. adb shell settings put system screen_brightness 150

  13. 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)

    #获取某程序使用流量情况:

    1. adb connect xxx;
    2. adb shell;
    3. top -n 1 -> 找到目标程序的pid;
    4. cat /proc/pid/status -> 找到uid;
    5. cd /proc/uid_stat/uid;
    6. 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"
相关推荐
风和先行5 小时前
adb 命令查看设备存储占用情况
android·adb
小兜全糖(xdqt)12 小时前
mysql数据同步到sql server
mysql·adb
帅得不敢出门1 天前
安卓设备adb执行AT指令控制电话卡
android·adb·sim卡·at指令·电话卡
鬼才血脉1 天前
docker+mysql配置
mysql·adb·docker
CircleMouse2 天前
MySQL8完全卸载方法-Win10系统
adb
小小哭包2 天前
MySQL日期时间函数大全
android·adb
ShuQiHere2 天前
【ShuQiHere】️`adb kill-server` 和 `adb start-server` 命令的作用
adb
ShuQiHere3 天前
【ShuQiHere】️ 深入了解 ADB(Android Debug Bridge):您的 Android 开发利器!
android·adb
fighting_sunnyGirl3 天前
mac端mumu模拟器adb识别不了问题
macos·adb
D@.4 天前
如何将MySQL彻底卸载干净
数据库·mysql·adb·方法·彻底删除