From b9b3ee62e18f8e5d84ccb2a501d995ca24848ce1 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Thu, 8 Jun 2023 03:35:47 +0000 Subject: [PATCH] Fix split to pip with home-key not dismissing split properly When pressing home-key with auto-pip activity in split screen, it will be handled as a RECENT_DURING_SPLIT transition in DefaultMixedHandler to mix with split transition handler and remote transition handler. However, the auto-pip information will be appended to the transition info and causing DefaultMixedHandler not consuming the transition due to no registered remote transition matched, and fall-through to pip transition handler. This updates DefaultMixedHandler to monitor such transition in startAnimation callback to make sure nofity split transition handler to dismiss split. Fix: 273410079 Test: atest WMShellUtilsTests WMShellFlickerTests Test: enable 3-buttona and compose a split pair with auto-pip activity press home-key to auto-pip and expand the pip window observed there is no split pair in overview panel. Change-Id: I1c931c2beb7feedae571216414ed9f24b0972b3e --- .../shell/splitscreen/StageCoordinator.java | 21 +++++++++---------- .../shell/transition/DefaultMixedHandler.java | 14 +++++++++++++ 2 files changed, 24 insertions(+), 11 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 c5619a016cf90..da14d03adb353 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 @@ -23,7 +23,6 @@ import static android.app.ComponentOptions.KEY_PENDING_INTENT_BACKGROUND_ACTIVIT 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.content.res.Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.RemoteAnimationTarget.MODE_OPENING; @@ -2823,19 +2822,19 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } - mRecentTasks.ifPresent(recentTasks -> { + if (shouldBreakPairedTaskInRecents(dismissReason)) { // Notify recents if we are exiting in a way that breaks the pair, and disable further // updates to splits in the recents until we enter split again - if (shouldBreakPairedTaskInRecents(dismissReason)) { - for (TransitionInfo.Change change : info.getChanges()) { - final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); - if (taskInfo != null - && taskInfo.getWindowingMode() != WINDOWING_MODE_MULTI_WINDOW) { - recentTasks.removeSplitPair(taskInfo.taskId); - } + mRecentTasks.ifPresent(recentTasks -> { + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + final TransitionInfo.Change change = info.getChanges().get(i); + final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); + if (taskInfo != null && getStageOfTask(taskInfo) != null) { + recentTasks.removeSplitPair(taskInfo.taskId); } - } - }); + } + }); + } mSplitRequest = null; // Update local states. diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java index 760023a8e1ff4..cfb87905966ed 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java @@ -24,6 +24,7 @@ import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.window.TransitionInfo.FLAG_IS_WALLPAPER; import static com.android.wm.shell.common.split.SplitScreenConstants.FLAG_IS_DIVIDER_BAR; +import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED; import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_UNDEFINED; import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_CHILD_TASK_ENTER_PIP; import static com.android.wm.shell.util.TransitionUtil.isOpeningType; @@ -303,6 +304,19 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, return animateOpenIntentWithRemoteAndPip(mixed, info, startTransaction, finishTransaction, finishCallback); } else if (mixed.mType == MixedTransition.TYPE_RECENTS_DURING_SPLIT) { + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + final TransitionInfo.Change change = info.getChanges().get(i); + // Pip auto-entering info might be appended to recent transition like pressing + // home-key in 3-button navigation. This offers split handler the opportunity to + // handle split to pip animation. + if (mPipHandler.isEnteringPip(change, info.getType()) + && mSplitHandler.getSplitItemPosition(change.getLastParent()) + != SPLIT_POSITION_UNDEFINED) { + return animateEnterPipFromSplit(mixed, info, startTransaction, + finishTransaction, finishCallback); + } + } + return animateRecentsDuringSplit(mixed, info, startTransaction, finishTransaction, finishCallback); } else if (mixed.mType == MixedTransition.TYPE_KEYGUARD) {