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

Commit 87a79d3a authored by Jeff Chang's avatar Jeff Chang
Browse files

Start activity with focus root task for staged split

During the start activity process, the system will get a launch root
task to launch activity. The root tasks are created as a direct child
of a TDA, unless there is a launch-root-task set where the created
task would be a child task of the launch-root-task.

This CL make activity can start with a focus root task which is
created by the task organizer and has an adjacent task. For
legacy split screens, this CL doesn't change the original behavior.

Bug: 180079028
Test: atest MultiWindowTests
      atest TaskDisplayAreaTests
Change-Id: Idf62ec2489eb1f05baddd3b527a0afc868426251
parent 20f2cdd3
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1274,7 +1274,15 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {

        for (int i = mLaunchRootTasks.size() - 1; i >= 0; --i) {
            if (mLaunchRootTasks.get(i).contains(windowingMode, activityType)) {
                return mLaunchRootTasks.get(i).task;
                final Task launchRootTask = mLaunchRootTasks.get(i).task;
                // Return the focusable root task for improving the UX with staged split screen.
                final Task adjacentRootTask = launchRootTask != null
                        ? launchRootTask.mAdjacentTask : null;
                if (adjacentRootTask != null && adjacentRootTask.isFocusedRootTaskOnDisplay()) {
                    return adjacentRootTask;
                } else {
                    return launchRootTask;
                }
            }
        }
        return null;
+23 −0
Original line number Diff line number Diff line
@@ -100,6 +100,29 @@ public class TaskDisplayAreaTests extends WindowTestsBase {
        assertNull(actualRootTask);
    }

    @Test
    public void getLaunchRootTask_checksFocusedRootTask() {
        final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
        final Task rootTask = createTaskWithActivity(
                taskDisplayArea,
                WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD, ON_TOP, true);
        rootTask.mCreatedByOrganizer = true;

        final Task adjacentRootTask = createTask(
                mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD);
        adjacentRootTask.mCreatedByOrganizer = true;
        adjacentRootTask.mAdjacentTask = rootTask;
        rootTask.mAdjacentTask = adjacentRootTask;

        taskDisplayArea.setLaunchRootTask(rootTask,
                new int[]{WINDOWING_MODE_MULTI_WINDOW}, new int[]{ACTIVITY_TYPE_STANDARD});

        Task actualRootTask = taskDisplayArea.getLaunchRootTask(
                WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD, null /* options */,
                null /* sourceTask */, 0 /*launchFlags*/);
        assertTrue(actualRootTask.isFocusedRootTaskOnDisplay());
    }

    @Test
    public void getLaunchRootTask_fromLaunchAdjacentFlagRoot_checksAdjacentRoot() {
        final ActivityRecord activity = createNonAttachedActivityRecord(mDisplayContent);