From c4b8e300d7b447f707a99242450e661cfa34c17c Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Tue, 3 Jan 2023 16:33:03 -0800 Subject: Always bring desktop tasks to front When showDesktop API is called, always bring desktop tasks to front. And ignore the visibility status of the tasks. Fixes an issue with launching desktop tasks from launcher when they are already visible. Skipping the reorder calls causes second invoke from launcher to hide all tasks. Bug: 263264985 Test: atest DesktopModeControllerTest DesktopTasksControllerTest Change-Id: Iaf5b77e24b75bf8dc8f1daeb749fa0e8e71fb232 --- .../shell/desktopmode/DesktopModeController.java | 21 +++++++------ .../wm/shell/desktopmode/DesktopTasksController.kt | 7 ++--- .../desktopmode/DesktopModeControllerTest.java | 15 ++++++++-- .../desktopmode/DesktopTasksControllerTest.kt | 34 ++++++++++++++++++++-- 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java index f5f3573252ec..63b03ab76aac 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeController.java @@ -251,7 +251,8 @@ public class DesktopModeController implements RemoteCallable activeTasks = mDesktopModeTaskRepository.getActiveTasks(); ProtoLog.d(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront: tasks=%s", activeTasks.size()); @@ -278,12 +279,14 @@ public class DesktopModeController implements RemoteCallable mDesktopModeTaskRepository.isVisibleTask(info.taskId)); - if (allActiveTasksAreVisible) { - ProtoLog.d(WM_SHELL_DESKTOP_MODE, - "bringDesktopAppsToFront: active tasks are already in front, skipping."); - return wct; + if (!force) { + final boolean allActiveTasksAreVisible = taskInfos.stream() + .allMatch(info -> mDesktopModeTaskRepository.isVisibleTask(info.taskId)); + if (allActiveTasksAreVisible) { + ProtoLog.d(WM_SHELL_DESKTOP_MODE, + "bringDesktopAppsToFront: active tasks are already in front, skipping."); + return wct; + } } ProtoLog.d(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront: reordering all active tasks to the front"); @@ -354,7 +357,7 @@ public class DesktopModeController implements RemoteCallable