From f3ff9e7f61af16ca99c73c58b09bfdaebcc6bc99 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 27 May 2020 23:15:39 +0800 Subject: Update top fixed rotation launching app when linking new top Assume the foreground activity is fixed orientation landscape. Recents (home) is fixed orientation portrait. When swiping the navigation bar to switch to another fixed orientation portrait activity, before the recents animation is finished, the fixed rotation app is the recents activity. And after that, the top activity will be the portrait one. It will share the existing rotation transform of recents. If the top fixed rotation app is still the recents, its transform will be cleared too early (FixedRotationTransitionListener#onFinishRecentsAnimation) when finishing recents animation that causes flickering. Also change the usage of mAssociatedTokens to include the owner token, so that any linked token can clears all rotated state of associated token at the same time. Fixes: 157446289 Test: atest DisplayContentTests#testApplyTopFixedRotationTransform Change-Id: Ibc1c85cf9c9f61297cbcf13412f39b388b874557 --- services/core/java/com/android/server/wm/DisplayContent.java | 6 ++++++ services/core/java/com/android/server/wm/WindowToken.java | 9 ++++----- .../wmtests/src/com/android/server/wm/DisplayContentTests.java | 4 +++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index b6672d3c73c0..fcd642f9a9c9 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1527,6 +1527,11 @@ class DisplayContent extends WindowContainer { final Configuration mRotatedOverrideConfiguration; final SeamlessRotator mRotator; /** - * The tokens that share the same transform. Their end time of transform are the same as - * {@link #mOwner}. + * The tokens that share the same transform. Their end time of transform are the same. The + * list should at least contain the token who creates this state. */ - final ArrayList mAssociatedTokens = new ArrayList<>(1); + final ArrayList mAssociatedTokens = new ArrayList<>(3); final ArrayList> mRotatedContainers = new ArrayList<>(3); boolean mIsTransforming = true; @@ -531,6 +531,7 @@ class WindowToken extends WindowContainer { mDisplayContent.getConfiguration().uiMode); mFixedRotationTransformState = new FixedRotationTransformState(info, displayFrames, insetsState, new Configuration(config), mDisplayContent.getRotation()); + mFixedRotationTransformState.mAssociatedTokens.add(this); onConfigurationChanged(getParent().getConfiguration()); notifyFixedRotationTransform(true /* enabled */); } @@ -578,14 +579,12 @@ class WindowToken extends WindowContainer { for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) { state.mAssociatedTokens.get(i).cancelFixedRotationTransform(); } - cancelFixedRotationTransform(); } // The state is cleared at the end, because it is used to indicate that other windows can // use seamless rotation when applying rotation to display. for (int i = state.mAssociatedTokens.size() - 1; i >= 0; i--) { state.mAssociatedTokens.get(i).cleanUpFixedRotationTransformState(); } - cleanUpFixedRotationTransformState(); } private void cleanUpFixedRotationTransformState() { diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 7be2b732ac62..7197ce9c22aa 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -1134,8 +1134,10 @@ public class DisplayContentTests extends WindowTestsBase { mDisplayContent.mOpeningApps.add(app2); app2.setRequestedOrientation(newOrientation); - // The activity should share the same transform state as the existing one. + // The activity should share the same transform state as the existing one. The activity + // should also be the fixed rotation launching app because it is the latest top. assertTrue(app.hasFixedRotationTransform(app2)); + assertTrue(mDisplayContent.isFixedRotationLaunchingApp(app2)); // The display should be rotated after the launch is finished. mDisplayContent.mAppTransition.notifyAppTransitionFinishedLocked(app.token); -- cgit v1.2.3-59-g8ed1b