From b3d0379faa1dceb0a2d84a75e85155f2882fc0a5 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Fri, 25 Mar 2022 11:35:01 +0000 Subject: [PATCH] Make sure to release split layout when returning to home When returning to home from recent apps, the splitting tasks were already hidden while performing the recent transition, so dismiss split screen directly without requesting dismiss transition. Also reorder to make sure it collects all clean-up operations before finishing the transition. Fix: 226682648 Bug: 206487881 Test: verify with the repro steps of the bug Change-Id: I05e7ae6fa26631203d652ccb532fb57f532794d7 --- .../splitscreen/SplitScreenTransitions.java | 36 ++++++++++--------- .../shell/splitscreen/StageCoordinator.java | 17 ++++----- 2 files changed, 29 insertions(+), 24 deletions(-) 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 d30d0cc95f465..cd121ed41fdd4 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 @@ -231,6 +231,26 @@ class SplitScreenTransitions { void onFinish(WindowContainerTransaction wct, WindowContainerTransactionCallback wctCB) { if (!mAnimations.isEmpty()) return; + if (mAnimatingTransition == mPendingEnter) { + mPendingEnter = null; + } + if (mPendingDismiss != null && mPendingDismiss.mTransition == mAnimatingTransition) { + mPendingDismiss = null; + } + if (mAnimatingTransition == mPendingRecent) { + // If the clean-up wct is null when finishing recent transition, it indicates it's + // returning to home and thus no need to reorder tasks. + final boolean returnToHome = wct == null; + if (returnToHome) { + wct = new WindowContainerTransaction(); + } + mStageCoordinator.onRecentTransitionFinished(returnToHome, wct, mFinishTransaction); + mPendingRecent = null; + } + mPendingRemoteHandler = null; + mActiveRemoteHandler = null; + mAnimatingTransition = null; + mOnFinish.run(); if (mFinishTransaction != null) { mFinishTransaction.apply(); @@ -241,22 +261,6 @@ class SplitScreenTransitions { mFinishCallback.onTransitionFinished(wct /* wct */, wctCB /* wctCB */); mFinishCallback = null; } - if (mAnimatingTransition == mPendingEnter) { - mPendingEnter = null; - } - if (mPendingDismiss != null && mPendingDismiss.mTransition == mAnimatingTransition) { - mPendingDismiss = null; - } - if (mAnimatingTransition == mPendingRecent) { - // If the wct is not null while finishing recent transition, it indicates it's not - // dismissing split and thus need to reorder split task so they can be on top again. - final boolean dismissSplit = wct == null; - mStageCoordinator.finishRecentAnimation(dismissSplit); - mPendingRecent = null; - } - mPendingRemoteHandler = null; - mActiveRemoteHandler = null; - mAnimatingTransition = null; } // TODO(shell-transitions): real animations diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index b10d50da10bf3..3593eddf4b3b8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -1568,8 +1568,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, logExit(dismissTransition.mReason); // TODO: Have a proper remote for this. Until then, though, reset state and use the // normal animation stuff (which falls back to the normal launcher remote). - setDividerVisibility(false, t); - mSplitLayout.release(); + mSplitLayout.release(t); mSplitTransitions.mPendingDismiss = null; return false; } else { @@ -1595,7 +1594,8 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, return true; } - void finishRecentAnimation(boolean dismissSplit) { + void onRecentTransitionFinished(boolean returnToHome, WindowContainerTransaction wct, + SurfaceControl.Transaction finishT) { // Exclude the case that the split screen has been dismissed already. if (!mMainStage.isActive()) { // The latest split dismissing transition might be a no-op transition and thus won't @@ -1605,13 +1605,14 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, return; } - if (dismissSplit) { - final WindowContainerTransaction wct = new WindowContainerTransaction(); + if (returnToHome) { + // When returning to home from recent apps, the splitting tasks are already hidden, so + // append the reset of dismissing operations into the clean-up wct. prepareExitSplitScreen(STAGE_TYPE_UNDEFINED, wct); - mSplitTransitions.startDismissTransition(null /* transition */, wct, this, - STAGE_TYPE_UNDEFINED, EXIT_REASON_RETURN_HOME); + setSplitsVisible(false); + logExit(EXIT_REASON_RETURN_HOME); } else { - setDividerVisibility(true, null /* t */); + setDividerVisibility(true, finishT); } }