From a7b45cb8c018e592e8677b8068494be0c05c439d Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 14 Sep 2022 22:59:51 +0800 Subject: [PATCH] Disable freeze insets for non blast sync shell transition The method shouldFreezeInsetsPosition was added for when display rotation happens, if the rotated insets position is sent to client before the rotation animation starts, the system bars will jump to weird position temporally because the client side insets animation runner is not a part of sync system. But during freezing, it still has a race that after the start transaction of transition is applied (no longer freeze), the new position doesn't apply synchronously. Then the bars may flicker after rotation animation starts. Since the sync method of shell transition is going to switch to non-blast version, just disable it and rely on the screenshot to cover any temporary states. Bug: 234585256 Test: atest TransitionTests#testDisplayRotationChange Change-Id: I7499db22b1008820f7dcc62ce714eeb27f0fd674 --- .../server/wm/AsyncRotationController.java | 7 ++++++- .../com/android/server/wm/TransitionTests.java | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/AsyncRotationController.java b/services/core/java/com/android/server/wm/AsyncRotationController.java index 219092baface2..1266db5bff980 100644 --- a/services/core/java/com/android/server/wm/AsyncRotationController.java +++ b/services/core/java/com/android/server/wm/AsyncRotationController.java @@ -357,7 +357,12 @@ class AsyncRotationController extends FadeAnimationController implements Consume * or seamless transformation in a rotated display. */ boolean shouldFreezeInsetsPosition(WindowState w) { - return mTransitionOp != OP_LEGACY && w.mTransitionController.inTransition() + if (TransitionController.SYNC_METHOD != BLASTSyncEngine.METHOD_BLAST) { + // Expect a screenshot layer has covered the screen, so it is fine to let client side + // insets animation runner update the position directly. + return false; + } + return mTransitionOp != OP_LEGACY && !mIsStartTransactionCommitted && isTargetToken(w.mToken); } diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java index 8f186e40e2014..ad6ec074257dd 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java @@ -727,7 +727,7 @@ public class TransitionTests extends WindowTestsBase { assertTrue(ime.mToken.inTransition()); assertTrue(task.inTransition()); assertTrue(asyncRotationController.isTargetToken(decorToken)); - assertTrue(asyncRotationController.shouldFreezeInsetsPosition(navBar)); + assertShouldFreezeInsetsPosition(asyncRotationController, statusBar, true); screenDecor.setOrientationChanging(false); // Status bar finishes drawing before the start transaction. Its fade-in animation will be @@ -742,6 +742,7 @@ public class TransitionTests extends WindowTestsBase { // The transaction is committed, so fade-in animation for status bar is consumed. transactionCommittedListener.onTransactionCommitted(); assertFalse(asyncRotationController.isTargetToken(statusBar.mToken)); + assertShouldFreezeInsetsPosition(asyncRotationController, navBar, false); // Navigation bar finishes drawing after the start transaction, so its fade-in animation // can execute directly. @@ -777,7 +778,7 @@ public class TransitionTests extends WindowTestsBase { final AsyncRotationController asyncRotationController = mDisplayContent.getAsyncRotationController(); assertNotNull(asyncRotationController); - assertTrue(asyncRotationController.shouldFreezeInsetsPosition(statusBar)); + assertShouldFreezeInsetsPosition(asyncRotationController, statusBar, true); statusBar.setOrientationChanging(true); player.startTransition(); @@ -823,7 +824,7 @@ public class TransitionTests extends WindowTestsBase { final AsyncRotationController asyncRotationController = mDisplayContent.getAsyncRotationController(); assertNotNull(asyncRotationController); - assertTrue(asyncRotationController.shouldFreezeInsetsPosition(statusBar)); + assertShouldFreezeInsetsPosition(asyncRotationController, statusBar, true); assertTrue(app.getTask().inTransition()); player.start(); @@ -858,6 +859,15 @@ public class TransitionTests extends WindowTestsBase { assertNull(mDisplayContent.getAsyncRotationController()); } + private static void assertShouldFreezeInsetsPosition(AsyncRotationController controller, + WindowState w, boolean freeze) { + if (TransitionController.SYNC_METHOD != BLASTSyncEngine.METHOD_BLAST) { + // Non blast sync should never freeze insets position. + freeze = false; + } + assertEquals(freeze, controller.shouldFreezeInsetsPosition(w)); + } + @Test public void testDeferRotationForTransientLaunch() { final TestTransitionPlayer player = registerTestTransitionPlayer();