From f2370163b8d05c770f4df01d57ad8edaae8151e3 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Fri, 16 Mar 2018 16:26:23 -0700 Subject: [PATCH] Don't ANR if a broadcast recipient is sitting at a breakpoint Change-Id: Idcf4f3f0903a59c1787d636cd2994d97c63c3add Fixes: 74616569 Test: manual --- .../java/com/android/server/am/BroadcastQueue.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java index ea90db3f59686..9a7634edd81ba 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -1457,10 +1457,17 @@ public final class BroadcastQueue { return; } - Slog.w(TAG, "Timeout of broadcast " + r + " - receiver=" + r. receiver + // If the receiver app is being debugged we quietly ignore unresponsiveness, just + // tidying up and moving on to the next broadcast without crashing or ANRing this + // app just because it's stopped at a breakpoint. + final boolean debugging = (r.curApp != null && r.curApp.debugging); + + Slog.w(TAG, "Timeout of broadcast " + r + " - receiver=" + r.receiver + ", started " + (now - r.receiverTime) + "ms ago"); r.receiverTime = now; - r.anrCount++; + if (!debugging) { + r.anrCount++; + } ProcessRecord app = null; String anrMessage = null; @@ -1500,7 +1507,7 @@ public final class BroadcastQueue { r.resultExtras, r.resultAbort, false); scheduleBroadcastsLocked(); - if (anrMessage != null) { + if (!debugging && anrMessage != null) { // Post the ANR to the handler since we do not want to process ANRs while // potentially holding our lock. mHandler.post(new AppNotResponding(app, anrMessage));