From ae1def7b63e9087a2c48d39c6a1b9bd6118908f5 Mon Sep 17 00:00:00 2001 From: Ben Miles Date: Tue, 5 Jul 2022 13:22:51 +0100 Subject: [PATCH] Add timeout duration to broadcast ANRs Before: Subject: Broadcast of Intent { ... } After: Subject: Broadcast of Intent { ... }, waited 5001ms Change-Id: Id384d00901217318313d67fb9ee0b2482021bba8 Bug: 238079066 Test: Existing tests pass --- .../core/java/com/android/server/am/BroadcastQueue.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/BroadcastQueue.java b/services/core/java/com/android/server/am/BroadcastQueue.java index 43d0de9855fe9..0cd1bfa3740ad 100644 --- a/services/core/java/com/android/server/am/BroadcastQueue.java +++ b/services/core/java/com/android/server/am/BroadcastQueue.java @@ -2125,8 +2125,9 @@ public final class BroadcastQueue { // app just because it's stopped at a breakpoint. final boolean debugging = (r.curApp != null && r.curApp.isDebugging()); + long timeoutDurationMs = now - r.receiverTime; Slog.w(TAG, "Timeout of broadcast " + r + " - receiver=" + r.receiver - + ", started " + (now - r.receiverTime) + "ms ago"); + + ", started " + timeoutDurationMs + "ms ago"); r.receiverTime = now; if (!debugging) { r.anrCount++; @@ -2158,7 +2159,9 @@ public final class BroadcastQueue { } if (app != null) { - anrMessage = "Broadcast of " + r.intent.toString(); + anrMessage = + "Broadcast of " + r.intent.toString() + ", waited " + timeoutDurationMs + + "ms"; } if (mPendingBroadcast == r) {