From 76ce5869fc9acbd8b925682d99dc73833bc5aa2c Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Wed, 9 Nov 2022 16:39:42 +0800 Subject: [PATCH] Support back gesture to split pair in background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Split screen will be dismissed right after both sides of the split were occluded. So if users try to use a back-gesture to go back to the previous split pair, it’ll be back to home instead of going back to the split pair. This CL support the split pair in background to make split experience better. Bug: 236317871 Test: atest com.android.wm.shell.SplitLayoutTests Change-Id: I1ead65011ced82e1faa24ccfbc8bf474828fc7dc --- .../wm/shell/splitscreen/StageCoordinator.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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 da8dc8733ef5f..80149996cf6c8 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 @@ -1064,6 +1064,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, wct.setSmallestScreenWidthDp(childrenToTop.mRootTaskInfo.token, SMALLEST_SCREEN_WIDTH_DP_UNDEFINED); } + wct.setReparentLeafTaskIfRelaunch(mRootTaskInfo.token, + false /* reparentLeafTaskIfRelaunch */); mSyncQueue.queue(wct); mSyncQueue.runInSync(t -> { t.setWindowCrop(mMainStage.mRootLeash, null) @@ -1441,16 +1443,19 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, return; } + final WindowContainerTransaction wct = new WindowContainerTransaction(); if (!mainStageVisible) { + wct.setReparentLeafTaskIfRelaunch(mRootTaskInfo.token, + true /* setReparentLeafTaskIfRelaunch */); // Both stages are not visible, check if it needs to dismiss split screen. - if (mExitSplitScreenOnHide - // Don't dismiss split screen when both stages are not visible due to sleeping - // display. - || (!mMainStage.mRootTaskInfo.isSleeping - && !mSideStage.mRootTaskInfo.isSleeping)) { + if (mExitSplitScreenOnHide) { exitSplitScreen(null /* childrenToTop */, EXIT_REASON_RETURN_HOME); } + } else { + wct.setReparentLeafTaskIfRelaunch(mRootTaskInfo.token, + false /* setReparentLeafTaskIfRelaunch */); } + mSyncQueue.queue(wct); mSyncQueue.runInSync(t -> { t.setVisibility(mSideStage.mRootLeash, sideStageVisible) @@ -1571,6 +1576,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mSideStagePosition != SPLIT_POSITION_BOTTOM_OR_RIGHT, EXIT_REASON_APP_FINISHED); } + } else { + exitSplitScreen(null /* childrenToTop */, EXIT_REASON_UNKNOWN); } } else if (isSideStage && hasChildren && !mMainStage.isActive()) { final WindowContainerTransaction wct = new WindowContainerTransaction();