在多个设备上运行时,adb shell输入命令会更改 [英] adb shell input command changes when ran on multiple devices

查看:139
本文介绍了在多个设备上运行时,adb shell输入命令会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用bash和adb在Android设备上自动进行配置。当我在一台设备上运行代码时, adb shell输入tap xxx xxx命令的准确性为100%,可以很好地完成工作。

I am currently using bash and adb to automate configurations on Android devices. When I run my code on one device, the 'adb shell input tap xxx xxx' commands are 100% accurate and do their job well.

在多个设备,坐标似乎发生了变化-设备开始在屏幕上看似随机的位置单击,好像它们已经为自己重新分配了新位置一样。

When I run the script on multiple devices, the coordinates seem to change - the device starts clicking at seemingly random spots on the screen, as if they have reassigned themselves new locations.

从逻辑上讲,可能是发生在这里吗?脚本的相关部分如下。

Logically, what could be happening right here? Relevant parts of the script are below.

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


推荐答案

我假设您在这里谈论的是相同的设备

I am assuming you are talking about identical devices here.

如果您的设备只是放置在水平表面上,则某些设备可能会处于不同的显示方向模式,这会使您的坐标偏斜。

If your devices are just laying on top of a horizontal surface - some of the devices could be in a different display orientation mode which would skew your coordinates.

您可以确保所有设备都处于相同的位置(假设是直立的),也可以在运行自动化之前将它们设置为固定的方向。更好的是-停止对模拟的触摸使用绝对坐标。

You could either make sure all of your devices are in the same (let's say upright) position or you could set them to a fixed orientation before running your automation. Or better yet - stop using absolute coordinates for your emulated touches.

这篇关于在多个设备上运行时,adb shell输入命令会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆