Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9bad644 authored by Christopher Tate's avatar Christopher Tate Committed by Ricardo Cerqueira
Browse files

Mark persistent apps as such when the ProcessRecord is created

...rather than only during the OS's "time to start the persistent apps"
boot phase.  This closes a window of opportunity during which a
persistent app container may be live without having been properly
noted as such, because it wound up being launched prior to the
[rather late] boot phase at which the persistent apps are directly
enumerated and bookkeeping for them established.

Bug 20855725

Change-Id: I41822b412de4540dbdeab300b38089303678f76c
parent 912c1a75
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -388,6 +388,10 @@ public final class ActivityManagerService extends ActivityManagerNative
    // Delay in notifying task stack change listeners (in millis)
    static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 1000;
    // Necessary ApplicationInfo flags to mark an app as persistent
    private static final int PERSISTENT_MASK =
            ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT;
    /** All system services */
    SystemServiceManager mSystemServiceManager;
@@ -10091,10 +10095,10 @@ public final class ActivityManagerService extends ActivityManagerNative
        String proc = customProcess != null ? customProcess : info.processName;
        BatteryStatsImpl.Uid.Proc ps = null;
        BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();
        final int userId = UserHandle.getUserId(info.uid);
        int uid = info.uid;
        if (isolated) {
            if (isolatedUid == 0) {
                int userId = UserHandle.getUserId(uid);
                int stepsLeft = Process.LAST_ISOLATED_UID - Process.FIRST_ISOLATED_UID + 1;
                while (true) {
                    if (mNextIsolatedProcessUid < Process.FIRST_ISOLATED_UID
@@ -10118,7 +10122,13 @@ public final class ActivityManagerService extends ActivityManagerNative
                uid = isolatedUid;
            }
        }
        return new ProcessRecord(stats, info, proc, uid);
        final ProcessRecord r = new ProcessRecord(stats, info, proc, uid);
        if (!mBooted && !mBooting
                && userId == UserHandle.USER_OWNER
                && (info.flags & PERSISTENT_MASK) == PERSISTENT_MASK) {
            r.persistent = true;
        }
        return r;
    }
    final ProcessRecord addAppLocked(ApplicationInfo info, boolean isolated,
@@ -10150,8 +10160,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    + info.packageName + ": " + e);
        }
        if ((info.flags&(ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT))
                == (ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT)) {
        if ((info.flags & PERSISTENT_MASK) == PERSISTENT_MASK) {
            app.persistent = true;
            // The Adj score defines an order of processes to be killed.