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

Commit 6f57572b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move existing minimized tasks behind Home on fullscreen task launch" into main

parents e1ab7920 10ab4fde
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1070,6 +1070,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
@@ -1349,13 +1349,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