Android测试adb command
adb shell下循环执行命令
adb shell之后的命令无法自动执行,可以通过调用txt来执行其中的命令,如:
adb root
adb remount
adb shell < test.txt
test.txt
包含需在shell内执行的命令,如while循环:
while true
do
input tap 180 360 #点击指定坐标
sleep 60
input tap 180 360
rm /sdcard/VID* #删除通配名的文件
done
或者
start cmd /k adb shell "xxxxx"
start cmd /c adb shell "xxxxx"
adb 启动apk
- 获取需要启动的APP的包名:在手机上打开需要启动的app,通过以下命令获取apk包名:
adb shell dumpsys window | findstr mCurrentFocus
如:GFXbench,执行以上命令后返回如下:
adb shell dumpsys window | findstr mCurrentFocus
mCurrentFocus=Window{e8a8aea u0 net.kishonti.gfxbench.vulkan.v50000.corporate/net.kishonti.benchui.initialization.InitActivity}
其中net.kishonti.gfxbench.vulkan.v50000.corporate
即为包名。
- 启动app
adb shell am start net.kishonti.gfxbench.vulkan.v50000.corporate
- 启动APP需要加载时间,通过
ping 8.8.8.8 -n 5 >nul
实现延时执行点击命令。其中-n x
中的x即为可修改的延迟时间,单位秒;ping 地址可随意更改。或者:TIMEOUT /T 3
实现延时3s。
启动GFXbench之后,自动点击开始,命令如下:
@ECHO OFF
adb wait-for-device root
adb wait-for-device remount
adb wait-for-device
adb shell am start net.kishonti.gfxbench.vulkan.v50000.corporate
ping 127.0.0.1 -n 5 >nul
adb shell input tap 530 1040
pause
点击坐标可通过打开开发者模式 —> 指针位置 来获取。