0
0

More than 3 years have passed since last update.

android adb

Posted at

ADB是什么

ADB,即 Android Debug Bridge 是一种允许模拟器或已连接的 Android 设备进行通信的命令行工具,它可为各种设备操作提供便利,如安装和调试应用,并提供对 Unix shell(可用来在模拟器或连接的设备上运行各种命令)的访问。可以在Android SDK/platform-tools中找到 adb 工具或下载 ADB Kits

查看adb的版本信息

adb version

显示设备列表

adb devices

List of devices attached
LK7N18125001132 device

关闭usb调试

adb shell settings put global adb_enabled 0

打开usb调试

adb shell settings put global adb_enabled 1

查询usb调试开关情况

adb shell settings get global adb_enabled

打开模拟定位

adb shell settings put secure mock_location 1

打开坐标

adb shell settings put system pointer_location 1

模拟home按键

adb shell input keyevent 3

模拟按下 Power 键

adb shell input keyevent 26

模拟 touch屏幕事件

点击屏幕(x, y) = (350, 350)位置

adb shell input tap 350 350

模拟滑动的事件

从屏幕(150, 150) 滑到屏幕(300, 300)

adb shell input swipe 150 150 300 300

输入文字

adb shell input text 123

查看 WiFi IP 地址

adb shell ip -f inet addr show wlan0

<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 3000
    inet 192.168.0.100/24 brd 192.168.0.255 scope global wlan0
       valid_lft forever preferred_lft forever

开启adb服务

默认启动 5037 端口

adb start-server

netstat -na | grep 5037

tcp4       0      0  127.0.0.1.5037         127.0.0.1.65208        ESTABLISHED
tcp4       0      0  127.0.0.1.65208        127.0.0.1.5037         ESTABLISHED
tcp4       0      0  127.0.0.1.5037         127.0.0.1.65206        ESTABLISHED
tcp4       0      0  127.0.0.1.65206        127.0.0.1.5037         ESTABLISHED
tcp4       0      0  127.0.0.1.5037         127.0.0.1.65204        ESTABLISHED
tcp4       0      0  127.0.0.1.65204        127.0.0.1.5037         ESTABLISHED
tcp4       0      0  127.0.0.1.5037         127.0.0.1.65202        ESTABLISHED
tcp4       0      0  127.0.0.1.65202        127.0.0.1.5037         ESTABLISHED
tcp4       0      0  127.0.0.1.5037         *.*                    LISTEN

查看系统应用

adb shell pm list packages -s

查看第三方应用

adb shell pm list packages -3

查看应用安装路径

adb shell pm path <package-name>

通过 TCP 连接设备

adb tcpip 5555
adb connect 192.168.1.3:5555

adb devices

关闭 adb服务

adb kill-server

参考:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0