From 667db9ef20f23f8e484587025788a07efd204faf Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Mon, 20 Dec 2021 09:28:35 +0000 Subject: [PATCH] Fix CTS failure for waterfall device When entering to or exiting from Pip mode, the PipTaskOrganizer will set the windowing mode of the activity of the task to WINDOWING_MODE_FULLSCREEN and temporarily set the bounds of the task to fullscreen size for transitioning. It will get the wrong smallestScreenWidthDp if the calculation is based on this temporary fullscreen bounds. We should just inherit the value from parent for this temporary state. Bug: 210892943 Test: atest PinnedStackTests Change-Id: Iaf83de8ad13768c755df7b2a32edbbbec8a02317 Merged-In: If3001b13b48b1e3124b9bd898ab740a2d3025df0 --- services/core/java/com/android/server/wm/Task.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index cae4f22f913f1..dca0bacf1af7d 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -2787,7 +2787,15 @@ class Task extends WindowContainer { if (inOutConfig.smallestScreenWidthDp == Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) { - if (WindowConfiguration.isFloating(windowingMode)) { + // When entering to or exiting from Pip, the PipTaskOrganizer will set the + // windowing mode of the activity in the task to WINDOWING_MODE_FULLSCREEN and + // temporarily set the bounds of the task to fullscreen size for transitioning. + // It will get the wrong value if the calculation is based on this temporary + // fullscreen bounds. + // We should just inherit the value from parent for this temporary state. + final boolean inPipTransition = windowingMode == WINDOWING_MODE_PINNED + && !mTmpFullBounds.isEmpty() && mTmpFullBounds.equals(parentBounds); + if (WindowConfiguration.isFloating(windowingMode) && !inPipTransition) { // For floating tasks, calculate the smallest width from the bounds of the task inOutConfig.smallestScreenWidthDp = (int) ( Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density);