From df34aeadf66a77395c55f23fad235b72af790408 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 29 May 2023 17:02:57 +0800 Subject: [PATCH] Handle split to pip if open another fullscreen app case When this case, because the pip task is outside split root so we will start dismiss transition and bring another side stage to top. It cause transition weird and also caused the target opening task not on top due to we try to bring another side task to top. Fix this by add another specific logic to handle this. In this case , we should dismiss split but do not bring any side to top. Bug: 282894249 Test: manual Test: pass existing tests Change-Id: I8855473f60b58290ad6eac1a005f719b2a5125d4 --- .../shell/splitscreen/StageCoordinator.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 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 b2526ee97a210..5e9f3c0e4b1d1 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 @@ -24,6 +24,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW; +import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.content.res.Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.RemoteAnimationTarget.MODE_OPENING; @@ -2406,6 +2407,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, if (change.getMode() == TRANSIT_CHANGE && (change.getFlags() & FLAG_IS_DISPLAY) != 0) { mSplitLayout.update(startTransaction); + record.mContainDisplayChange = true; } final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); @@ -2435,7 +2437,13 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, continue; } final StageTaskListener stage = getStageOfTask(taskInfo); - if (stage == null) continue; + if (stage == null) { + if (change.getParent() == null && !isClosingType(change.getMode()) + && taskInfo.getWindowingMode() == WINDOWING_MODE_PINNED) { + record.mContainShowPipChange = true; + } + continue; + } if (isOpeningType(change.getMode())) { if (!stage.containsTask(taskInfo.taskId)) { Log.w(TAG, "Expected onTaskAppeared on " + stage + " to have been called" @@ -2450,13 +2458,22 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } } - // 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 dismissStages = record.getShouldDismissedStage(); - if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0 + if (!record.mContainDisplayChange && record.mContainShowPipChange) { + // This occurred when split enter pip by open another fullscreen app so let + // pip tranistion handler to handle this but also start our dismiss transition. + // TODO(b/282894249): Should improve this case animation on pip. + final WindowContainerTransaction wct = new WindowContainerTransaction(); + prepareExitSplitScreen(STAGE_TYPE_UNDEFINED, wct); + mSplitTransitions.startDismissTransition(wct, this, STAGE_TYPE_UNDEFINED, + EXIT_REASON_CHILD_TASK_ENTER_PIP); + } else if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0 || dismissStages.size() == 1) { + // 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. Log.e(TAG, "Somehow removed the last task in a stage outside of a proper " + "transition."); final WindowContainerTransaction wct = new WindowContainerTransaction(); @@ -2473,7 +2490,6 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, // TODO(b/184679596): Find a way to either include task-org information in // the transition, or synchronize task-org callbacks. } - // Use normal animations. return false; } else if (mMixedHandler != null && TransitionUtil.hasDisplayChange(info)) { @@ -2490,6 +2506,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } static class StageChangeRecord { + boolean mContainDisplayChange = false; + boolean mContainShowPipChange = false; static class StageChange { final StageTaskListener mStageTaskListener; final IntArray mAddedTaskId = new IntArray();