出错:
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.at com.android.server.input.InputManagerService.injectInputEventToTarget(InputManagerService.java:912)
at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1217)
at android.hardware.input.InputManagerGlobal.injectInputEvent(InputManagerGlobal.java:1227)
at com.android.server.input.InputShellCommand.injectMotionEvent(InputShellCommand.java:196)
at com.android.server.input.InputShellCommand.sendSwipe(InputShellCommand.java:430)
at com.android.server.input.InputShellCommand.runSwipe(InputShellCommand.java:414)
at com.android.server.input.InputShellCommand.onCommand(InputShellCommand.java:257)
at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
at android.os.ShellCommand.exec(ShellCommand.java:38)
at com.android.server.input.InputManagerService.onShellCommand(InputManagerService.java:3435)
at android.os.Binder.shellCommand(Binder.java:1075)
at android.os.Binder.onTransact(Binder.java:895)
at android.hardware.input.IInputManager$Stub.onTransact(IInputManager.java:1372)
at android.os.Binder.execTransactInternal(Binder.java:1351)
at android.os.Binder.execTransact(Binder.java:1282)
解决方法:
打开开发者选项 ,小米手机是点进我的设备,进入全部参数然后连续点击系统版本号进入开发者模式。
设置>>更多设置>>开发者选项>>开启USB调试及USB调试(安全设置)。
如果仍报错,则在系统跟踪中关闭跟踪。