【发布时间】:2016-09-01 18:24:57
【问题描述】:
我目前正在使用 bash 和 adb 在 Android 设备上自动进行配置。当我在一台设备上运行我的代码时,“adb shell input tap xxx xxx”命令是 100% 准确的并且可以很好地完成它们的工作。
当我在多个设备上运行脚本时,坐标似乎发生了变化 - 设备开始点击屏幕上看似随机的点,就好像它们已经重新分配了新的位置。
从逻辑上讲,这里会发生什么?脚本的相关部分如下。
DeviceConfig () {
#Location
./adb -s "$usb" shell am start -n com.android.settings/.Settings
./adb -s "$usb" shell input tap 215 695
./adb -s "$usb" shell input tap 1210 55
#Icons
./adb -s "$usb" shell am start -n com.estrongs.android.pop/.view.FileExplorerActivity
sleep 7
./adb -s "$usb" shell input tap 165 500
./adb -s "$usb" shell input tap 165 500
./adb -s "$usb" shell input tap 165 500
./adb -s "$usb" shell input tap 165 500
sleep 1
./adb -s "$usb" shell input tap 155 150
sleep 1
./adb -s "$usb" shell input tap 155 374
sleep 1
./adb -s "$usb" shell input swipe 680 130 680 130 1500
sleep 1
./adb -s "$usb" shell input tap 920 130
sleep 1
./adb -s "$usb" shell input tap 1185 723
sleep 1
}
for usb in $(./adb devices -l | awk '/ device usb:/{print $3}'); do DeviceConfig $usb ; done
【问题讨论】:
-
与所描述的问题没有直接关系 - 但在开始活动时使用
am start -W而不是之后插入固定延迟