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

Commit 3018b8b0 authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Handle task closing only when we are in desktop.

We used to handle task closing outside of desktop as well. This resulted
in adding tasks into closing list even when they were outside of
desktop. This would result in empty desktop state in some cases.

Test: atest DesktopTasksControllerTest
Fix: 358552898
Flag: EXEMPT Bug fix
Change-Id: I31c1ef5108e3f400fe6518a9fe7dea1919dbd049
parent fc53eaec
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1090,16 +1090,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
@@ -1658,6 +1658,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)