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

Commit 10ab4fde authored by Gustav Sennton's avatar Gustav Sennton
Browse files

Move existing minimized tasks behind Home on fullscreen task launch

Recently we started moving the Home task behind other Desktop tasks on
fullscreen task launch, with this CL we also move existing minimized
tasks behind Home.

Fixes: 357638060
Flag: com.android.window.flags.enable_desktop_windowing_task_limit
Test: DesktopTasksControllerTest
Change-Id: I4660d6fe965fb1720b812315f43fcd72594bd35f
parent 1bb06ef3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1068,6 +1068,11 @@ class DesktopTasksController(
                // In some launches home task is moved behind new task being launched. Make sure
                // that's not the case for launches in desktop.
                moveHomeTask(wct, toTop = false)
                // Move existing minimized tasks behind Home
                taskRepository.getFreeformTasksInZOrder(task.displayId)
                    .filter { taskId -> taskRepository.isMinimizedTask(taskId) }
                    .mapNotNull { taskId -> shellTaskOrganizer.getRunningTaskInfo(taskId) }
                    .forEach { taskInfo -> wct.reorder(taskInfo.token, /* onTop= */ false) }
                // Desktop Mode is already showing and we're launching a new Task - we might need to
                // minimize another Task.
                val taskToMinimize = addAndGetMinimizeChangesIfNeeded(task.displayId, wct, task)
+25 −2
Original line number Diff line number Diff line
@@ -1305,13 +1305,36 @@ class DesktopTasksControllerTest : ShellTestCase() {
    val freeformTasks = (1..MAX_TASK_LIMIT).map { _ -> setUpFreeformTask() }
    freeformTasks.forEach { markTaskVisible(it) }
    val fullscreenTask = createFullscreenTask()
    val homeTask = setUpHomeTask(DEFAULT_DISPLAY)

    val wct = controller.handleRequest(Binder(), createTransition(fullscreenTask))

    // Make sure we reorder the new task to top, and the back task to the bottom
    assertThat(wct!!.hierarchyOps.size).isEqualTo(2)
    assertThat(wct!!.hierarchyOps.size).isEqualTo(3)
    wct.assertReorderAt(0, fullscreenTask, toTop = true)
    wct.assertReorderAt(1, freeformTasks[0], toTop = false)
    wct.assertReorderAt(1, homeTask, toTop = false)
    wct.assertReorderAt(2, freeformTasks[0], toTop = false)
  }

  @Test
  fun handleRequest_fullscreenTaskToFreeform_alreadyBeyondLimit_existingAndNewTasksAreMinimized() {
    assumeTrue(ENABLE_SHELL_TRANSITIONS)

    val minimizedTask = setUpFreeformTask()
    taskRepository.minimizeTask(displayId = DEFAULT_DISPLAY, taskId = minimizedTask.taskId)
    val freeformTasks = (1..MAX_TASK_LIMIT).map { _ -> setUpFreeformTask() }
    freeformTasks.forEach { markTaskVisible(it) }
    val homeTask = setUpHomeTask()
    val fullscreenTask = createFullscreenTask()

    val wct = controller.handleRequest(Binder(), createTransition(fullscreenTask))

    assertThat(wct!!.hierarchyOps.size).isEqualTo(4)
    wct.assertReorderAt(0, fullscreenTask, toTop = true)
    // Make sure we reorder the home task to the bottom, and minimized tasks below the home task.
    wct.assertReorderAt(1, homeTask, toTop = false)
    wct.assertReorderAt(2, minimizedTask, toTop = false)
    wct.assertReorderAt(3, freeformTasks[0], toTop = false)
  }

  @Test