我关注:Android INJECT_EVENTS permission 和Permission: INJECT_EVENTS for Instrumenation to other apps
1.我的手机成功了。
2.我已完成关注sign application APK并将app.apk
复制到system/app
并通过app root explorer将权限app.apk
设置为rw-r--r--
3.我在Androidmanifest.xml中添加<uses-permission android:name="android.permission.INJECT_EVENTS" />
但仍有错误需要注射permissoin。我不知道为什么?
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)
代码注入事件
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();
我的手机是联想P70 android 4.4.4
答案 0 :(得分:1)
此权限授予系统应用。第三方不能拥有它。除非您使用系统证书对应用进行签名,否则您将无法获得INJECT_EVENTS
权限。
允许应用程序注入用户事件(键,触摸,轨迹球) 进入事件流并将它们传送到任何窗口。没有这个 权限,您只能将事件传递给自己的窗口 过程
不供第三方应用程序使用。