【发布时间】:2015-04-20 14:20:44
【问题描述】:
如何签署我的应用程序以便我可以将其安装为系统应用程序?
我生成 apk。然后我在终端中输入这些命令:
adb remount
adb push app-debug.apk /system/app/
adb shell chmod 644 /system/app/app-debug.apk
adb reboot
Ofc,我的手机上有根。是 LG G2。
完成重启手机后,该应用程序存在,我无法卸载它,所以我认为这是从现在开始的系统应用程序。但是..
/**
* Match signature of application to identify that if it is signed by system
* or not.
*
* @param packageName
* package of application. Can not be blank.
* @return <code>true</code> if application is signed by system certificate,
* otherwise <code>false</code>
*/
public boolean isSystemApp(String packageName) {
try {
// Get packageinfo for target application
PackageInfo targetPkgInfo = mPackageManager.getPackageInfo(
packageName, PackageManager.GET_SIGNATURES);
// Get packageinfo for system package
PackageInfo sys = mPackageManager.getPackageInfo(
SYSTEM_PACKAGE_NAME, PackageManager.GET_SIGNATURES);
// Match both packageinfo for there signatures
return (targetPkgInfo != null && targetPkgInfo.signatures != null && sys.signatures[0]
.equals(targetPkgInfo.signatures[0]));
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
当我使用我的应用程序包运行它时,上面的函数返回 false。 而且我仍然收到错误:
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
Ofc,我在 android manifest 中添加了 INJECT_EVENTS 权限。我需要它来模拟触摸并模拟从我的服务到其他应用程序的按键。
我做错了吗?
【问题讨论】:
标签: android