Cyanogen /dev/uinput key injection
I'm working on a Synergy port to the Android (see synergy-foss.org).
The only 开发者_运维百科way I've found to inject keystrokes is to use the Cyanogen Mod and write keystrokes to /dev/uinput. However, my app does not have permissions to write to /dev/uinput. The only way around this that I've found is to chmod 777 /dev/uinput.
However... it seems after some time the permissions on /dev/uinput are reset -- by what? I don't know.
Is there a better way or is there a way to run your app as root in the Cyanogen mod?
Thanks
Look at IWindowManager.injectKeyEvent. It is in the layoutlib.jar in the platform SDK. I am not sure what permissions the application will need to call it (like root or not) but it is a start. I don't think you will need root to execute the method.
I was playing around with it for a little while and was able to inject keystrokes from my computer keyboard and have the device "repeat" the action.
Hmm I guess it's as simple as
Process p = Runtime.getRuntime().exec("su");
精彩评论