我的 Android 设备上发生 SecurityException

问题描述 投票:0回答:1

设备:小米12S(Android 13)

我将手机连接到电脑进行USB调试,我正在尝试使用cmd命令来模拟手机上的点击:

adb shell input swipe 447 572 447 572 737

然后出现错误:

Exception occurred while executing 'swipe':
java.lang.SecurityException: Injecting input events requires the caller (or the source of the instrumentation, if any) to have the INJECT_EVENTS permission.

我的设备上没有发生点击事件。

我尝试在 stackoverflow 中寻找类似的问题:

Android INJECT_EVENTS 权限(Android 13)

但是这个问题的解决方案对我不起作用。因为我是通过cmd命令执行adb shell的。

我的设置:

java android adb
1个回答
0
投票

显然,您是从应用程序(可能是测试应用程序)而不是从终端运行

adb shell <>
命令。

  • 你有锁屏吗?在屏幕打开且禁用锁定屏幕的情况下进行测试。如果(非特权?)测试尝试触摸锁屏进程(systemUI?),这可以解释 java.lang.SecurityException
  • 您想模拟哪个应用程序的点击?您的测试应用程序(执行
    adb shell <>
    的应用程序)是否有清单(指定了这些权限)?两个 APK 是否使用相同的密钥签名? (这是您能够将事件从测试 apk 注入到测试中的应用程序的要求)
  • 由于 shell 隐式获得 INJECT_EVENTS 权限,您能否成功运行这个确切的
    adb shell <>
    命令(您应该能够 - 如果没有在 https://b.corp.google.com/issues/new?component 下提交错误) =192795&模板=1310483)。 PS:不太可能..但如果它是系统应用程序,它应该由平台密钥签名
© www.soinside.com 2019 - 2024. All rights reserved.