一.APK端
将apk给予系统签名,以mm方式编译,内置在system/app目录下.
1.Android.mk 中增加 LOCAL_CERTIFICATE := platform
2.manifest 节点中增加android:sharedUserId=“android.uid.system”
3.manifest 节点中设置android:persistent=”true”属性
二.系统端
ActivityManager作过滤,不杀死此apk进程.
--- frameworks/base/services/core/java/com/android/server/am/ProcessRecord.java
+++ frameworks/base/services/core/java/com/android/server/am/ProcessRecord.java
@@ -550,6 +550,9 @@ final class ProcessRecord {
Slog.i(TAG, "Killing " + toShortString() + " (adj " + setAdj + "): " + reason);
}
+ if (processName.equals("相应apk的进程名")) {
+ return;
+ }
+
Process.killProcessQuiet(pid);
Process.killProcessGroup(uid, pid);
if (!persistent) {
end