From 3fee149ed07f8211cca39445d5f06212e1a7c96f Mon Sep 17 00:00:00 2001 From: Jeff Chang Date: Tue, 11 Apr 2023 18:53:31 +0800 Subject: [PATCH] Exit split if one of the split is empty IllegalStateException is thrown if one of the splits is empty during start animaiton. This CL performs the split dismiss action instead of making the system-ui crash. Bug: 273426456 Test: make a split with map app. start a full screen on top. Change-Id: I5d2cae97187bb45df7b550cc99980c1aa792df2d --- .../wm/shell/splitscreen/StageCoordinator.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 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 dd91a37039e42..4fd1f8b1b53c8 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 @@ -2321,9 +2321,14 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0) { - // TODO(shell-transitions): Implement a fallback behavior for now. - throw new IllegalStateException("Somehow removed the last task in a stage" - + " outside of a proper transition"); + Log.e(TAG, "Somehow removed the last task in a stage outside of a proper " + + "transition."); + final WindowContainerTransaction wct = new WindowContainerTransaction(); + final int dismissTop = mMainStage.getChildCount() == 0 + ? STAGE_TYPE_MAIN : STAGE_TYPE_SIDE; + prepareExitSplitScreen(dismissTop, wct); + mSplitTransitions.startDismissTransition(wct, this, dismissTop, + EXIT_REASON_UNKNOWN); // This can happen in some pathological cases. For example: // 1. main has 2 tasks [Task A (Single-task), Task B], side has one task [Task C] // 2. Task B closes itself and starts Task A in LAUNCH_ADJACENT at the same time