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

Commit 80f14ace authored by Snild Dolkow's avatar Snild Dolkow Committed by Steve Kondik
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
parent 4587c32a
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -10660,9 +10660,15 @@ public final class ActivityManagerService extends ActivityManagerNative
                    return true;
                    return true;
                }
                }
            }
            }
            final int anrPid = proc.pid;
            mHandler.post(new Runnable() {
            mHandler.post(new Runnable() {
                @Override
                @Override
                public void run() {
                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);
                    appNotResponding(proc, activity, parent, aboveSystem, annotation);
                }
                }
            });
            });