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

Commit 4aae7797 authored by Snild Dolkow's avatar Snild Dolkow Committed by Gerrit Code Review
Browse files

Avoid ANR loop because of queued-up ANR runnables

When a persistent app is killed, it will be restarted immediately. If
this app had ANR:d, there may be a bunch of runnables with its
ProcessRecord queued up. Since the new process will have the same
ProcessRecord (but a different PID), ActivityManager will consider it
to have ANR:d before it has even attached.

This will check that the ProcessRecord's current PID is equal to the
PID when we posted the ANR.

Change-Id: I2a5d7db2f587eceefa4cc5388f10133ca707c2be
(cherry picked from commit 80f14ace)
Ticket: CYNGNOS-751
parent 89c650b7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10631,9 +10631,15 @@ public final class ActivityManagerService extends ActivityManagerNative
                    return true;
                }
            }
            final int anrPid = proc.pid;
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    if (anrPid != proc.pid) {
                        Slog.i(TAG, "Ignoring stale ANR (occurred in " + anrPid +
                                    ", but current pid is " + proc.pid + ")");
                        return;
                    }
                    appNotResponding(proc, activity, parent, aboveSystem, annotation);
                }
            });