From b6ce9a4b204f09328caac2cfca2b6e4a594fda01 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 22 May 2024 20:14:11 +0800 Subject: Pause insets position for seamless rotation The enhances the concept [1] to sync insets leash position. Because after [2], the position will be applied with insets control change. [1]: I51ebd9f2c90b2b4d12f77d1361acc66ab7777b38 [2]: I5ba0c33ca4542d27bb4dee4ce849f34721f20b14 This also merges I2a886a6a04891a7bf09c1152e52a431326a80d03. Bug: 337018949 Test: Enable auto rotation. Rotate camera app. The navigation bar can won't show on screen center. Merged-In: Ibb25dc5735674e6618b5c639c4e2e61ffa678f52 Change-Id: Ibb25dc5735674e6618b5c639c4e2e61ffa678f52 --- .../java/com/android/server/wm/AsyncRotationController.java | 13 +++++++++---- 1 file changed, 9 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 24d4be83c82b..eb85c1a73212 100644 --- a/services/core/java/com/android/server/wm/AsyncRotationController.java +++ b/services/core/java/com/android/server/wm/AsyncRotationController.java @@ -290,7 +290,7 @@ class AsyncRotationController extends FadeAnimationController implements Consume } // The insets position may be frozen by shouldFreezeInsetsPosition(), so refresh the // position to the latest state when it is ready to show in new rotation. - if (mTransitionOp == OP_APP_SWITCH) { + if (isSeamlessTransition()) { for (int i = windowToken.getChildCount() - 1; i >= 0; i--) { final WindowState w = windowToken.getChildAt(i); final InsetsSourceProvider insetsProvider = w.getControllableInsetProvider(); @@ -505,10 +505,15 @@ class AsyncRotationController extends FadeAnimationController implements Consume */ boolean shouldFreezeInsetsPosition(WindowState w) { // Non-change transition (OP_APP_SWITCH) and METHOD_BLAST don't use screenshot so the - // insets should keep original position before the start transaction is applied. - return mTransitionOp != OP_LEGACY && (mTransitionOp == OP_APP_SWITCH + // insets should keep original position before the window is done with new rotation. + return mTransitionOp != OP_LEGACY && (isSeamlessTransition() || TransitionController.SYNC_METHOD == BLASTSyncEngine.METHOD_BLAST) - && !mIsStartTransactionCommitted && canBeAsync(w.mToken) && isTargetToken(w.mToken); + && canBeAsync(w.mToken) && isTargetToken(w.mToken); + } + + /** Returns true if there won't be a screen rotation animation (screenshot-based). */ + private boolean isSeamlessTransition() { + return mTransitionOp == OP_APP_SWITCH || mTransitionOp == OP_CHANGE_MAY_SEAMLESS; } /** -- cgit v1.2.3-59-g8ed1b