Android 8.1 persisten 应用通过安装方式更新升级

最近接到一个客户需求:

SystemUI 想通过安装的方式直接升级更新

但是systemUI 是有标记persistent=true ,无法正常安装,PMS会报错,因为这种应用死掉后会自启,无法杀死应用去重新安装app。

所以只能从系统源码下手 

frameworks/base/services/core/java/com/android/server

+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -6471,7 +6471,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                 ProcessRecord app = apps.valueAt(ia);
                 if (app.persistent && !evenPersistent) {
                     // we don't kill persistent processes
-                    continue;
+                                       if ( TextUtils.equals(app.processName, "com.android.systemui") )
+                                       {
+                                               Slog.w(TAG, "ignore persistent " + app.processName);
+                                       }
+                                       else
+                                       {
+                                               continue;
+                                       }
                 }

+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -944,7 +944,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
         computeProgressLocked(true);
 
         // Unpack native libraries
-        extractNativeLibraries(mResolvedStageDir, params.abiOverride);
+               if ( TextUtils.equals(mPackageName, "com.android.systemui") )
+               {
+                       Slog.w(TAG, "ignored by customer!!!");
+                       //extractNativeLibraries(mResolvedStageDir, params.abiOverride);
+               }
+               else
+               {
+                       extractNativeLibraries(mResolvedStageDir, params.abiOverride);
+               }

觉得我写的有用的兄弟们。帮忙点个赞!!!你们的支持是我写下去的动力

你可能感兴趣的:(android)