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

Commit 3febd4a3 authored by Jing Ji's avatar Jing Ji Committed by Automerger Merge Worker
Browse files

Merge "Fix race condition in UidRecord cleanup" into rvc-d1-dev am: c453c4af

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12244064

Change-Id: I7efa28128e6d794cc39a90643f6ead866b5f0f12
parents 0fa3c008 c453c4af
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -2908,25 +2908,26 @@ public final class ProcessList {
        if ((expecting == null) || (old == expecting)) {
            mProcessNames.remove(name, uid);
        }
        if (old != null && old.uidRecord != null) {
            old.uidRecord.numProcs--;
            old.uidRecord.procRecords.remove(old);
            if (old.uidRecord.numProcs == 0) {
        final ProcessRecord record = expecting != null ? expecting : old;
        if (record != null && record.uidRecord != null) {
            final UidRecord uidRecord = record.uidRecord;
            uidRecord.numProcs--;
            uidRecord.procRecords.remove(record);
            if (uidRecord.numProcs == 0) {
                // No more processes using this uid, tell clients it is gone.
                if (DEBUG_UID_OBSERVERS) Slog.i(TAG_UID_OBSERVERS,
                        "No more processes in " + old.uidRecord);
                mService.enqueueUidChangeLocked(old.uidRecord, -1, UidRecord.CHANGE_GONE);
                        "No more processes in " + uidRecord);
                mService.enqueueUidChangeLocked(uidRecord, -1, UidRecord.CHANGE_GONE);
                EventLogTags.writeAmUidStopped(uid);
                mActiveUids.remove(uid);
                mService.noteUidProcessState(uid, ActivityManager.PROCESS_STATE_NONEXISTENT,
                        ActivityManager.PROCESS_CAPABILITY_NONE);
            }
            old.uidRecord = null;
            record.uidRecord = null;
        }
        mIsolatedProcesses.remove(uid);
        mGlobalIsolatedUids.freeIsolatedUidLocked(uid);
        // Remove the (expected) ProcessRecord from the app zygote
        final ProcessRecord record = expecting != null ? expecting : old;
        if (record != null && record.appZygote) {
            removeProcessFromAppZygoteLocked(record);
        }