From 1bc6b35487babfdefdc91adda3e27735c7a65ee1 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 4 May 2023 15:53:25 +0800 Subject: [PATCH] Use pending transaction for setting transform hint This uses the proper transaction for [1]. Because the "t" could be sync transaction or start transaction of transition, which will be applied by shell side that is too late. Such as the app relayout before the transition starts, it will still get old transform. [1]: I6650eef0b12d84f7014e5afc280c1cb5e907d7b2 Bug: 270282500 Test: atest SurfaceControlTests#testSurfaceChangedOnRotation Change-Id: Ib4a019bef270e33f76eec51220e758925dbb4c97 --- services/core/java/com/android/server/wm/WindowContainer.java | 4 ++-- services/core/java/com/android/server/wm/WindowToken.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 3ccf183920d3d..829a33d4bfb73 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3592,11 +3592,11 @@ class WindowContainer extends ConfigurationContainer< && !mTransitionController.useShellTransitionsRotation()) { if (deltaRotation != Surface.ROTATION_0) { updateSurfaceRotation(t, deltaRotation, null /* positionLeash */); - t.setFixedTransformHint(mSurfaceControl, + getPendingTransaction().setFixedTransformHint(mSurfaceControl, getWindowConfiguration().getDisplayRotation()); } else if (deltaRotation != mLastDeltaRotation) { t.setMatrix(mSurfaceControl, 1, 0, 0, 1); - t.unsetFixedTransformHint(mSurfaceControl); + getPendingTransaction().unsetFixedTransformHint(mSurfaceControl); } } mLastDeltaRotation = deltaRotation; diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java index 4c5efef795d86..31afcbf262203 100644 --- a/services/core/java/com/android/server/wm/WindowToken.java +++ b/services/core/java/com/android/server/wm/WindowToken.java @@ -596,7 +596,8 @@ class WindowToken extends WindowContainer { .build(); t.setPosition(leash, mLastSurfacePosition.x, mLastSurfacePosition.y); t.reparent(getSurfaceControl(), leash); - t.setFixedTransformHint(leash, getWindowConfiguration().getDisplayRotation()); + getPendingTransaction().setFixedTransformHint(leash, + getWindowConfiguration().getDisplayRotation()); mFixedRotationTransformLeash = leash; updateSurfaceRotation(t, rotation, mFixedRotationTransformLeash); return mFixedRotationTransformLeash;