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

Commit b27a8ea7 authored by Martijn Coenen's avatar Martijn Coenen
Browse files

Make app zygote launches more robust.

In case a process launch times out, there are paths in
ActivityManagerService that call removeProcessNameLocked() more than
once; in case such a process is using the application zygote, that can
cause the logic to remove the same ProcessRecord from the application
zygote twice, resulting in a NullPointerException.

Bug: 123758436
Test: atest android.app.cts.ServiceTest#testActivityServiceBindingLru
Change-Id: Id5462b6005a7c0601820332344af5be6d10eb319
parent 0671c44a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1681,7 +1681,8 @@ public final class ProcessList {
    public void killAppZygoteIfNeededLocked(AppZygote appZygote) {
        final ApplicationInfo appInfo = appZygote.getAppInfo();
        ArrayList<ProcessRecord> zygoteProcesses = mAppZygoteProcesses.get(appZygote);
        if (zygoteProcesses.size() == 0) { // Only remove if no longer in use now
        if (zygoteProcesses != null && zygoteProcesses.size() == 0) {
            // Only remove if no longer in use now
            mAppZygotes.remove(appInfo.processName, appInfo.uid);
            mAppZygoteProcesses.remove(appZygote);
            mAppIsolatedUidRangeAllocator.freeUidRangeLocked(appInfo);
@@ -1703,6 +1704,7 @@ public final class ProcessList {
            ArrayList<ProcessRecord> zygoteProcesses = mAppZygoteProcesses.get(appZygote);
            zygoteProcesses.remove(app);
            if (zygoteProcesses.size() == 0) {
                mService.mHandler.removeMessages(KILL_APP_ZYGOTE_MSG);
                Message msg = mService.mHandler.obtainMessage(KILL_APP_ZYGOTE_MSG);
                msg.obj = appZygote;
                mService.mHandler.sendMessageDelayed(msg, KILL_APP_ZYGOTE_DELAY_MS);