Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 258019fe authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge "Separate code paths to launch split from existing pair vs new pair" into udc-dev

parents bc4813af 6ab2786d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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,
+41 −30
Original line number Diff line number Diff line
@@ -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<Boolean> 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<Boolean> 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).
     *
     * <p/>
     * NOTE: This is not to be used to launch AppPairs.
     */
    public void launchExistingSplitPair(@Nullable GroupedTaskView groupedTaskView,
            int firstTaskId, int secondTaskId, @StagePosition int stagePosition,
            Consumer<Boolean> 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) {
+8 −10
Original line number Diff line number Diff line
@@ -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 -> {
        launchTask(success -> {
            endCallback.executeAllAndDestroy();
            InteractionJankMonitorWrapper.end(
                    InteractionJankMonitorWrapper.CUJ_SPLIT_SCREEN_ENTER);
                },
                false /* freezeTaskList */);
        }, 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<Boolean> 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