From 5a964a3f02ce4606b2b1475e0bf021f532ef73fc Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Fri, 14 Aug 2020 15:01:03 -0700 Subject: [PATCH] WindowState: Fix transaction usage in preserve surface Currently we are using the global transaction without opening it. Switch to the pending transaction. Bug: 161937501 Test: Existing tests pass Change-Id: Icf1215c278ce088d91bd7fb15f932f9ae6378d33 --- services/core/java/com/android/server/wm/WindowState.java | 6 ++++-- .../java/com/android/server/wm/WindowStateAnimator.java | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index f01b68f4393f2..131e5bd67872c 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -5009,9 +5009,10 @@ class WindowState extends WindowContainer implements WindowManagerP // on the new one. This prevents blinking when we change elevation of freeform and // pinned windows. if (!mWinAnimator.tryChangeFormatInPlaceLocked()) { - mWinAnimator.preserveSurfaceLocked(); + mWinAnimator.preserveSurfaceLocked(getPendingTransaction()); result |= RELAYOUT_RES_SURFACE_CHANGED | RELAYOUT_RES_FIRST_TIME; + scheduleAnimation(); } } @@ -5027,9 +5028,10 @@ class WindowState extends WindowContainer implements WindowManagerP // to preserve and destroy windows which are attached to another, they // will keep their surface and its size may change over time. if (mHasSurface && !isChildWindow()) { - mWinAnimator.preserveSurfaceLocked(); + mWinAnimator.preserveSurfaceLocked(getPendingTransaction()); result |= RELAYOUT_RES_SURFACE_CHANGED | RELAYOUT_RES_FIRST_TIME; + scheduleAnimation(); } } final boolean freeformResizing = isDragResizing() diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 1f7324d4d7801..2ace23f24788a 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -349,7 +349,7 @@ class WindowStateAnimator { return result; } - void preserveSurfaceLocked() { + void preserveSurfaceLocked(SurfaceControl.Transaction t) { if (mDestroyPreservedSurfaceUponRedraw) { // This could happen when switching the surface mode very fast. For example, // we preserved a surface when dragResizing changed to true. Then before the @@ -376,7 +376,7 @@ class WindowStateAnimator { // Our SurfaceControl is always at layer 0 within the parent Surface managed by // window-state. We want this old Surface to stay on top of the new one // until we do the swap, so we place it at a positive layer. - mSurfaceController.mSurfaceControl.setLayer(PRESERVED_SURFACE_LAYER); + t.setLayer(mSurfaceController.getClientViewRootSurface(), PRESERVED_SURFACE_LAYER); } mDestroyPreservedSurfaceUponRedraw = true; mSurfaceDestroyDeferred = true;