diff options
| author | 2020-03-24 23:38:40 +0800 | |
|---|---|---|
| committer | 2020-03-25 00:02:12 +0800 | |
| commit | 06aeb069a070535c0f623c69f8bb0c64a1ed9b1d (patch) | |
| tree | a3f3a820eae26a197f109d1983018fcff61ce050 | |
| parent | 9a8e3ae15c8608f46e29c3aa90a68539c4164cbe (diff) | |
Notify remote rotation with fixed rotation transform
Divider and PipManager in SystemUI needs the signal to position the
corresponding windows.
Since update-orientation and apply-rotation could be asynchronous,
the actual cleanup of fixed rotation transform is split to execute
with applying display rotation.
Bug: 151727009
Test: atest DisplayContentTests#testApplyTopFixedRotationTransform
Change-Id: I49b5a4951c04e52b7880ecd7e21a91f3061d2379
5 files changed, 51 insertions, 34 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index aad242dbc338..f0b906ea448a 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1305,8 +1305,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (mDisplayRotation.isWaitingForRemoteRotation()) { return; } - // Clear the record because the display will sync to current rotation. - mFixedRotationLaunchingApp = null; final boolean configUpdated = updateDisplayOverrideConfigurationLocked(); if (configUpdated) { @@ -1497,7 +1495,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo startFixedRotationTransform(r, rotation); mAppTransition.registerListenerLocked(new WindowManagerInternal.AppTransitionListener() { void done() { - r.clearFixedRotationTransform(); + r.finishFixedRotationTransform(); mAppTransition.unregisterListener(this); } @@ -1526,7 +1524,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (token != mFixedRotationLaunchingApp) { return false; } - if (updateOrientation()) { + // Update directly because the app which will change the orientation of display is ready. + if (mDisplayRotation.updateOrientation(getOrientation(), false /* forceUpdate */)) { sendNewConfiguration(); return true; } @@ -1572,7 +1571,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * @param oldRotation the rotation we are coming from. * @param rotation the rotation to apply. */ - void applyRotationLocked(final int oldRotation, final int rotation) { + private void applyRotation(final int oldRotation, final int rotation) { mDisplayRotation.applyCurrentRotation(rotation); final boolean rotateSeamlessly = mDisplayRotation.isRotatingSeamlessly(); final Transaction transaction = getPendingTransaction(); @@ -6416,15 +6415,20 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo @Override public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { - final int currRotation = - getRequestedOverrideConfiguration().windowConfiguration.getRotation(); - if (currRotation != ROTATION_UNDEFINED - && currRotation != overrideConfiguration.windowConfiguration.getRotation()) { - applyRotationLocked(currRotation, - overrideConfiguration.windowConfiguration.getRotation()); - } - mCurrentOverrideConfigurationChanges = - getRequestedOverrideConfiguration().diff(overrideConfiguration); + final Configuration currOverrideConfig = getRequestedOverrideConfiguration(); + final int currRotation = currOverrideConfig.windowConfiguration.getRotation(); + final int overrideRotation = overrideConfiguration.windowConfiguration.getRotation(); + if (currRotation != ROTATION_UNDEFINED && currRotation != overrideRotation) { + if (mFixedRotationLaunchingApp != null) { + mFixedRotationLaunchingApp.clearFixedRotationTransform( + () -> applyRotation(currRotation, overrideRotation)); + // Clear the record because the display will sync to current rotation. + mFixedRotationLaunchingApp = null; + } else { + applyRotation(currRotation, overrideRotation); + } + } + mCurrentOverrideConfigurationChanges = currOverrideConfig.diff(overrideConfiguration); super.onRequestedOverrideConfigurationChanged(overrideConfiguration); mCurrentOverrideConfigurationChanges = 0; mWmService.setNewDisplayOverrideConfiguration(overrideConfiguration, this); diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java index 57babb0eeaa0..825848022b68 100644 --- a/services/core/java/com/android/server/wm/DisplayRotation.java +++ b/services/core/java/com/android/server/wm/DisplayRotation.java @@ -484,11 +484,8 @@ public class DisplayRotation { prepareNormalRotationAnimation(); } - // TODO(b/147469351): Remove the restriction. - if (mDisplayContent.mFixedRotationLaunchingApp == null) { - // Give a remote handler (system ui) some time to reposition things. - startRemoteRotation(oldRotation, mRotation); - } + // Give a remote handler (system ui) some time to reposition things. + startRemoteRotation(oldRotation, mRotation); return true; } diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 3e5cb50d6101..a30b70de267d 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -667,7 +667,7 @@ public class RecentsAnimationController implements DeathRecipient { mTargetActivityRecord.token); } if (mTargetActivityRecord.hasFixedRotationTransform()) { - mTargetActivityRecord.clearFixedRotationTransform(); + mTargetActivityRecord.finishFixedRotationTransform(); } } diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java index b7c6af2f7a0d..104c5c96ac1b 100644 --- a/services/core/java/com/android/server/wm/WindowToken.java +++ b/services/core/java/com/android/server/wm/WindowToken.java @@ -462,26 +462,42 @@ class WindowToken extends WindowContainer<WindowState> { } /** - * Clears the transformation and continue updating the orientation change of display. Only the - * state owner can clear the transform state. + * Finishes the transform and continue updating the orientation change of display. Only the + * state owner can finish the transform state. */ - void clearFixedRotationTransform() { + void finishFixedRotationTransform() { + if (mFixedRotationTransformState == null || mFixedRotationTransformState.mOwner != this) { + return; + } + final boolean changed = + mDisplayContent.continueUpdateOrientationForDiffOrienLaunchingApp(this); + // If it is not the launching app or the display is not rotated, make sure the transform is + // cleared and the configuration is restored from parent. + if (!changed) { + clearFixedRotationTransform(null /* applyDisplayRotation */); + onConfigurationChanged(getParent().getConfiguration()); + } + } + + /** + * Clears the transform and apply display rotation if the action is given. The caller needs to + * refresh the configuration of this container after this method call. + */ + void clearFixedRotationTransform(Runnable applyDisplayRotation) { final FixedRotationTransformState state = mFixedRotationTransformState; - if (state == null || state.mOwner != this) { + if (state == null) { return; } + state.resetTransform(); // Clear the flag so if the display will be updated to the same orientation, the transform - // won't take effect. 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. + // won't take effect. state.mIsTransforming = false; - final boolean changed = - mDisplayContent.continueUpdateOrientationForDiffOrienLaunchingApp(this); - // If it is not the launching app or the display is not rotated, make sure the merged - // override configuration is restored from parent. - if (!changed) { - onMergedOverrideConfigurationChanged(); + if (applyDisplayRotation != null) { + applyDisplayRotation.run(); } + // 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).mFixedRotationTransformState = null; } diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java index 406affc27b0a..f242989ab885 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentsAnimationControllerTest.java @@ -403,11 +403,11 @@ public class RecentsAnimationControllerTest extends WindowTestsBase { wallpapers.get(0).getConfiguration().orientation); // Wallpaper's transform state is controlled by home, so the invocation should be no-op. - wallpaperWindowToken.clearFixedRotationTransform(); + wallpaperWindowToken.finishFixedRotationTransform(); assertTrue(wallpaperWindowToken.hasFixedRotationTransform()); // Wallpaper's transform state should be cleared with home. - homeActivity.clearFixedRotationTransform(); + homeActivity.finishFixedRotationTransform(); assertFalse(wallpaperWindowToken.hasFixedRotationTransform()); } |