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

Commit d58cb67b authored by Louis Chang's avatar Louis Chang
Browse files

Handover launch display id when starting activity from no-display caller

When starting an app on a display, the app was not landed on the requested
display because the application used a trampoline activity that had
consumed the launch display id request. Although the trampoline activity
did launched on the requested display, the same restriction didn’t pass
on to the next activity launch (which from the trampoline activity).

Handover the requested launch display id to next started activity if it
was started from a no-display caller.

Bug: 119592692
Test: atest TaskLaunchParamsModifierTests

Change-Id: Ie9744cf5faf0cc7e8cc79f009b224732110b917f
parent 0ef75b19
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -271,7 +271,10 @@ final class ActivityRecord extends ConfigurationContainer {
    boolean fullscreen; // The activity is opaque and fills the entire space of this task.
    // TODO: See if it possible to combine this with the fullscreen field.
    final boolean hasWallpaper; // Has a wallpaper window as a background.
    final boolean noDisplay;  // activity is not displayed?
    @VisibleForTesting
    boolean noDisplay;  // activity is not displayed?
    @VisibleForTesting
    int mHandoverLaunchDisplayId = INVALID_DISPLAY; // Handover launch display id to next activity.
    private final boolean componentSpecified;  // did caller specify an explicit component?
    final boolean rootVoiceInteraction;  // was this the root activity of a voice interaction?

@@ -1019,6 +1022,8 @@ final class ActivityRecord extends ConfigurationContainer {
            if (useLockTask && lockTaskLaunchMode == LOCK_TASK_LAUNCH_MODE_DEFAULT) {
                lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
            }
            // Gets launch display id from options. It returns INVALID_DISPLAY if not set.
            mHandoverLaunchDisplayId = options.getLaunchDisplayId();
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -305,6 +305,13 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
            displayId = optionLaunchId;
        }

        // If the source activity is a no-display activity, pass on the launch display id from
        // source activity as currently preferred.
        if (displayId == INVALID_DISPLAY && source != null && source.noDisplay) {
            displayId = source.mHandoverLaunchDisplayId;
            if (DEBUG) appendLog("display-from-no-display-source=" + displayId);
        }

        ActivityStack stack =
                (displayId == INVALID_DISPLAY && task != null) ? task.getStack() : null;
        if (stack != null) {
+19 −0
Original line number Diff line number Diff line
@@ -199,6 +199,25 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
        assertEquals(freeformDisplay.mDisplayId, mResult.mPreferredDisplayId);
    }

    @Test
    public void testUsesNoDisplaySourceHandoverDisplayIdIfSet() {
        final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
                WINDOWING_MODE_FREEFORM);
        final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
                WINDOWING_MODE_FULLSCREEN);

        mCurrent.mPreferredDisplayId = fullscreenDisplay.mDisplayId;
        ActivityRecord reusableActivity = createSourceActivity(fullscreenDisplay);
        ActivityRecord source = createSourceActivity(freeformDisplay);
        source.mHandoverLaunchDisplayId = freeformDisplay.mDisplayId;
        source.noDisplay = true;

        assertEquals(RESULT_CONTINUE, mTarget.onCalculate(reusableActivity.getTaskRecord(),
                null /* layout */, mActivity, source, null /* options */, mCurrent, mResult));

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

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