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

Commit a48e2337 authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge "Allow closing tasks even if not inside a desk" into main

parents 121a11cf 84f72306
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1704,13 +1704,14 @@ class DesktopTasksController(
        wct: WindowContainerTransaction,
        displayId: Int,
        taskInfo: RunningTaskInfo,
    ): ((IBinder) -> Unit) {
    ): ((IBinder) -> Unit)? {
        val taskId = taskInfo.taskId
        val userId = taskInfo.userId
        val repository = userRepositories.getProfile(userId)
        val deskId = repository.getDeskIdForTask(taskInfo.taskId)
        if (deskId == null && DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
            error("Did not find desk for task: $taskId")
            logW("onDesktopWindowClose: desk not found for task: $taskId")
            return null
        }
        snapEventHandler.removeTaskIfTiled(displayId, taskId)
        val shouldExitDesktop =
+1 −1
Original line number Diff line number Diff line
@@ -1277,7 +1277,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                        decoration.getTaskInfo().displayId, decoration.getTaskInfo());
        final IBinder transition = mTaskOperations.closeTask(
                decoration.getTaskInfo().token, wct);
        if (transition != null) {
        if (transition != null && runOnTransitionStart != null) {
            runOnTransitionStart.invoke(transition);
        }
    }
+16 −3
Original line number Diff line number Diff line
@@ -4672,6 +4672,19 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        wct.assertWithoutPendingIntent(launchHomeIntent(DEFAULT_DISPLAY))
    }
    @Test
    @EnableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
    fun onDesktopWindowClose_notInDesk_returnsNullOnTransitStart() {
        val task = setUpFreeformTask(deskId = DEFAULT_DESK_ID)
        val wct = WindowContainerTransaction()
        taskRepository.removeDesk(DEFAULT_DESK_ID)
        val runOnTransitStart =
            controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task)
        assertThat(runOnTransitStart).isNull()
    }
    @Test
    fun tilingBroken_onTaskMinimised() {
        val task = setUpFreeformTask()
@@ -4770,7 +4783,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        val transition = Binder()
        val runOnTransitStart =
            controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task)
        runOnTransitStart(transition)
        runOnTransitStart?.invoke(transition)
        verify(desksTransitionsObserver)
            .addPendingTransition(
@@ -4798,7 +4811,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        val transition = Binder()
        val runOnTransitStart =
            controller.onDesktopWindowClose(wct, displayId = DEFAULT_DISPLAY, task)
        runOnTransitStart(transition)
        runOnTransitStart?.invoke(transition)
        verify(desksTransitionsObserver)
            .addPendingTransition(
@@ -12826,7 +12839,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        const val MAX_TASK_LIMIT = 6
        private const val TASKBAR_FRAME_HEIGHT = 200
        private const val FLOAT_TOLERANCE = 0.005f
        private const val DEFAULT_DESK_ID = 100
        private const val DEFAULT_DESK_ID = 0
        // For testing disconnecting a display containing a desk.
        private const val DISCONNECTED_DESK_ID = 200
        private val TASK_BOUNDS = Rect(100, 100, 300, 300)