Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipDesktopState.java +3 −3 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public class PipDesktopState { return false; } final int displayId = mPipDisplayLayoutState.getDisplayId(); return getDesktopRepository().getVisibleTaskCount(displayId) > 0 return getDesktopRepository().isAnyDeskActive(displayId) || getDesktopWallpaperActivityTokenProvider().isWallpaperActivityVisible(displayId) || isDisplayInFreeform(); } Loading @@ -100,7 +100,7 @@ public class PipDesktopState { return false; } final DesktopRepository desktopRepository = getDesktopRepository(); return desktopRepository.getVisibleTaskCount(pipTask.getDisplayId()) > 0 return desktopRepository.isAnyDeskActive(pipTask.getDisplayId()) || desktopRepository.isMinimizedPipPresentInDisplay(pipTask.getDisplayId()); } Loading @@ -114,7 +114,7 @@ public class PipDesktopState { return false; } final int displayId = mPipDisplayLayoutState.getDisplayId(); return getDesktopRepository().getVisibleTaskCount(displayId) == 0 return !getDesktopRepository().isAnyDeskActive(displayId) && getDesktopWallpaperActivityTokenProvider().isWallpaperActivityVisible(displayId); } Loading libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +1 −1 Original line number Diff line number Diff line Loading @@ -872,7 +872,7 @@ public class CompatUIController implements OnDisplaysChangedListener, return false; } boolean isDesktopModeShowing = mDesktopUserRepositories.get().getCurrent() .getVisibleTaskCount(taskInfo.displayId) > 0; .isAnyDeskActive(taskInfo.displayId); return DesktopModeFlags.ENABLE_DESKTOP_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE_BUGFIX .isTrue() && isDesktopModeShowing; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandler.kt +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class DesktopActivityOrientationChangeHandler( if (!Flags.respectOrientationChangeForUnresizeable()) return val task = shellTaskOrganizer.getRunningTaskInfo(taskId) ?: return val taskRepository = desktopUserRepositories.current val isDesktopModeShowing = taskRepository.getVisibleTaskCount(task.displayId) > 0 val isDesktopModeShowing = taskRepository.isAnyDeskActive(task.displayId) if (!isDesktopModeShowing || !task.isFreeform || task.isResizeable) return val taskBounds = task.configuration.windowConfiguration.bounds Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +27 −12 Original line number Diff line number Diff line Loading @@ -460,11 +460,15 @@ class DesktopRepository( .singleOrNull() == taskId } /** * Returns the active tasks in the given display's active desk. * * TODO: b/389960283 - migrate callers to [getActiveTaskIdsInDesk]. */ /** Whether the task is the only visible desktop task in the display. */ fun isOnlyVisibleTask(taskId: Int, displayId: Int): Boolean { val desk = desktopData.getActiveDesk(displayId) ?: return false return desk.visibleTasks.size == 1 && desk.visibleTasks.single() == taskId } /** Whether the display has only one visible desktop task. */ fun hasOnlyOneVisibleTask(displayId: Int): Boolean = getVisibleTaskCount(displayId) == 1 @VisibleForTesting fun getActiveTasks(displayId: Int): ArraySet<Int> = ArraySet(desktopData.getActiveDesk(displayId)?.activeTasks) Loading Loading @@ -593,7 +597,7 @@ class DesktopRepository( } else { desk.visibleTasks.remove(taskId) } val newCount = getVisibleTaskCount(deskId) val newCount = getVisibleTaskCountInDesk(deskId) if (prevCount != newCount) { logD( "Update task visibility taskId=%d visible=%b deskId=%d displayId=%d", Loading Loading @@ -777,18 +781,29 @@ class DesktopRepository( } } /** * Gets number of visible freeform tasks on given [displayId]'s active desk. * * TODO: b/389960283 - migrate callers to [getVisibleTaskCountInDesk]. */ /** Whether the display is currently showing any desk. */ fun isAnyDeskActive(displayId: Int): Boolean { if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) { val desk = desktopData.getDefaultDesk(displayId) if (desk == null) { logE("Could not find default desk for display: $displayId") return false } return desk.visibleTasks.isNotEmpty() } return desktopData.getActiveDesk(displayId) != null } /** Gets number of visible freeform tasks on given [displayId]'s active desk. */ @Deprecated("Use isAnyDeskActive() instead.", ReplaceWith("isAnyDeskActive()")) @VisibleForTesting fun getVisibleTaskCount(displayId: Int): Int = (desktopData.getActiveDesk(displayId)?.visibleTasks?.size ?: 0).also { logD("getVisibleTaskCount=$it") } /** Gets the number of visible tasks on the given desk. */ fun getVisibleTaskCountInDesk(deskId: Int): Int = private fun getVisibleTaskCountInDesk(deskId: Int): Int = desktopData.getDesk(deskId)?.visibleTasks?.size ?: 0 /** Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +10 −3 Original line number Diff line number Diff line Loading @@ -337,8 +337,8 @@ class DesktopTasksController( activateDefaultDeskInDisplay(displayId, remoteTransition) } /** Gets number of visible freeform tasks in [displayId]. */ fun visibleTaskCount(displayId: Int): Int = taskRepository.getVisibleTaskCount(displayId) /** Returns whether the given display has an active desk. */ fun isAnyDeskActive(displayId: Int): Boolean = taskRepository.isAnyDeskActive(displayId) /** * Returns true if any of the following is true: Loading @@ -346,9 +346,16 @@ class DesktopTasksController( * - A transparent fullscreen task exists on top in Desktop Mode * - PiP on Desktop Windowing is enabled, there is an active PiP window and the desktop * wallpaper is visible. * * TODO: b/362720497 - consolidate with [isAnyDeskActive]. * - top-transparent-fullscreen case: should not be needed if we allow it to launch inside * the desk in fullscreen instead of force-exiting desktop and having to trick this method * into thinking it is in desktop mode when a task in this state exists. * - PIP case: a PIP presence should influence desk activation, so * [DesktopRepository#isAnyDeskActive] should be sufficient. */ fun isDesktopModeShowing(displayId: Int): Boolean { val hasVisibleTasks = visibleTaskCount(displayId) > 0 val hasVisibleTasks = taskRepository.isAnyDeskActive(displayId) val hasTopTransparentFullscreenTask = taskRepository.getTopTransparentFullscreenTaskId(displayId) != null val hasMinimizedPip = Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PipDesktopState.java +3 −3 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public class PipDesktopState { return false; } final int displayId = mPipDisplayLayoutState.getDisplayId(); return getDesktopRepository().getVisibleTaskCount(displayId) > 0 return getDesktopRepository().isAnyDeskActive(displayId) || getDesktopWallpaperActivityTokenProvider().isWallpaperActivityVisible(displayId) || isDisplayInFreeform(); } Loading @@ -100,7 +100,7 @@ public class PipDesktopState { return false; } final DesktopRepository desktopRepository = getDesktopRepository(); return desktopRepository.getVisibleTaskCount(pipTask.getDisplayId()) > 0 return desktopRepository.isAnyDeskActive(pipTask.getDisplayId()) || desktopRepository.isMinimizedPipPresentInDisplay(pipTask.getDisplayId()); } Loading @@ -114,7 +114,7 @@ public class PipDesktopState { return false; } final int displayId = mPipDisplayLayoutState.getDisplayId(); return getDesktopRepository().getVisibleTaskCount(displayId) == 0 return !getDesktopRepository().isAnyDeskActive(displayId) && getDesktopWallpaperActivityTokenProvider().isWallpaperActivityVisible(displayId); } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +1 −1 Original line number Diff line number Diff line Loading @@ -872,7 +872,7 @@ public class CompatUIController implements OnDisplaysChangedListener, return false; } boolean isDesktopModeShowing = mDesktopUserRepositories.get().getCurrent() .getVisibleTaskCount(taskInfo.displayId) > 0; .isAnyDeskActive(taskInfo.displayId); return DesktopModeFlags.ENABLE_DESKTOP_SKIP_COMPAT_UI_EDUCATION_IN_DESKTOP_MODE_BUGFIX .isTrue() && isDesktopModeShowing; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandler.kt +1 −1 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class DesktopActivityOrientationChangeHandler( if (!Flags.respectOrientationChangeForUnresizeable()) return val task = shellTaskOrganizer.getRunningTaskInfo(taskId) ?: return val taskRepository = desktopUserRepositories.current val isDesktopModeShowing = taskRepository.getVisibleTaskCount(task.displayId) > 0 val isDesktopModeShowing = taskRepository.isAnyDeskActive(task.displayId) if (!isDesktopModeShowing || !task.isFreeform || task.isResizeable) return val taskBounds = task.configuration.windowConfiguration.bounds Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopRepository.kt +27 −12 Original line number Diff line number Diff line Loading @@ -460,11 +460,15 @@ class DesktopRepository( .singleOrNull() == taskId } /** * Returns the active tasks in the given display's active desk. * * TODO: b/389960283 - migrate callers to [getActiveTaskIdsInDesk]. */ /** Whether the task is the only visible desktop task in the display. */ fun isOnlyVisibleTask(taskId: Int, displayId: Int): Boolean { val desk = desktopData.getActiveDesk(displayId) ?: return false return desk.visibleTasks.size == 1 && desk.visibleTasks.single() == taskId } /** Whether the display has only one visible desktop task. */ fun hasOnlyOneVisibleTask(displayId: Int): Boolean = getVisibleTaskCount(displayId) == 1 @VisibleForTesting fun getActiveTasks(displayId: Int): ArraySet<Int> = ArraySet(desktopData.getActiveDesk(displayId)?.activeTasks) Loading Loading @@ -593,7 +597,7 @@ class DesktopRepository( } else { desk.visibleTasks.remove(taskId) } val newCount = getVisibleTaskCount(deskId) val newCount = getVisibleTaskCountInDesk(deskId) if (prevCount != newCount) { logD( "Update task visibility taskId=%d visible=%b deskId=%d displayId=%d", Loading Loading @@ -777,18 +781,29 @@ class DesktopRepository( } } /** * Gets number of visible freeform tasks on given [displayId]'s active desk. * * TODO: b/389960283 - migrate callers to [getVisibleTaskCountInDesk]. */ /** Whether the display is currently showing any desk. */ fun isAnyDeskActive(displayId: Int): Boolean { if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) { val desk = desktopData.getDefaultDesk(displayId) if (desk == null) { logE("Could not find default desk for display: $displayId") return false } return desk.visibleTasks.isNotEmpty() } return desktopData.getActiveDesk(displayId) != null } /** Gets number of visible freeform tasks on given [displayId]'s active desk. */ @Deprecated("Use isAnyDeskActive() instead.", ReplaceWith("isAnyDeskActive()")) @VisibleForTesting fun getVisibleTaskCount(displayId: Int): Int = (desktopData.getActiveDesk(displayId)?.visibleTasks?.size ?: 0).also { logD("getVisibleTaskCount=$it") } /** Gets the number of visible tasks on the given desk. */ fun getVisibleTaskCountInDesk(deskId: Int): Int = private fun getVisibleTaskCountInDesk(deskId: Int): Int = desktopData.getDesk(deskId)?.visibleTasks?.size ?: 0 /** Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +10 −3 Original line number Diff line number Diff line Loading @@ -337,8 +337,8 @@ class DesktopTasksController( activateDefaultDeskInDisplay(displayId, remoteTransition) } /** Gets number of visible freeform tasks in [displayId]. */ fun visibleTaskCount(displayId: Int): Int = taskRepository.getVisibleTaskCount(displayId) /** Returns whether the given display has an active desk. */ fun isAnyDeskActive(displayId: Int): Boolean = taskRepository.isAnyDeskActive(displayId) /** * Returns true if any of the following is true: Loading @@ -346,9 +346,16 @@ class DesktopTasksController( * - A transparent fullscreen task exists on top in Desktop Mode * - PiP on Desktop Windowing is enabled, there is an active PiP window and the desktop * wallpaper is visible. * * TODO: b/362720497 - consolidate with [isAnyDeskActive]. * - top-transparent-fullscreen case: should not be needed if we allow it to launch inside * the desk in fullscreen instead of force-exiting desktop and having to trick this method * into thinking it is in desktop mode when a task in this state exists. * - PIP case: a PIP presence should influence desk activation, so * [DesktopRepository#isAnyDeskActive] should be sufficient. */ fun isDesktopModeShowing(displayId: Int): Boolean { val hasVisibleTasks = visibleTaskCount(displayId) > 0 val hasVisibleTasks = taskRepository.isAnyDeskActive(displayId) val hasTopTransparentFullscreenTask = taskRepository.getTopTransparentFullscreenTaskId(displayId) != null val hasMinimizedPip = Loading