Question

I am trying to send touch events (clicks and motions) to the foreground application from an application with system privileges (standard upload, not rooted)

I was able to run shell scripts emulating the inputs directly from linux shell but not from my application:

Runtime.getRuntime().exec(cmd)

returns

cannot open /dev/input/event1, permission denied

This occurs if cmd is sh /path/script-emulating-events or sendevent /dev/input/event1 xxxx x x.

Since the application has android.uid.system for shared user id, it shouldn't be an android privilege issue.

Any idea?

Was it helpful?

Solution 2

There appears to be something new in Jelly Bean! The input commands have improved:

usage: input ...
       input text <string>
       input keyevent <key code number or name>
->       input tap <x> <y>
->       input swipe <x1> <y1> <x2> <y2>

It worked fine on 4.1.2

OTHER TIPS

In order to run those commands, you have to root your device.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top