You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

小米12S(Android13)执行adb输入命令遇SecurityException权限问题

ADB模拟点击在Android 13设备上触发INJECT_EVENTS权限错误

环境与操作

  • 设备:小米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.

补充说明

曾查找过类似问题,但对应解决方案针对应用内注入场景,不适用于当前通过CMD执行ADB Shell命令的情况。当前USB调试相关设置截图如下:
USB调试设置截图

解决方案

针对小米Android 13设备的该问题,可尝试以下方法:

  1. 重新开启"USB调试(安全设置)"
    小米/Redmi设备的开发者选项中,该选项允许ADB执行输入注入、截图等敏感操作。即便已开启,建议关闭后重新打开一次,确保设置生效。
  2. 用root权限执行命令
    若设备已root,可通过root权限绕过限制:
    adb shell su -c "input swipe 447 572 447 572 737"
    
  3. 更新ADB版本
    旧版ADB可能与Android 13存在兼容性问题,通过adb version查看当前版本,从Android官方渠道下载最新平台工具包更新。
  4. 尝试Monkey或sendevent命令替代
    • Monkey工具模拟点击:
      adb shell monkey --pct-touch 100 -v 1
      
    • sendevent精准模拟坐标点击(需先通过adb shell getevent -l获取对应input设备路径,替换命令中的eventX):
      adb shell sendevent /dev/input/eventX 3 53 447 && sendevent /dev/input/eventX 3 54 572 && sendevent /dev/input/eventX 1 330 1 && sendevent /dev/input/eventX 0 0 0 && sendevent /dev/input/eventX 1 330 0 && sendevent /dev/input/eventX 0 0 0
      

内容的提问来源于stack exchange,提问作者Alpha Beta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 14:17:47