Android:注入KeyEvents

时间:2014-03-25 07:06:04

标签: android linux keyboard android-input-method key-events

我正在开发一个项目,它有两个模块,服务器和客户端。 服务器将作为后台服务在OTT设备(基于Android)上运行,并将负责启动/注入密钥事件,客户端将通过wifi发送密钥事件。 现在我能够控制包含服务器服务的单个应用程序,或者我可以说我能够控制我开发的所有应用程序(使用广播接收器,仪表等等)。

现在我必须控制其他应用程序,我的意思是我必须在全球范围内发送关键事件 我已经完成了几个教程,但仍然坚持这一点。 我需要尝试的最后一件事是使用JNI注入低级别的关键事件,但我对JNI和低级linux子系统陌生!

还有其他解决方法吗?任何领导都会有所帮助 谢谢:D

这些是我的logcat值: -

03-25 16:12:06.422: E/Key Value(7679): 343
03-25 16:12:06.752: E/JavaBinder(8556): Unknown binder error code. 0xfffffff7
03-25 16:12:06.752: E/ServiceManager(8556): error in getService
03-25 16:12:06.752: E/ServiceManager(8556): android.os.RemoteException: Unknown binder error code. 0xfffffff7
03-25 16:12:06.752: E/ServiceManager(8556):     at android.os.BinderProxy.transact(Native Method)
03-25 16:12:06.752: E/ServiceManager(8556):     at android.os.ServiceManagerProxy.getService(ServiceManagerNative.java:123)
03-25 16:12:06.752: E/ServiceManager(8556):     at android.os.ServiceManager.getService(ServiceManager.java:55)
03-25 16:12:06.752: E/ServiceManager(8556):     at android.app.ActivityManagerNative$1.create(ActivityManagerNative.java:1832)
03-25 16:12:06.752: E/ServiceManager(8556):     at android.app.ActivityManagerNative$1.create(ActivityManagerNative.java:1830)
03-25 16:12:06.752: E/ServiceManager(8556):     at android.util.Singleton.get(Singleton.java:34)
03-25 16:12:06.752: E/ServiceManager(8556):     at android.app.ActivityManagerNative.getDefault(ActivityManagerNative.java:74)
03-25 16:12:06.752: E/ServiceManager(8556):     at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:76)
03-25 16:12:06.752: E/ServiceManager(8556):     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-25 16:12:06.752: E/ServiceManager(8556):     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-25 16:12:06.752: E/ServiceManager(8556):     at dalvik.system.NativeStart.main(Native Method)
03-25 16:12:06.752: E/AndroidRuntime(8556): *** FATAL EXCEPTION IN SYSTEM PROCESS: main
03-25 16:12:06.752: E/AndroidRuntime(8556): java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
03-25 16:12:06.752: E/AndroidRuntime(8556):     at android.os.Parcel.readException(Parcel.java:1425)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at android.os.Parcel.readException(Parcel.java:1379)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:356)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at android.hardware.input.InputManager.injectInputEvent(InputManager.java:619)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at com.android.commands.input.Input.injectKeyEvent(Input.java:201)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at com.android.commands.input.Input.sendKeyEvent(Input.java:163)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at com.android.commands.input.Input.run(Input.java:64)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at com.android.commands.input.Input.main(Input.java:41)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
03-25 16:12:06.752: E/AndroidRuntime(8556):     at dalvik.system.NativeStart.main(Native Method)
03-25 16:12:06.762: E/AndroidRuntime(8556): Error reporting crash
03-25 16:12:06.762: E/AndroidRuntime(8556): java.lang.NullPointerException
03-25 16:12:06.762: E/AndroidRuntime(8556):     at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:76)
03-25 16:12:06.762: E/AndroidRuntime(8556):     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
03-25 16:12:06.762: E/AndroidRuntime(8556):     at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
03-25 16:12:06.762: E/AndroidRuntime(8556):     at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案