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

Commit c2a8374d authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Make sure tasks are launched on the right display in desktop mode.

The task was launched on the default display, but with transitions that
expected a specified display, leading to weird result (e.g. full screen
on external display). Setting the display seems to solve
that issue.

Bug: 403506870
Flag: com.android.window.flags.enable_start_launch_transition_from_taskbar_bugfix
Test: atest DesktopTasksControllerTest
Test: Build and run
Change-Id: I1648d1bc1cc56db0e381cc31f6954cbec34cff23
parent 21ba4f2b
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -835,7 +835,9 @@ class DesktopTasksController(
            val requestRes = transitions.dispatchRequest(Binder(), requestInfo, /* skip= */ null)
            wct.merge(requestRes.second, true)

            desktopPipTransitionObserver.get().addPendingPipTransition(
            desktopPipTransitionObserver
                .get()
                .addPendingPipTransition(
                    DesktopPipTransitionObserver.PendingPipTransition(
                        token = freeformTaskTransitionStarter.startPipTransition(wct),
                        taskId = taskInfo.taskId,
@@ -1208,6 +1210,7 @@ class DesktopTasksController(
                pendingIntentBackgroundActivityStartMode =
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
                launchBounds = bounds
                launchDisplayId = displayId
                if (DesktopModeFlags.ENABLE_SHELL_INITIAL_BOUNDS_REGRESSION_BUG_FIX.isTrue) {
                    // Sets launch bounds size as flexible so core can recalculate.
                    flexibleLaunchSize = true
+31 −0
Original line number Diff line number Diff line
@@ -1525,6 +1525,37 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        assertThat(wct.hierarchyOps).hasSize(1)
    }

    @Test
    fun launchIntent_taskInDesktopMode_onSecondaryDisplay_transitionStarted() {
        setUpLandscapeDisplay()
        taskRepository.addDesk(SECOND_DISPLAY, deskId = 2)
        val intent = Intent().setComponent(homeComponentName)
        whenever(
                desktopMixedTransitionHandler.startLaunchTransition(
                    eq(TRANSIT_OPEN),
                    any(),
                    anyOrNull(),
                    anyOrNull(),
                    anyOrNull(),
                )
            )
            .thenReturn(Binder())

        controller.startLaunchIntentTransition(intent, Bundle.EMPTY, SECOND_DISPLAY)

        val wct = getLatestDesktopMixedTaskWct(type = TRANSIT_OPEN)
        // We expect two actions: open the app and start the desk
        assertThat(wct.hierarchyOps).hasSize(2)
        val hOps0 = wct.hierarchyOps[0]
        val hOps1 = wct.hierarchyOps[1]
        assertThat(hOps0.type).isEqualTo(HIERARCHY_OP_TYPE_PENDING_INTENT)
        val activityOptions0 = ActivityOptions.fromBundle(hOps0.launchOptions)
        assertThat(activityOptions0.launchDisplayId).isEqualTo(SECOND_DISPLAY)
        assertThat(hOps1.type).isEqualTo(HIERARCHY_OP_TYPE_PENDING_INTENT)
        val activityOptions1 = ActivityOptions.fromBundle(hOps1.launchOptions)
        assertThat(activityOptions1.launchDisplayId).isEqualTo(SECOND_DISPLAY)
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS)
    fun addMoveToDeskTaskChanges_landscapeDevice_userFullscreenOverride_defaultPortraitBounds() {