From 6ab2786d16c128acd4d3c5218a10f929126be31c Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 18 May 2023 10:43:17 -0700 Subject: [PATCH] Separate code paths to launch split from existing pair vs new pair * Launching existing pair doesn't rely on any existing data/state in SplitSelectStateController or SplitSelectDataHolder * Consolidate launchTask*() methods in GroupedTaskView Test: TaskThumbnailViews measured correctly, animation correct on small+large screen, initiating split still working Fixes: 274540670 Flag: none needed Change-Id: Id359f53ac5f2bba19948d4ae3231092fb90cc7c5 --- .../uioverrides/QuickstepLauncher.java | 3 +- .../util/SplitSelectStateController.java | 71 +++++++++++-------- .../quickstep/views/GroupedTaskView.java | 18 +++-- 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 79a301a88c..95c2326765 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -1282,7 +1282,8 @@ public class QuickstepLauncher extends Launcher { getActivityLaunchOptions(taskView, null).options)); return; } - mSplitSelectStateController.launchTasks( + mSplitSelectStateController.launchExistingSplitPair( + null /* launchingTaskView */, groupTask.task1.key.id, groupTask.task2.key.id, SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT, diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index da81410c7a..ee51af7a5d 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -297,36 +297,6 @@ public class SplitSelectStateController { } } - /** - * To be called when we want to launch split pairs from an existing GroupedTaskView. - */ - public void launchTasks(GroupedTaskView groupedTaskView, Consumer callback, - boolean freezeTaskList) { - mLaunchingTaskView = groupedTaskView; - TaskView.TaskIdAttributeContainer[] taskIdAttributeContainers = - groupedTaskView.getTaskIdAttributeContainers(); - launchTasks(taskIdAttributeContainers[0].getTask().key.id, - taskIdAttributeContainers[1].getTask().key.id, - taskIdAttributeContainers[0].getStagePosition(), callback, freezeTaskList, - groupedTaskView.getSplitRatio()); - } - - /** - * To be called when we want to launch split pairs from Overview when split is initiated from - * Overview. - */ - public void launchTasks(int taskId1, int taskId2, @StagePosition int stagePosition, - Consumer callback, boolean freezeTaskList, float splitRatio) { - if (FeatureFlags.ENABLE_SPLIT_LAUNCH_DATA_REFACTOR.get()) { - mSplitSelectDataHolder.setInitialTaskSelect(null /*intent*/, - stagePosition, null /*itemInfo*/, null /*splitEvent*/, - taskId1); - mSplitSelectDataHolder.setSecondTask(taskId2); - } - launchTasks(taskId1, null /* intent1 */, taskId2, null /* intent2 */, stagePosition, - callback, freezeTaskList, splitRatio, null); - } - /** * To be called when we want to launch split pairs from Overview. Split can be initiated from * either Overview or home, or all apps. Either both taskIds are set, or a pending intent + a @@ -510,6 +480,47 @@ public class SplitSelectStateController { } } + /** + * Used to launch split screen from a split pair that already exists (usually accessible through + * Overview). This is different than + * {@link #launchTasks(int, Intent, int, Intent, int, Consumer, boolean, float, InstanceId)} in + * that this only launches split screen that are existing tasks. This doesn't determine which + * API should be used (i.e. launching split with existing tasks vs intents vs shortcuts, etc). + * + *

+ * NOTE: This is not to be used to launch AppPairs. + */ + public void launchExistingSplitPair(@Nullable GroupedTaskView groupedTaskView, + int firstTaskId, int secondTaskId, @StagePosition int stagePosition, + Consumer callback, boolean freezeTaskList, float splitRatio) { + mLaunchingTaskView = groupedTaskView; + final ActivityOptions options1 = ActivityOptions.makeBasic(); + if (freezeTaskList) { + options1.setFreezeRecentTasksReordering(); + } + Bundle optionsBundle = options1.toBundle(); + + if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) { + final RemoteSplitLaunchTransitionRunner animationRunner = + new RemoteSplitLaunchTransitionRunner(firstTaskId, secondTaskId, callback); + final RemoteTransition remoteTransition = new RemoteTransition(animationRunner, + ActivityThread.currentActivityThread().getApplicationThread(), + "LaunchSplitPair"); + mSystemUiProxy.startTasks(firstTaskId, optionsBundle, secondTaskId, + null /* options2 */, stagePosition, splitRatio, + remoteTransition, null /*shellInstanceId*/); + } else { + final RemoteSplitLaunchAnimationRunner animationRunner = + new RemoteSplitLaunchAnimationRunner(firstTaskId, secondTaskId, callback); + final RemoteAnimationAdapter adapter = new RemoteAnimationAdapter( + animationRunner, 300, 150, + ActivityThread.currentActivityThread().getApplicationThread()); + mSystemUiProxy.startTasksWithLegacyTransition(firstTaskId, optionsBundle, + secondTaskId, null /* options2 */, stagePosition, + splitRatio, adapter, null /*shellInstanceId*/); + } + } + private void launchIntentOrShortcut(Intent intent, UserHandle user, ActivityOptions options1, int taskId, @StagePosition int stagePosition, float splitRatio, RemoteTransition remoteTransition, @Nullable InstanceId shellInstanceId) { diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index c6c84bd17d..c91b18347c 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -223,13 +223,11 @@ public class GroupedTaskView extends TaskView { // Callbacks run from remote animation when recents animation not currently running InteractionJankMonitorWrapper.begin(this, InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER, "Enter form GroupedTaskView"); - recentsView.getSplitSelectController().launchTasks(this /*groupedTaskView*/, - success -> { - endCallback.executeAllAndDestroy(); - InteractionJankMonitorWrapper.end( - InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER); - }, - false /* freezeTaskList */); + launchTask(success -> { + endCallback.executeAllAndDestroy(); + InteractionJankMonitorWrapper.end( + InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER); + }, false /* freezeTaskList */); // Callbacks get run from recentsView for case when recents animation already running recentsView.addSideTaskLaunchCallback(endCallback); @@ -238,9 +236,9 @@ public class GroupedTaskView extends TaskView { @Override public void launchTask(@NonNull Consumer callback, boolean isQuickswitch) { - getRecentsView().getSplitSelectController().launchTasks(mTask.key.id, mSecondaryTask.key.id, - SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT, callback, isQuickswitch, - getSplitRatio()); + getRecentsView().getSplitSelectController().launchExistingSplitPair(this, mTask.key.id, + mSecondaryTask.key.id, SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT, + callback, isQuickswitch, getSplitRatio()); } @Override