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

Commit f135a423 authored by Jing Ji's avatar Jing Ji
Browse files

Wait for the previous app process died before restarting it

Add a wait-for-died in the startProcess if it finds the previous
process is bad and needs to be killed.

Bug: 141857656
Test: Manual - had to forge a fake "bad" app in the AMS to test it
Change-Id: Ia9c80aac42a4bef7affe9fecddae67311ef04c3c
parent 77618452
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3783,7 +3783,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    @GuardedBy("this")
    private void waitForProcKillLocked(final ProcessRecord app, final String formatString,
    void waitForProcKillLocked(final ProcessRecord app, final String formatString,
            final long startTime) {
        app.mAppDiedCallback = () -> {
            synchronized (ActivityManagerService.this) {
+4 −5
Original line number Diff line number Diff line
@@ -1421,7 +1421,7 @@ public final class ProcessList {
        if (app.pendingStart) {
            return true;
        }
        long startTime = SystemClock.elapsedRealtime();
        long startTime = SystemClock.uptimeMillis();
        if (app.pid > 0 && app.pid != ActivityManagerService.MY_PID) {
            checkSlow(startTime, "startProcess: removing from pids map");
            mService.mPidsSelfLocked.remove(app);
@@ -1856,7 +1856,7 @@ public final class ProcessList {
            boolean knownToBeDead, int intentFlags, HostingRecord hostingRecord,
            boolean allowWhileBooting, boolean isolated, int isolatedUid, boolean keepIfLarge,
            String abiOverride, String entryPoint, String[] entryPointArgs, Runnable crashHandler) {
        long startTime = SystemClock.elapsedRealtime();
        long startTime = SystemClock.uptimeMillis();
        ProcessRecord app;
        if (!isolated) {
            app = getProcessRecordLocked(processName, info.uid, keepIfLarge);
@@ -1917,10 +1917,9 @@ public final class ProcessList {
            // An application record is attached to a previous process,
            // clean it up now.
            if (DEBUG_PROCESSES) Slog.v(TAG_PROCESSES, "App died: " + app);
            checkSlow(startTime, "startProcess: bad proc running, killing");
            ProcessList.killProcessGroup(app.uid, app.pid);
            mService.handleAppDiedLocked(app, true, true);
            checkSlow(startTime, "startProcess: done killing old proc");
            mService.waitForProcKillLocked(app, "startProcess: bad proc running, killing: %s",
                    startTime);
        }

        if (app == null) {