From e453728b69a40b9d14e76b44745ebbaadc1a45ca Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 23 Jun 2022 21:34:42 +0800 Subject: [PATCH] Sync surface position for animation in core With shell transition: 1. Transition is collecting 2. Window updates position -> set to sync transaction 3. Window plays animation -> use pending transaction 4. The transition is ready and apply sync transaction -> The position set by 3 is replaced by 2 Though it can also be fixed by startAnimation(getSyncTransaction(), that will lose the ability to run window animation independently of token level transition. Bug: 236947311 Test: Launch an activity with a short transition or no transition animation. And it pops a dialog immediately. The dialog should not show in wrong place. Change-Id: I74e044f440e40c3c5f99bf0f8c7a601e953dbbc7 --- services/core/java/com/android/server/wm/WindowContainer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 66cc216fd0e20..bc67c3e578075 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3212,6 +3212,10 @@ class WindowContainer extends ConfigurationContainer< void resetSurfacePositionForAnimationLeash(Transaction t) { t.setPosition(mSurfaceControl, 0, 0); + if (mSyncState != SYNC_STATE_NONE && t != mSyncTransaction) { + // Avoid restoring to old position if the sync transaction is applied later. + mSyncTransaction.setPosition(mSurfaceControl, 0, 0); + } mLastSurfacePosition.set(0, 0); }