From 59a7b14c3e499b3cc70dfc54db7b83a4ea5b1d2d Mon Sep 17 00:00:00 2001 From: shawnlin Date: Mon, 29 Nov 2021 15:21:55 +0800 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: 206871341 Test: atest PinnedStackTests Change-Id: If3001b13b48b1e3124b9bd898ab740a2d3025df0 --- .../core/java/com/android/server/wm/TaskFragment.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java index 985128aaec35a..510ca77752634 100644 --- a/services/core/java/com/android/server/wm/TaskFragment.java +++ b/services/core/java/com/android/server/wm/TaskFragment.java @@ -1957,7 +1957,15 @@ class TaskFragment 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);