From 8a33797644bec28c00bb8c7c801df8325d619b79 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Mon, 25 Jul 2022 19:35:22 +0000 Subject: [PATCH] Hold global lock when calling dumpAnrStateLocked Bug: 233890533 Test: Presubmit Change-Id: I2fed92014082938db5f2e9ded23d11023c75ebd7 --- services/core/java/com/android/server/wm/AnrController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/AnrController.java b/services/core/java/com/android/server/wm/AnrController.java index b23f501542573..1ed5a851549c5 100644 --- a/services/core/java/com/android/server/wm/AnrController.java +++ b/services/core/java/com/android/server/wm/AnrController.java @@ -135,8 +135,10 @@ class AnrController { * Notify a window owned by the provided pid was unresponsive. */ private void notifyWindowUnresponsive(int pid, String reason) { - Slog.i(TAG_WM, "ANR in input window owned by pid=" + pid + ". Reason: " + reason); - dumpAnrStateLocked(null /* activity */, null /* windowState */, reason); + synchronized (mService.mGlobalLock) { + Slog.i(TAG_WM, "ANR in input window owned by pid=" + pid + ". Reason: " + reason); + dumpAnrStateLocked(null /* activity */, null /* windowState */, reason); + } // We cannot determine the z-order of the window, so place the anr dialog as high // as possible.