From 74fbeaf167d7cc99cf07779c5e73ecb98a49ffb4 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 28 Sep 2021 22:08:42 -0700 Subject: [PATCH] Put recents input consumer to the top of the display area - Instead of trying to place it above the top task which can't account for other relative layering (ie. IME), just place the consumer at the top of the display area containing all the tasks Fixes: 195427335 Fixes: 198416276 Test: Open an app with the IME showing, enter recents Change-Id: Iab9ccea417b1c14d8318296ee8bc181528942013 --- .../com/android/server/wm/InputMonitor.java | 13 ++++++++----- .../server/wm/RecentsAnimationController.java | 18 ++++-------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 1bc1d46a42301..1e7b676fbfe4c 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -48,6 +48,8 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import static com.android.server.wm.WindowManagerService.LOGTAG_INPUT_FOCUS; +import static java.lang.Integer.MAX_VALUE; + import android.annotation.Nullable; import android.graphics.Rect; import android.graphics.Region; @@ -581,10 +583,11 @@ final class InputMonitor { if (mAddRecentsAnimationInputConsumerHandle && shouldApplyRecentsInputConsumer) { if (recentsAnimationController.updateInputConsumerForApp( mRecentsAnimationInputConsumer.mWindowHandle)) { - final WindowState highestLayerWindow = - recentsAnimationController.getHighestLayerWindow(); - if (highestLayerWindow != null) { - mRecentsAnimationInputConsumer.show(mInputTransaction, highestLayerWindow); + final DisplayArea targetDA = + recentsAnimationController.getTargetAppDisplayArea(); + if (targetDA != null) { + mRecentsAnimationInputConsumer.reparent(mInputTransaction, targetDA); + mRecentsAnimationInputConsumer.show(mInputTransaction, MAX_VALUE - 1); mAddRecentsAnimationInputConsumerHandle = false; } } @@ -597,7 +600,7 @@ final class InputMonitor { rootTask.getSurfaceControl()); // We set the layer to z=MAX-1 so that it's always on top. mPipInputConsumer.reparent(mInputTransaction, rootTask); - mPipInputConsumer.show(mInputTransaction, Integer.MAX_VALUE - 1); + mPipInputConsumer.show(mInputTransaction, MAX_VALUE - 1); mAddPipInputConsumerHandle = false; } } diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index ba85c9800e568..6a06c0591c36d 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -1102,21 +1102,11 @@ public class RecentsAnimationController implements DeathRecipient { return mTargetActivityRecord.findMainWindow(); } - /** - * Returns the window with the highest layer, or null if none is found. - */ - public WindowState getHighestLayerWindow() { - int highestLayer = Integer.MIN_VALUE; - Task highestLayerTask = null; - for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { - TaskAnimationAdapter adapter = mPendingAnimations.get(i); - int layer = adapter.mTask.getPrefixOrderIndex(); - if (layer > highestLayer) { - highestLayer = layer; - highestLayerTask = adapter.mTask; - } + DisplayArea getTargetAppDisplayArea() { + if (mTargetActivityRecord == null) { + return null; } - return highestLayerTask.getTopMostActivity().getTopChild(); + return mTargetActivityRecord.getDisplayArea(); } boolean isAnimatingTask(Task task) {