5

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!

alchemiss
  • 398
  • 4
  • 16

3 Answers3

3

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.

radhoo
  • 2,877
  • 26
  • 27
2

So, after a couple of days of googling and research, I found no way to do that (well, except for obviously impossible things like creating my own version of android to obtain the system signature), and devised a sort of workaround: the vnc server (taken from droid-vnc-server v.0.72) opens a socket and writes all pointer events to it (type and coordinates); then there is a service that reads from this socket and injects events via multiple sendevent commands (I could probably do it from the native code as well, but since I suck at c++, I decided not to bother :) ).

This works fine (surprisingly!), but I'm not fully satisfied, because on different devices there are different constants (like, types of events, min and max values, etc.), and I'll have to either parse them from getevent -p, or specify a configuration file.

alchemiss
  • 398
  • 4
  • 16
0

Have you add INJECT_EVENTS use-permission in your manifest.

Vivek Khandelwal
  • 7,829
  • 3
  • 25
  • 40
  • 1
    Of course. I checked, after I push to system/app and reset, on startup it still rejects me the permission: ` W/PackageManager( 115): Not granting permission android.permission.INJECT_EVENTS to package com.vnc.test (protectionLevel=2 flags=0xbe47)` – alchemiss Mar 15 '12 at 14:26
  • 2
    this permission is not the regular type so adding it to the manifest has little effect. For this permission to work , the apk must be signed with system certificate. Not for the regular developers, only for platform makers. – radhoo Jan 30 '13 at 15:38