From e3a8bcca10a8394643e359758d32210f3804f758 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 8 Dec 2022 23:39:13 +0800 Subject: [PATCH] Use seamless for collecting transition with fixed rotation When swiping up to enter PiP (auto-pip), the transition type will PiP. If it affects display orientation at the same time, the next activity will have fixed rotation transform. Then the display should also use seamless rotation to avoid taking screenshot and flickering of overlay windows (e.g. round corner) because the draw transaction is not synced. Also correct task transform for a corner case: expanding PiP to different orientation, but display orientation is changed to previous orientation during the animation. Then there is no next transition to reset rotation transform of task. So manual reset it when receiving a cancel event of the change. Bug: 260925940 Test: Enable shell transition. Use Chrome to play a Youtube video in fullscreen landscape. Enter PiP mode by swiping to home. The round corner and cutout should not be flickering. Change-Id: Ibebf033233e43e778b94b7947ab935ca5bc76388 --- .../com/android/server/wm/ActivityRecord.java | 4 ++++ .../com/android/server/wm/DisplayContent.java | 20 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 10b735265b060..183b452a07bb2 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7707,6 +7707,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // This activity may relaunch or perform configuration change so once it has reported drawn, // the screen can be unfrozen. ensureActivityConfiguration(0 /* globalChanges */, !PRESERVE_WINDOWS); + if (mTransitionController.isCollecting(this)) { + // In case the task was changed from PiP but still keeps old transform. + task.resetSurfaceControlTransforms(); + } } void setRequestedOrientation(int requestedOrientation) { diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index b33a83dac6e52..a191fc44b46a7 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -3334,6 +3334,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (!controller.isCollecting(this)) { controller.collect(this); startAsyncRotationIfNeeded(); + if (mFixedRotationLaunchingApp != null) { + setSeamlessTransitionForFixedRotation(controller.getCollectingTransition()); + } } return; } @@ -3343,12 +3346,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mAtmService.startLaunchPowerMode(POWER_MODE_REASON_CHANGE_DISPLAY); if (mFixedRotationLaunchingApp != null) { // A fixed-rotation transition is done, then continue to start a seamless display - // transition. And be fore the start transaction is applied, the non-app windows - // need to keep in previous rotation to avoid showing inconsistent content. - t.setSeamlessRotation(this); - if (mAsyncRotationController != null) { - mAsyncRotationController.keepAppearanceInPreviousRotation(); - } + // transition. + setSeamlessTransitionForFixedRotation(t); } else if (isRotationChanging()) { if (displayChange != null) { final boolean seamless = mDisplayRotation.shouldRotateSeamlessly( @@ -3367,6 +3366,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } } + private void setSeamlessTransitionForFixedRotation(Transition t) { + t.setSeamlessRotation(this); + // Before the start transaction is applied, the non-app windows need to keep in previous + // rotation to avoid showing inconsistent content. + if (mAsyncRotationController != null) { + mAsyncRotationController.keepAppearanceInPreviousRotation(); + } + } + /** If the display is in transition, there should be a screenshot covering it. */ @Override boolean inTransition() {