0
如何簽署我的應用程序,以便將其作爲系統應用程序安裝?將INJECT_PERMISSION添加到應用程序
我生成apk。然後我在終端輸入這些命令:
adb remount
adb push app-debug.apk /system/app/
adb shell chmod 644 /system/app/app-debug.apk
adb reboot
Ofc,我的手機上有root。是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時,我運行它與我的應用程序包。 ,也是我仍然得到錯誤:在Android清單
java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
OFC,我加INJECT_EVENTS許可。我需要它來模擬觸摸並模擬從我的服務到其他應用程序的按鍵。
我做錯了什麼?