Show desktop tasks when taskbar is pinned on home

Updates taskbar and KQS to show (running) desktop tasks when taskbar is
shown on the home screen - adds `shouldShowDesktopTasksInTaskbar` method
to TaskbarDesktopModeController to be used instead of
`areDesktopTasksVisible*()` to determine whether to show desktop tasks
in the taskbar. The method, in addition to desktop tasks visibility,
also considers whether taskbar should be shown on the home screen, and
whether current launcher state is home.

The launcher state is fetched from `TaskbarStashController`, which
already keeps track of this state. This is likely not ideal, but can be
removed in the long term - see http://b/390665752.

Furthermore, updates ReventsModel login not to always filter out desktop
tasks with no non-minimized tasks (which is currently expected behavior
in overview) in `getTasks()`. The filtering is now done by the filter
passed to `getTasks()` method, instead of when processing tasks in the
background. The filter used by default is updated to filter out such
desktop tasks, but callsites from `KeyboardQuickSwitchController` and
`TaskbarRecentAppsController` are updated to use an empty filter, so
they can display desktop tasks when they're all minimized.

Bug: 376711722
Bug: 390665160
Test: Manual on desktop device - verify that taskbar and KQS when shown
on home screen display desktop tasks, including the case all tasks are
minimized.
Flag: com.android.window.flags.enter_desktop_by_default_on_freeform_displays

Change-Id: Iabc22e20bf64aa9a826b4a5952f1edc6ea639cdc
This commit is contained in:
Toni Barzic
2025-01-17 23:05:14 +00:00
parent bd3228ef8e
commit f817372651
10 changed files with 117 additions and 47 deletions
@@ -28,6 +28,7 @@ import com.android.launcher3.R;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayDragLayer;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.RecentsFilterState;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.util.DesktopTask;
import com.android.quickstep.util.GroupTask;
@@ -153,6 +154,8 @@ public final class KeyboardQuickSwitchController implements
// Skip the task reload if the list is not changed.
if (!mModel.isTaskListValid(mTaskListChangeId) || !taskIdsToExclude.equals(
mExcludedTaskIds)) {
final boolean shouldShowDesktopTasks = mControllers.taskbarDesktopModeController
.shouldShowDesktopTasksInTaskbar();
mExcludedTaskIds = taskIdsToExclude;
mTaskListChangeId = mModel.getTasks((tasks) -> {
processLoadedTasks(tasks, taskIdsToExclude);
@@ -162,7 +165,8 @@ public final class KeyboardQuickSwitchController implements
currentFocusIndexOverride,
mHasDesktopTask,
mWasDesktopTaskFilteredOut);
});
}, shouldShowDesktopTasks ? RecentsFilterState.EMPTY_FILTER
: RecentsFilterState.getEmptyDesktopTaskFilter());
}
mQuickSwitchViewController.updateLayoutForSurface(wasOpenedFromTaskbar,
@@ -188,8 +192,8 @@ public final class KeyboardQuickSwitchController implements
mQuickSwitchViewController = new KeyboardQuickSwitchViewController(
mControllers, mOverlayContext, keyboardQuickSwitchView, mControllerCallbacks);
final boolean onDesktop = mControllers.taskbarDesktopModeController
.getAreDesktopTasksVisibleAndNotInOverview();
final boolean shouldShowDesktopTasks = mControllers.taskbarDesktopModeController
.shouldShowDesktopTasksInTaskbar();
if (mModel.isTaskListValid(mTaskListChangeId)
&& taskIdsToExclude.equals(mExcludedTaskIds)) {
@@ -201,7 +205,7 @@ public final class KeyboardQuickSwitchController implements
/* updateTasks= */ false,
currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning()
? 0 : currentFocusedIndex,
onDesktop,
shouldShowDesktopTasks,
mHasDesktopTask,
mWasDesktopTaskFilteredOut,
wasOpenedFromTaskbar);
@@ -219,11 +223,12 @@ public final class KeyboardQuickSwitchController implements
/* updateTasks= */ true,
currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning()
? 0 : currentFocusedIndex,
onDesktop,
shouldShowDesktopTasks,
mHasDesktopTask,
mWasDesktopTaskFilteredOut,
wasOpenedFromTaskbar);
});
}, shouldShowDesktopTasks ? RecentsFilterState.EMPTY_FILTER
: RecentsFilterState.getEmptyDesktopTaskFilter());
}
private boolean shouldExcludeTask(GroupTask task, Set<Integer> taskIdsToExclude) {
@@ -233,7 +238,7 @@ public final class KeyboardQuickSwitchController implements
private void processLoadedTasks(List<GroupTask> tasks, Set<Integer> taskIdsToExclude) {
mHasDesktopTask = false;
mWasDesktopTaskFilteredOut = false;
if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisibleAndNotInOverview()) {
if (mControllers.taskbarDesktopModeController.shouldShowDesktopTasksInTaskbar()) {
processLoadedTasksOnDesktop(tasks, taskIdsToExclude);
} else {
processLoadedTasksOutsideDesktop(tasks, taskIdsToExclude);