From c9c163399c8ab13ae49eedc8b9e1a709a9258850 Mon Sep 17 00:00:00 2001 From: Arthur Hung Date: Wed, 30 Mar 2022 21:07:48 +0800 Subject: [PATCH] Remove focus if no window and current focus is valid To prevent the event log report many requesting to set the focus to null window even the current focus has been cleared. Bug: 227445061 Test: manual Change-Id: Ia6b6ff9a50824944788968921274750ad43a4bc8 --- services/core/java/com/android/server/wm/InputMonitor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 8038f4404799a..00f7e6362be93 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -414,10 +414,9 @@ final class InputMonitor { final IBinder focusToken = focus != null ? focus.mInputChannelToken : null; if (focusToken == null) { - mInputFocus = null; // When an app is focused, but its window is not showing yet, remove the input focus // from the current window. - if (mDisplayContent.mFocusedApp != null) { + if (mDisplayContent.mFocusedApp != null && mInputFocus != null) { ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "App %s is focused," + " but the window is not ready. Start a transaction to remove focus from" + " the window of non-focused apps.", @@ -426,6 +425,7 @@ final class InputMonitor { "reason=UpdateInputWindows"); mInputTransaction.removeCurrentInputFocus(mDisplayId); } + mInputFocus = null; return; }