I can’t execute the “sendevent” command, but found another way for myself, hope it will be helpfull for somebody.
For simulate touch I used sendPointerSync() from android.app.Instrumentation, that work only with “android.permission.INJECT_EVENTS” permission. For use it you should compile your app as a system app.
To do it you should follow next steps:
-
Getting files from android source:
root-of-android-source-tree/out/host//framework/signapk.jar
root-of-android-source-tree/build/target/product/security/platform.x509.pem
root-of-android-source-tree/build/target/product/security/platform.pk8
-
sign your app using getting files:
Command “java -jar signapk.jar platform.x509.pem platform.pk8 YourApp-unsigned.apk” YourApp-signed.apk.
- adb install YourApp-signed.apk
- Run your app
- Use “adb shell ps” to confirm that your app is running as system.
Code with touch simulating(new thread is necessary for simulation):
Thread thread = new Thread(){
@Override
public void run(){
Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendPointerSync(MotionEvent.obtain(
SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),
MotionEvent.ACTION_DOWN,posx, posy, 0));
m_Instrumentation.sendPointerSync(MotionEvent.obtain(
SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP,width*4/5,height, 0));
}
};
Manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.yourapp"
**android:sharedUserId="android.uid.system"**
android:versionCode="1"
android:versionName="1.0" >
Using resources: