签署Android Studio项目apk作为系统应用程序以使用权限INJECT_EVENTS

时间:2016-04-23 05:08:32

标签: android permissions

Instrumentation m_Instrumentation = new Instrumentation();    
m_Instrumentation.sendPointerSync(MotionEvent.obtain(
                        SystemClock.uptimeMillis()+555,
                        SystemClock.uptimeMillis()+600,
                        MotionEvent.ACTION_UP,500,1000, 0));

我想尝试使用Android Studio开发TeamViewer的模拟。显示应用程序UI时,此代码片段工作正常,我想在应用程序在后台时使用sendPointerSync方法,它给我的消息:

java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission

我添加了权限,它给出了消息:

Permissions with the protection level signature or signatureOrSystem are only granted to system apps. If an app is a regular non-system app, it will never be able to use these permissions.

如何将应用程序签名为系统应用程序?

1 个答案:

答案 0 :(得分:0)

  

如何将应用程序签名为系统应用程序?

使用与Android系统签名相同的密钥!如果您的应用和系统具有相同的证书,您的应用会自动被识别为“系统应用”。

但是,只要您没有自己构建和签署Android系统,通常就没有系统密钥。