From 5498ee18fe0a7697b2755aecaf23f39bf7fd0462 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 17 Jun 2021 10:45:18 -0700 Subject: [PATCH] Account for the focused window before requesting input consumer focus - The original patch for ag/13732971 was right -- we need to only apply this if the calculated focused window is being animated by the recents animation, not only if there is a recents animation input consumer applied Fixes: 191058092 Bug: 177923822 Test: With live tile enabled, open app in overview and try to reply in a HUN Change-Id: Ib13ada79971ea09dba27c6e0acc2e50017a92951 --- .../com/android/server/wm/InputMonitor.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 6f2f69810f3f0..8c781a13f7db3 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -394,10 +394,23 @@ final class InputMonitor { /** * Called when the current input focus changes. */ - private void updateInputFocusRequest() { + private void updateInputFocusRequest(InputConsumerImpl recentsAnimationInputConsumer) { final WindowState focus = mDisplayContent.mCurrentFocus; - final IBinder focusToken = focus != null ? focus.mInputChannelToken : null; + // Request focus for the recents animation input consumer if an input consumer should + // be applied for the window. + if (recentsAnimationInputConsumer != null && focus != null) { + final RecentsAnimationController recentsAnimationController = + mService.getRecentsAnimationController(); + final boolean shouldApplyRecentsInputConsumer = recentsAnimationController != null + && recentsAnimationController.shouldApplyInputConsumer(focus.mActivityRecord); + if (shouldApplyRecentsInputConsumer) { + requestFocus(recentsAnimationInputConsumer.mWindowHandle.token, + recentsAnimationInputConsumer.mName); + return; + } + } + final IBinder focusToken = focus != null ? focus.mInputChannelToken : null; if (focusToken == null) { mInputFocus = null; return; @@ -474,8 +487,6 @@ final class InputMonitor { boolean mInDrag; - private boolean mRecentsAnimationFocusOverride; - private void updateInputWindows(boolean inDrag) { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "updateInputWindows"); @@ -491,16 +502,8 @@ final class InputMonitor { mInDrag = inDrag; resetInputConsumers(mInputTransaction); - mRecentsAnimationFocusOverride = false; mDisplayContent.forAllWindows(this, true /* traverseTopToBottom */); - - if (mRecentsAnimationFocusOverride) { - requestFocus(mRecentsAnimationInputConsumer.mWindowHandle.token, - mRecentsAnimationInputConsumer.mName); - } else { - updateInputFocusRequest(); - } - + updateInputFocusRequest(mRecentsAnimationInputConsumer); if (!mUpdateInputWindowsImmediately) { mDisplayContent.getPendingTransaction().merge(mInputTransaction); @@ -538,7 +541,6 @@ final class InputMonitor { mRecentsAnimationInputConsumer.mWindowHandle)) { mRecentsAnimationInputConsumer.show(mInputTransaction, w.mActivityRecord); mAddRecentsAnimationInputConsumerHandle = false; - mRecentsAnimationFocusOverride = true; } }