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

Commit 47d92e09 authored by Omar Elmekkawy's avatar Omar Elmekkawy
Browse files

Call removeTaskIfTiled from the right places within the Controller.

handleFreeformTaskLaunch has changed significantly over time,
introducing a bug that made removeTaskIfTiled be called from
the wrong place within the function.

Flag: com.android.window.flags.enable_tile_resizing
Test: Unit tests and on device testing
Bug: 414788320

Change-Id: Ia1dd98c9d9efd03445d28b5cdae6771710315f3e
parent a73c04e8
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1173,7 +1173,7 @@ class DesktopTasksController(
            } else {
                taskRepository.isOnlyVisibleNonClosingTask(taskId = taskId, displayId = displayId)
            }

        snapEventHandler.removeTaskIfTiled(displayId, taskId)
        val isMinimizingToPip =
            DesktopExperienceFlags.ENABLE_DESKTOP_WINDOWING_PIP.isTrue &&
                (taskInfo.pictureInPictureParams?.isAutoEnterEnabled ?: false) &&
@@ -1219,7 +1219,6 @@ class DesktopTasksController(
            val transition = freeformTaskTransitionStarter.startPipTransition(wct)
            desktopExitRunnable?.invoke(transition)
        } else {
            snapEventHandler.removeTaskIfTiled(displayId, taskId)
            val willExitDesktop =
                if (
                    DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue &&
@@ -3035,11 +3034,11 @@ class DesktopTasksController(
        )
        if (taskIdToMinimize != null) {
            addPendingMinimizeTransition(transition, taskIdToMinimize, MinimizeReason.TASK_LIMIT)
            snapEventHandler.removeTaskIfTiled(task.displayId, taskIdToMinimize)
            return wct
        }
        addPendingTaskLimitTransition(transition, deskId, task.taskId)
        if (!wct.isEmpty) {
            snapEventHandler.removeTaskIfTiled(task.displayId, task.taskId)
            return wct
        }
        return null
+18 −0
Original line number Diff line number Diff line
@@ -3987,6 +3987,24 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        assertThat(wct.hierarchyOps).isEmpty()
    }

    @Test
    fun tilingBroken_onTaskMinimised() {
        val task = setUpFreeformTask()
        val transition = Binder()
        whenever(
                freeformTaskTransitionStarter.startMinimizedModeTransition(
                    any(),
                    anyInt(),
                    anyBoolean(),
                )
            )
            .thenReturn(transition)

        controller.minimizeTask(task, MinimizeReason.TASK_LIMIT)

        verify(snapEventHandler, times(1)).removeTaskIfTiled(task.displayId, task.taskId)
    }

    @Test
    fun onDesktopWindowClose_multipleActiveTasks() {
        val task1 = setUpFreeformTask()