Help us understand the problem. What is going on with this article?

android adb

原文

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

参考:

https://juejin.im/post/5b5683bcf265da0f9b4dea96

https://developer.android.com/studio/command-line/adb?hl=zh-Cn

https://cwgoover.github.io/2016/05/31/android-setting-pointer-location/

https://android.stackexchange.com/a/114081

https://segmentfault.com/a/1190000015345637

https://github.com/esauvisky/PGo-CalcaBotaBotaCalca

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした