Merge "Only need to dismiss stage if one of the task is closed." into udc-dev am: 54d018e1de am: 43084e1b7a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22779458

Change-Id: I7cdb1e3ca41c835655af7999830b8b8155f82515
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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 4d53f5b..4c32040 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
@@ -2419,12 +2419,13 @@
                     }
                 }
             }
-            // If the size of dismissStages > 0, the task is closed without prepare pending
+            // If the size of dismissStages == 1, one of the task is closed without prepare pending
             // transition, which could happen if all activities were finished after finish top
             // activity in a task, so the trigger task is null when handleRequest.
+            // Note if the size of dismissStages == 2, it's starting a new task, so don't handle it.
             final ArraySet<StageTaskListener> dismissStages = record.getShouldDismissedStage();
             if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0
-                    || dismissStages.size() > 0) {
+                    || dismissStages.size() == 1) {
                 Log.e(TAG, "Somehow removed the last task in a stage outside of a proper "
                         + "transition.");
                 final WindowContainerTransaction wct = new WindowContainerTransaction();