ADB命令

连接电脑与手机,手机打开USB调试,接着在电脑上打开CMD输入:adb shell getevent

操作手机,CMD窗口中显示对应的位置信息
查看ADB版本号:

D:\adb>adb version
Android Debug Bridge version 1.0.41
Version 29.0.5-5949299
Installed as D:\adb\adb.exe

ADB连接时,特别是通过ADB WIFI连接的,先用命令:adb connect 192.168.1.105,测试,然后就可以正常控制了

连接指定设备:

adb connect 192.168.1.105

取消连接

adb disconnect 192.168.1.105

通过IP连接

C:\Users\my>adb connect 192.168.1.109
connected to 192.168.1.109:5555

得到序列号方法一

C:\Users\my>adb get-serialno
192.168.1.109:5555

得到序列号方法二

C:\Users\my>adb shell getprop ro.serialno
pvq4nrx4kzemw

C:\Users\my>

1.截屏 screencap

adb shell screencap 文件保存路径

os.system('adb shell screencap -p /sdcard/tmall.png')
os.system('adb pull /sdcard/tmall.png .')

2.录像 screenrecord

adb shell screenrecord 文件保存路径

3.调用ActivityManager(am 命令)

a. 发送 intent

adb shell am start -a android.intent.action.VIEW

b.启动Activity

adb shell am start -n 包名/类名

c. 启动service

adb shell am startservice 包名/类名

启动指定的Service

d. 发送广播

adb shell am boradcast -a 广播Action

adb 命令发送开机广播

e. 强行停止应用

adb shell force-stop 包名

 

卸载apk

adb shell pm uninstall 包名

查看手机中所有apk 包名

adb shell pm list packages

adb shell pm list packages "kuaisho"

结果:package:com.kuaishou.nebula

adb shell pm list packages "dida"

结果:package:com.didapinche.booking

根据包名,查看apk 安装路径

adb shell pm path 包名

adb shell pm path com.kuaishou.nebula

结果:package:/data/app/com.kuaishou.nebula-2/base.apk

查看分辨率:adb shell wm siz

结果:Physical size:1080X1920

删除指定文件:

adb shell rm /sdcard/tmall.png

adb shell pull /sdcard/tmall.png .

adb:error:remote object '/sdcard/tmall.png' does not exist

adb shell ls /sdcard/tmall.png

/sdcard/tmall.png:No such file or directory

清除app 数据

adb shell pm clear 包名

adb shell settings list system
adb shell settings list global
adb shell settings list secure
分别查看 系统 全局 安全 可以使用adb shell 设置的属性(可以使用setting设置的属性)
对应属性的存储的手机位置:
/data/system/users/0/下的对应xml文件:
ettings_global.xml,settings_secure.xml和settings_system.xml

获取自动锁屏时间是
adb shell settings list system | grep timeout
screen_off_timeout=300000
Android系统的锁屏时间存放在Setting数据库中,字段为Settings.System.SCREEN_OFF_TIMEOUT
设置为永不锁屏(2147483647也就是-1)
adb shell settings put system screen_off_timeout 2147483647
healer@healer:/ $ adb shell settings list system | grep timeout
screen_off_timeout=2147483647

 显示正在运行APP

adb shell dumpsys activity activities

posted @ 2020-11-19 10:40  myrj  阅读(555)  评论(0编辑  收藏  举报