From d430377b2fb2d6ed0f73855bdb6a37981f535556 Mon Sep 17 00:00:00 2001 From: Jing Ji Date: Fri, 27 May 2022 13:57:44 -0700 Subject: Check if the ANR dump is still ongoing before reporting it Bug: 234003550 Test: Manual Change-Id: I7a6161afe33ec1b7b2094cccb99686215fb5ecaa --- services/core/java/com/android/server/am/AppErrors.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java index ed492bc7344c..08c1de61d7fb 100644 --- a/services/core/java/com/android/server/am/AppErrors.java +++ b/services/core/java/com/android/server/am/AppErrors.java @@ -836,12 +836,18 @@ class AppErrors { report.type = ApplicationErrorReport.TYPE_CRASH; report.crashInfo = crashInfo; } else if (errState.isNotResponding()) { + final ActivityManager.ProcessErrorStateInfo anrReport = + errState.getNotRespondingReport(); + if (anrReport == null) { + // The ANR dump is still ongoing, ignore it for now. + return null; + } report.type = ApplicationErrorReport.TYPE_ANR; report.anrInfo = new ApplicationErrorReport.AnrInfo(); - report.anrInfo.activity = errState.getNotRespondingReport().tag; - report.anrInfo.cause = errState.getNotRespondingReport().shortMsg; - report.anrInfo.info = errState.getNotRespondingReport().longMsg; + report.anrInfo.activity = anrReport.tag; + report.anrInfo.cause = anrReport.shortMsg; + report.anrInfo.info = anrReport.longMsg; } return report; -- cgit v1.2.3-59-g8ed1b