From 9c09066ff6acac8c01eb6d61b723b54ee6779426 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Mon, 6 Feb 2023 10:16:47 -0800 Subject: [PATCH] [wm] Drop no focused window ANR request if the activity is stopped If the activity is in stopped state it will not have a visible window on screen. In this case drop any ANR request which tries to blame the app if it's focused without a window. This can happen on some products which do not have a focused system window when the display is turned off. Test: turn of display, send keyevent Bug: 236763025 Change-Id: I773bcd9b3448654705cdad224ea4426f9545f3cf --- services/core/java/com/android/server/wm/AnrController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/wm/AnrController.java b/services/core/java/com/android/server/wm/AnrController.java index 7c0d6586701fe..bbe7a33669c80 100644 --- a/services/core/java/com/android/server/wm/AnrController.java +++ b/services/core/java/com/android/server/wm/AnrController.java @@ -81,6 +81,10 @@ class AnrController { Slog.e(TAG_WM, "Unknown app appToken:" + applicationHandle.name + ". Dropping notifyNoFocusedWindowAnr request"); return; + } else if (activity.mAppStopped) { + Slog.d(TAG_WM, "App is in stopped state:" + applicationHandle.name + + ". Dropping notifyNoFocusedWindowAnr request"); + return; } // App is unresponsive, but we are actively trying to give focus to a window.