From b113a52484453fa18eb2a145a2293c6922a2584b Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Thu, 13 Apr 2023 16:43:58 +0800 Subject: [PATCH] Apply transaction before calling onFinish onFinish callback will be invoked before applying the start transaction when performing the resize animation. It happens when there is no need to play the animation. This CL adjusts the order of execution to ensure apply the start transaction before calling onFinish. Bug: 273430199 Test: pass exist testing Change-Id: I0aaed70a1e8cca1f39eb94c78d7e709c323dda77 --- .../wm/shell/common/split/SplitDecorManager.java | 10 ++++++---- .../wm/shell/splitscreen/SplitScreenTransitions.java | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java index 56616cb6bd88f..ed3aaddfc1642 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitDecorManager.java @@ -51,6 +51,8 @@ import com.android.wm.shell.R; import com.android.wm.shell.common.ScreenshotUtils; import com.android.wm.shell.common.SurfaceUtils; +import java.util.function.Consumer; + /** * Handles split decor like showing resizing hint for a specific split. */ @@ -251,7 +253,7 @@ public class SplitDecorManager extends WindowlessWindowManager { } /** Stops showing resizing hint. */ - public void onResized(SurfaceControl.Transaction t, Runnable animFinishedCallback) { + public void onResized(SurfaceControl.Transaction t, Consumer animFinishedCallback) { if (mScreenshotAnimator != null && mScreenshotAnimator.isRunning()) { mScreenshotAnimator.cancel(); } @@ -281,7 +283,7 @@ public class SplitDecorManager extends WindowlessWindowManager { mScreenshot = null; if (mRunningAnimationCount == 0 && animFinishedCallback != null) { - animFinishedCallback.run(); + animFinishedCallback.accept(true); } } }); @@ -313,12 +315,12 @@ public class SplitDecorManager extends WindowlessWindowManager { } } if (mShown) { - fadeOutDecor(animFinishedCallback); + fadeOutDecor(()-> animFinishedCallback.accept(true)); } else { // Decor surface is hidden so release it directly. releaseDecor(t); if (mRunningAnimationCount == 0 && animFinishedCallback != null) { - animFinishedCallback.run(); + animFinishedCallback.accept(false); } } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java index a2af93fc42c60..18b86750b3990 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitScreenTransitions.java @@ -237,11 +237,13 @@ class SplitScreenTransitions { mAnimations.add(va); decor.setScreenshotIfNeeded(change.getSnapshot(), startTransaction); - decor.onResized(startTransaction, () -> { - mTransitions.getMainExecutor().execute(() -> { - mAnimations.remove(va); - onFinish(null /* wct */, null /* wctCB */); - }); + decor.onResized(startTransaction, animated -> { + mAnimations.remove(va); + if (animated) { + mTransitions.getMainExecutor().execute(() -> { + onFinish(null /* wct */, null /* wctCB */); + }); + } }); } }