Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INJECT_EVENTS permission on a rooted device

I'm trying to implement a sort of vnc (based on oNaiPs's droid-vnc-server) in my application. Since the mouse events don't work with my device, I'm trying the following: send datagrams from the native vnc framebuffer server, catch them in a Service and use Instrumentation's sendPointerSync. And this is where the permission is needed. I heard you can get all the needed permissions if you push the .apk to /system/app with Root Exploter, chmod and reset, but that didn't work in my case, and I still get SecurityException. I've also tried manually editing the /data/system/packages.xml file.

Is there any other way to get the permission (maybe lower it's security level somehow? Since I only need this app to work on my device anyway), or probably a different way to do what I try to accomplish?

Thanks!

like image 731
alchemiss Avatar asked Mar 15 '12 13:03

alchemiss


1 Answers

Then you probably didn't search enough. Yes it is a pity that Android doesn't offer it by default, but this doesn't mean it's not doable.

The only catch is you'll need root. So if you have root, than you can change the permission of the /dev/input/eventX files to writable.

If the files are writable you can inject custom key and touch events, to any application, by writing to the input event nodes directly.

I have written a small library, available as open source here: http://code.google.com/p/android-event-injector/

It does just that: automatic chmod to set the permissions on the input devs, and uses JNI to interface the native files. Then it exposes a simple Java interface to use in your Android project.

like image 143
radhoo Avatar answered Sep 24 '22 07:09

radhoo