【问题标题】:adb shell input touchscreen tap is not workingadb shell 输入触摸屏点击不起作用
【发布时间】:2020-09-22 13:19:10
【问题描述】:

我正在尝试从 adb 模拟 tapswipe 手势到我的 android 设备。我试图运行以下命令 adb shell input tap 500 500adb shell input touchscreen tap 500 500 来自 Windows 命令提示符。它给了我以下错误,

    java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
        at android.os.Parcel.createException(Parcel.java:2074)
        at android.os.Parcel.readException(Parcel.java:2042)
        at android.os.Parcel.readException(Parcel.java:1990)
        at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:925)
        at android.hardware.input.InputManager.injectInputEvent(InputManager.java:886)
        at com.android.commands.input.Input.injectMotionEvent(Input.java:428)
        at com.android.commands.input.Input.access$200(Input.java:41)
        at com.android.commands.input.Input$InputTap.sendTap(Input.java:224)
        at com.android.commands.input.Input$InputTap.run(Input.java:218)
        at com.android.commands.input.Input.onRun(Input.java:108)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:56)
        at com.android.commands.input.Input.main(Input.java:71)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:380)
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.input.InputManagerService.injectInputEventInternal(InputManagerService.java:732)
        at com.android.server.input.InputManagerService.injectInputEvent(InputManagerService.java:706)
        at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:422)
        at android.os.Binder.execTransactInternal(Binder.java:1021)
        at android.os.Binder.execTransact(Binder.java:994)

我还尝试使用 pure-python-adb 包从 python 脚本执行相同的命令。以下是我执行的脚本。

from ppadb.client import Client


adb = Client()
devices = adb.devices()
if len(devices) == 0:
    print("No devices attached")
    quit()
device = devices[0]
print(device)
device.shell('input touchscreen tap 700 1453')

我得到了以下输出,没有注意到设备上的点击,脚本也没​​有错误。

<ppadb.device.Device object at 0x02B30E50>

我是否遗漏了什么(可能在 Android 的开发者选项设置中)?

我在 Windows 10 机器上使用 adb 版本 1.0.41。并通过 USB 使用装有 Android 10 (Android Q) 的 Android 设备。

【问题讨论】:

  • 这能回答你的问题吗? Android INJECT_EVENTS permission
  • @tir38 您建议的问题解决了创建 android 应用程序并使用从该应用程序到设备的触摸事件的问题。但是,我的问题是我无法通过 ADB 发送输入触摸事件。

标签: python android adb touch


【解决方案1】:

在调试部分的开发者选项中查找“USB 调试(安全设置)”或类似内容 -- 在这里您授予 ADB 特殊权限并允许输入。

祝你好运;希望你能找到。

【讨论】:

    【解决方案2】:

    我尝试使用 adb 命令点击 xy 坐标。启用“USB 调试(安全设置)”对我有用。但是手机应该连接到互联网才能启用设置。 谢谢@Meer

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-06
      • 2023-03-27
      • 1970-01-01
      • 2014-09-13
      相关资源
      最近更新 更多