adb shell 输入触摸屏点击不工作

adb shell input touchscreen tap is not working

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

    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.access0(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 设备。

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

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

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