From 038b68935d31ab92a1efbfe07842fb66308ee514 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 8 Aug 2023 13:02:05 +0000 Subject: [PATCH] Do not associate staring window to task for rotation change The association was used for using consistent appearance if the starting window is moved to an activity with different letterbox configurations. But if the change is from display rotation or fixed rotation, it should follow the configuration of the current activity. Fix: 294775946 Test: ActivityRecordTests#testTransferStartingWindowSetFixedRotation Change-Id: I2f6698aeb8470b959c10a7f1a31aa481ea5731ea --- services/core/java/com/android/server/wm/WindowState.java | 2 ++ .../wmtests/src/com/android/server/wm/ActivityRecordTests.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index b2a2452f11231..8faeebc8de7b5 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2334,6 +2334,8 @@ class WindowState extends WindowContainer implements WindowManagerP mDisplayContent.updateImeControlTarget(isImeLayeringTarget() /* updateImeParent */); // Fix the starting window to task when Activity has changed. if (mStartingData != null && mStartingData.mAssociatedTask == null + && mTempConfiguration.windowConfiguration.getRotation() + == selfConfiguration.windowConfiguration.getRotation() && !mTempConfiguration.windowConfiguration.getBounds().equals(getBounds())) { mStartingData.mResizedFromTransfer = true; // Lock the starting window to task, so it won't resize from transfer anymore. diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 3db53eb08ea14..3eed0b72e0bb8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -2939,6 +2939,9 @@ public class ActivityRecordTests extends WindowTestsBase { // transform to activity1. int rotation = (mDisplayContent.getRotation() + 1) % 4; mDisplayContent.setFixedRotationLaunchingApp(activity, rotation); + // The configuration with rotation change should not trigger task-association. + assertNotNull(activity.mStartingData); + assertNull(activity.mStartingData.mAssociatedTask); doReturn(rotation).when(mDisplayContent) .rotationForActivityInDifferentOrientation(topActivity);