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

Commit ab9561c7 authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Remove desktop tasks on back navigation.

This change makes sure that when we get closing type transition(CLOSE or
TO_BACK), the trigger task is removed. As a result is task is removed
from recents. Initial manual testing showed the approach as sound but we
will be monitoring during flag ramp up to make sure we don't miss any
edge cases.

For the tests, altered the current tests to test the following 3
conditions:
- Wallpaper disabled, back nav disabled
- Wallpaper enabled, back nav disabled
- Wallpaper enabled, back nav enabled

Bug; 352266521
Test: atest DesktopTasksControllerTest
Flag: com.android.window.flags.enable_desktop_windowing_back_navigation

Change-Id: I6cccdb9a0c0d31e34f671b9484cc37804fba6fd2
parent 5344f894
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -1048,14 +1048,12 @@ class DesktopTasksController(

    /** Handle task closing by removing wallpaper activity if it's the last active task */
    private fun handleTaskClosing(task: RunningTaskInfo): WindowContainerTransaction? {
        val wct = if (
            desktopModeTaskRepository.isOnlyVisibleNonClosingTask(task.taskId) &&
                desktopModeTaskRepository.wallpaperActivityToken != null
        ) {
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: handleTaskClosing")
        val wct = WindowContainerTransaction()
        if (desktopModeTaskRepository.isOnlyVisibleNonClosingTask(task.taskId)
            && desktopModeTaskRepository.wallpaperActivityToken != null) {
            // Remove wallpaper activity when the last active task is removed
            WindowContainerTransaction().also { wct -> removeWallpaperActivity(wct) }
        } else {
            null
            removeWallpaperActivity(wct)
        }
        if (!desktopModeTaskRepository.addClosingTask(task.displayId, task.taskId)) {
            // Could happen if the task hasn't been removed from closing list after it disappeared
@@ -1065,7 +1063,12 @@ class DesktopTasksController(
                task.taskId
            )
        }
        return wct
        // If a CLOSE or TO_BACK is triggered on a desktop task, remove the task.
        if (Flags.enableDesktopWindowingBackNavigation() &&
            desktopModeTaskRepository.isVisibleTask(task.taskId)) {
            wct.removeTask(task.token)
        }
        return if (wct.isEmpty) null else wct
    }

    private fun addMoveToDesktopChanges(
+272 −43

File changed.

Preview size limit exceeded, changes collapsed.