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

Commit 15ef6a2e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use the display of existing task as preferred"

parents a29499da 40750098
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        }

        // STEP 1: Determine the display to launch the activity/task.
        final int displayId = getPreferredLaunchDisplay(options, source, currentParams);
        final int displayId = getPreferredLaunchDisplay(task, options, source, currentParams);
        outParams.mPreferredDisplayId = displayId;
        ActivityDisplay display = mSupervisor.getActivityDisplay(displayId);
        if (DEBUG) {
@@ -268,8 +268,8 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
        return RESULT_CONTINUE;
    }

    private int getPreferredLaunchDisplay(@Nullable ActivityOptions options,
            ActivityRecord source, LaunchParams currentParams) {
    private int getPreferredLaunchDisplay(@Nullable TaskRecord task,
            @Nullable ActivityOptions options, ActivityRecord source, LaunchParams currentParams) {
        int displayId = INVALID_DISPLAY;
        final int optionLaunchId = options != null ? options.getLaunchDisplayId() : INVALID_DISPLAY;
        if (optionLaunchId != INVALID_DISPLAY) {
@@ -283,6 +283,13 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
            displayId = sourceDisplayId;
        }

        ActivityStack stack =
                (displayId == INVALID_DISPLAY && task != null) ? task.getStack() : null;
        if (stack != null) {
            if (DEBUG) appendLog("display-from-task=" + stack.mDisplayId);
            displayId = stack.mDisplayId;
        }

        if (displayId != INVALID_DISPLAY && mSupervisor.getActivityDisplay(displayId) == null) {
            displayId = INVALID_DISPLAY;
        }
+12 −0
Original line number Diff line number Diff line
@@ -167,6 +167,18 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
        assertEquals(fullscreenDisplay.mDisplayId, mResult.mPreferredDisplayId);
    }

    @Test
    public void testUsesTaskDisplayIdIfSet() {
        final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
                WINDOWING_MODE_FREEFORM);
        ActivityRecord source = createSourceActivity(freeformDisplay);

        assertEquals(RESULT_CONTINUE, mTarget.onCalculate(source.getTask(), null /* layout */,
                null /* activity */, null /* source */, null /* options */, mCurrent, mResult));

        assertEquals(freeformDisplay.mDisplayId, mResult.mPreferredDisplayId);
    }

    // =====================================
    // Launch Windowing Mode Related Tests
    // =====================================