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

Commit c290de66 authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Handle task closing only when we are in desktop." into main

parents 764fb203 3018b8b0
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1108,16 +1108,21 @@ class DesktopTasksController(
    /** Handle task closing by removing wallpaper activity if it's the last active task */
    private fun handleTaskClosing(task: RunningTaskInfo): WindowContainerTransaction? {
        logV("handleTaskClosing")
        if (!isDesktopModeShowing(task.displayId))
            return null

        val wct = WindowContainerTransaction()
        if (taskRepository.isOnlyVisibleNonClosingTask(task.taskId)
            && taskRepository.wallpaperActivityToken != null) {
            && taskRepository.wallpaperActivityToken != null
        ) {
            // Remove wallpaper activity when the last active task is removed
            removeWallpaperActivity(wct)
        }
        taskRepository.addClosingTask(task.displayId, task.taskId)
        // If a CLOSE or TO_BACK is triggered on a desktop task, remove the task.
        if (DesktopModeFlags.BACK_NAVIGATION.isEnabled(context) &&
            taskRepository.isVisibleTask(task.taskId)) {
            taskRepository.isVisibleTask(task.taskId)
        ) {
            wct.removeTask(task.token)
        }
        return if (wct.isEmpty) null else wct
+13 −0
Original line number Diff line number Diff line
@@ -1818,6 +1818,19 @@ class DesktopTasksControllerTest : ShellTestCase() {
    assertNotNull(result, "Should handle request").assertRemoveAt(0, task.token)
  }

  @Test
  @EnableFlags(
    Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY,
  )
  fun handleRequest_backTransition_singleTaskNoToken_withWallpaper_notInDesktop_doesNotHandle() {
    val task = setUpFreeformTask()
    markTaskHidden(task)

    val result = controller.handleRequest(Binder(), createTransition(task, type = TRANSIT_TO_BACK))

    assertNull(result, "Should not handle request")
  }

  @Test
  @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY)
  @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION)