From 833db3b471d0594cbbd38f47e8ae88f821c6ea53 Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Wed, 22 Feb 2023 11:36:34 -0800 Subject: [PATCH] Always execute logic to move desktop apps to front We had an optimization in bringDesktopAppsToFront to skip it when we detect that all tasks are already visible. This method was being called in two cases, when showing desktop tasks or when moving an existing task to desktop. We were already skipping this optimization when showing desktop tasks using the force arg. Also, when moving a task to desktop, this optimization was not actually used. As we only move a task to desktop when switching a fullscreen task to desktop. And in this case no other desktop task is visible. Removing this optimization also fixes a bug where moving a task to desktop can result in a fullscreen task remaining visible in the back. The reason is that bringDesktopAppsToFront also is responsible for ensuring that the launcher task is at the right location. And the optimization caused us to skip it. Bug: 269663000 Test: atest DesktopTasksControllerTest Change-Id: I8d9ba762c22ea1fed5fcf955b7098d8747cd553a --- .../shell/desktopmode/DesktopTasksController.kt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt index fce013837f018..73a7403810903 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt @@ -85,7 +85,7 @@ class DesktopTasksController( fun showDesktopApps() { ProtoLog.v(WM_SHELL_DESKTOP_MODE, "showDesktopApps") val wct = WindowContainerTransaction() - bringDesktopAppsToFront(wct, force = true) + bringDesktopAppsToFront(wct) // Execute transaction if there are pending operations if (!wct.isEmpty) { @@ -156,19 +156,9 @@ class DesktopTasksController( ?: WINDOWING_MODE_UNDEFINED } - private fun bringDesktopAppsToFront(wct: WindowContainerTransaction, force: Boolean = false) { - val activeTasks = desktopModeTaskRepository.getActiveTasks() - - // Skip if all tasks are already visible - if (!force && activeTasks.all(desktopModeTaskRepository::isVisibleTask)) { - ProtoLog.d( - WM_SHELL_DESKTOP_MODE, - "bringDesktopAppsToFront: active tasks are already in front, skipping." - ) - return - } - + private fun bringDesktopAppsToFront(wct: WindowContainerTransaction) { ProtoLog.v(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront") + val activeTasks = desktopModeTaskRepository.getActiveTasks() // First move home to front and then other tasks on top of it moveHomeTaskToFront(wct)