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

Commit 9e9a8a8f authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille Committed by Android (Google) Code Review
Browse files

Merge "Make sure tasks are launched on the right display in desktop mode." into main

parents 99124fb5 c2a8374d
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -859,7 +859,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,
@@ -1232,6 +1234,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() {