安卓的keyEvent注射需要系统权限权限、系统、keyEvent

2023-09-13 23:58:38 作者:一世残花

您好,我现在用的按键事件注射使用的窗口管理器 但是当我测试了这个应用程序它给我的错误

hi i am using key event injection using window manager but when i tested this application it gives me error

  04-12 18:19:35.794: WARN/WindowManager(58): Permission denied: injecting key event        
  from pid 6290 uid 10039 to window Window{45034880  
   com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 10020

   04-12 18:19:35.794: WARN/System.err(6290): java.lang.SecurityException: Injecting to 
    another application requires INJECT_EVENTS permission

 04-12 18:19:35.854: DEBUG/PhoneData(6290):

  04-12 18:19:36.048: WARN/System.err(6290):     at  
 android.os.Parcel.readException(Parcel.java:1247)

  04-12 18:19:36.048: WARN/System.err(6290):     at 
  android.os.Parcel.readException(Parcel.java:1235)

我也给注入事件许可 有没有办法让一个应用系统的权限。

I also give the inject event permission is there any way to give a application system permissions.

推荐答案

只有作为固件的一部分应用程序(例如,通过固件签名密钥签名的)可以按住 INJECT_EVENTS 许可。如果你正在做自己的设备或固件,这将是相关的。如果要创建一个普通的SDK应用程序,你不能注入事件。

Only applications that are part of the firmware (i.e., signed by the firmware signing key) can hold the INJECT_EVENTS permission. If you are making your own device or firmware, this will be relevant. If you are creating an ordinary SDK application, you cannot inject events.