I follow : Android INJECT_EVENTS permission and Permission: INJECT_EVENTS for Instrumenation to other apps
1.I have done root my phone success.
2.I have done follow sign application APK and copy app.apk
to system/app
and set permission app.apk
to rw-r--r--
by app root explorer
3.I add <uses-permission android:name="android.permission.INJECT_EVENTS" />
in Androidmanifest.xml
but It still error require inject permissoin. I don't know why?
06-06 21:23:31.815: E/OpenCV::camera(21812): calling (*pGetPropertyC)(0x7bde06c8, 3)
06-06 21:23:32.058: E/AndroidRuntime(21812): FATAL EXCEPTION: Thread-1881
06-06 21:23:32.058: E/AndroidRuntime(21812): Process: com.example.handtracking, PID: 21812
06-06 21:23:32.058: E/AndroidRuntime(21812): java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
06-06 21:23:32.058: E/AndroidRuntime(21812): at android.os.Parcel.readException(Parcel.java:1472)
06-06 21:23:32.058: E/AndroidRuntime(21812): at android.os.Parcel.readException(Parcel.java:1426)
06-06 21:23:32.058: E/AndroidRuntime(21812): at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:356)
06-06 21:23:32.058: E/AndroidRuntime(21812): at android.hardware.input.InputManager.injectInputEvent(InputManager.java:642)
06-06 21:23:32.058: E/AndroidRuntime(21812): at android.app.Instrumentation.sendPointerSync(Instrumentation.java:937)
06-06 21:23:32.058: E/AndroidRuntime(21812): at com.example.handtracking.CameraService$CameraWorker$2.run(CameraService.java:293)
06-06 21:23:32.274: E/Surface(240): queueBuffer: error queuing buffer to SurfaceTexture, -32
06-06 21:23:32.276: E/MtkCam/DisplayClient(240): (22102)[enquePrvOps] mpStreamOps->enqueue_buffer failed: status[Broken pipe(32)], rpImgBuf(0xb7381fb8,0xaeeb1000) (enquePrvOps){#369:mediatek/hardware/mtkcam/v1/client/DisplayClient/DisplayClient.Stream.cpp}
06-06 21:23:32.406: E/Sensors(785): handleToDriver handle(0)
06-06 21:23:32.406: E/Sensors(785): handleToDriver handle(0)
06-06 21:23:32.409: E/Sensors(785): new setDelay handle(0),ns(1000000)m, error(0), index(1)
06-06 21:23:32.409: E/Accel(785): ACC batch: handle:0, en:0, maxBatchReportLatencyNs:0
06-06 21:23:32.409: E/Sensors(785): sensor 0 go to common batch
06-06 21:23:32.480: E/Sensors(785): handleToDriver handle(0)
06-06 21:23:32.480: E/Sensors(785): handleToDriver handle(0)
06-06 21:23:32.483: E/Sensors(785): new setDelay handle(0),ns(1000000)m, error(0), index(1)
06-06 21:23:32.483: E/Accel(785): ACC batch: handle:0, en:0, maxBatchReportLatencyNs:0
06-06 21:23:32.483: E/Sensors(785): sensor 0 go to common batch
06-06 21:23:32.743: E/PROXIMITY(785): ProximitySensor: unknown event (type=3, code=0)
06-06 21:23:32.843: E/PROXIMITY(785): ProximitySensor: unknown event (type=3, code=0)
06-06 21:23:33.543: E/PROXIMITY(785): ProximitySensor: unknown event (type=3, code=0)
Code Inject event
thread_touch = new Thread(){
@Override
public void run(){
Instrumentation m_Instrumentation = new Instrumentation();
m_Instrumentation.sendPointerSync(MotionEvent.obtain(
SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),
MotionEvent.ACTION_DOWN,x, y, 0));
m_Instrumentation.sendPointerSync(MotionEvent.obtain(
SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP,x,y, 0));
}
};
thread_touch.start();
My phone is Lenovo P70 android 4.4.4