Don't cap number of items in taskbar overflow

Updates KQS view not to show fullscreen tasks, and not to cap off number
of items in the view if shown for taskbar overflow.

Bug:419279335
Test: TaskbarOverflowTest
Flag: com.android.window.flags.enable_taskbar_overflow

Change-Id: I771cabc51ffa527b7db83cf12747cf8c4793670d
This commit is contained in:
Toni Barzic
2025-05-29 19:12:50 +00:00
parent a96d9ce82c
commit 229bbf059c
2 changed files with 93 additions and 30 deletions

View File

@@ -169,7 +169,7 @@ public final class KeyboardQuickSwitchController implements
shouldShowDesktopTasks ? RecentsFilterState.EMPTY_FILTER
: RecentsFilterState.getDesktopTaskFilter(),
(tasks) -> {
processLoadedTasks(tasks, taskIdsToExclude);
processLoadedTasks(wasOpenedFromTaskbar, tasks, taskIdsToExclude);
mQuickSwitchViewController.updateQuickSwitchView(
mTasks,
wasOpenedFromTaskbar ? 0 : mNumHiddenTasks,
@@ -223,22 +223,24 @@ public final class KeyboardQuickSwitchController implements
}
mExcludedTaskIds = taskIdsToExclude;
mTaskListChangeId = mModel.getTasks(shouldShowDesktopTasks ? RecentsFilterState.EMPTY_FILTER
: RecentsFilterState.getDesktopTaskFilter(), (tasks) -> {
processLoadedTasks(tasks, taskIdsToExclude);
// Check if the first task is running after the recents model has updated so that we use
// the correct index.
mQuickSwitchViewController.openQuickSwitchView(
mTasks,
wasOpenedFromTaskbar ? 0 : mNumHiddenTasks,
/* updateTasks= */ true,
currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning()
? 0 : currentFocusedIndex,
shouldShowDesktopTasks,
mHasDesktopTask,
mWasDesktopTaskFilteredOut,
wasOpenedFromTaskbar);
});
mTaskListChangeId = mModel.getTasks(
shouldShowDesktopTasks ? RecentsFilterState.EMPTY_FILTER
: RecentsFilterState.getDesktopTaskFilter(),
(tasks) -> {
processLoadedTasks(wasOpenedFromTaskbar, tasks, taskIdsToExclude);
// Check if the first task is running after the recents model has updated so
// that we use the correct index.
mQuickSwitchViewController.openQuickSwitchView(
mTasks,
wasOpenedFromTaskbar ? 0 : mNumHiddenTasks,
/* updateTasks= */ true,
currentFocusedIndex == -1 && !mControllerCallbacks.isFirstTaskRunning()
? 0 : currentFocusedIndex,
shouldShowDesktopTasks,
mHasDesktopTask,
mWasDesktopTaskFilteredOut,
wasOpenedFromTaskbar);
});
}
private boolean shouldExcludeTask(GroupTask task, Set<Integer> taskIdsToExclude) {
@@ -246,11 +248,12 @@ public final class KeyboardQuickSwitchController implements
&& task.getTasks().stream().anyMatch(t -> taskIdsToExclude.contains(t.key.id));
}
private void processLoadedTasks(List<GroupTask> tasks, Set<Integer> taskIdsToExclude) {
private void processLoadedTasks(boolean openedFromTaskbar, List<GroupTask> tasks,
Set<Integer> taskIdsToExclude) {
mHasDesktopTask = false;
mWasDesktopTaskFilteredOut = false;
if (enableAltTabKqsFlatenning.isTrue()) {
if (enableAltTabKqsFlatenning.isTrue() && !openedFromTaskbar) {
processLoadedTasksCombined(tasks, taskIdsToExclude);
} else if (mControllers.taskbarDesktopModeController.shouldShowDesktopTasksInTaskbar()) {
processLoadedTasksOnDesktop(tasks, taskIdsToExclude);

View File

@@ -17,6 +17,7 @@
package com.android.launcher3.taskbar
import android.animation.AnimatorTestRule
import android.app.WindowConfiguration
import android.content.ComponentName
import android.content.Intent
import android.os.Process
@@ -25,7 +26,6 @@ import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import androidx.test.core.app.ApplicationProvider
import com.android.launcher3.BubbleTextView
import com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_FLATENNING
import com.android.launcher3.Flags.FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR
import com.android.launcher3.R
import com.android.launcher3.dagger.LauncherAppSingleton
@@ -358,7 +358,6 @@ class TaskbarOverflowTest {
@Test
@TaskbarMode(PINNED)
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
fun testPressingOverflowButtonOpensKeyboardQuickSwitch() {
val maxNumIconViews = maxNumberOfTaskbarIcons
// Assume there are at least all apps and divider icon, as they would appear once running
@@ -418,7 +417,6 @@ class TaskbarOverflowTest {
@Test
@TaskbarMode(PINNED)
@DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING)
fun testHotseatItemTasksNotShownInKQS() {
val maxNumIconViews = maxNumberOfTaskbarIcons
// Assume there are at least all apps and divider icon, as they would appear once running
@@ -453,6 +451,43 @@ class TaskbarOverflowTest {
.containsExactlyElementsIn(listOf(0) + (2..<createdTasks).toList())
}
@Test
@TaskbarMode(PINNED)
fun testFullscreenTasksNotShownInKQS() {
val maxNumIconViews = maxNumberOfTaskbarIcons
// Assume there are at least all apps and divider icon, as they would appear once running
// apps are added, even if not present initially.
val initialIconCount = currentNumberOfTaskbarIcons.coerceAtLeast(2)
val hotseatItems = createHotseatItems(1)
val targetOverflowSize = 5
val createdTasks = maxNumIconViews - initialIconCount + targetOverflowSize
createFullscreenAndDesktopTasksFromPackages(
listOf("fakeFullscreen"),
listOf("fake") +
listOf(hotseatItems[0]?.targetPackage ?: "") +
List(createdTasks - 2) { "fake" },
)
runOnMainSync {
val taskbarView: TaskbarView =
taskbarUnitTestRule.activityContext.dragLayer.findViewById(R.id.taskbar_view)
taskbarView.updateItems(
recentAppsController.updateHotseatItemInfos(hotseatItems as Array<ItemInfo?>),
recentAppsController.shownTasks,
)
}
tapOverflowIcon()
// Keyboard quick switch view is shown only after list of recent task is asynchronously
// retrieved from the recents model.
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
assertThat(getOnUiThread { keyboardQuickSwitchController.isShownFromTaskbar }).isTrue()
assertThat(getOnUiThread { keyboardQuickSwitchController.shownTaskIds() })
.containsExactlyElementsIn(listOf(1) + (3..<createdTasks + 1).toList())
}
@Test
@TaskbarMode(PINNED)
@EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU)
@@ -578,12 +613,36 @@ class TaskbarOverflowTest {
}
private fun createDesktopTaskWithTasksFromPackages(packages: List<String>) {
val tasks =
packages.mapIndexed({ index, p ->
createFullscreenAndDesktopTasksFromPackages(emptyList(), packages)
}
private fun createFullscreenAndDesktopTasksFromPackages(
fullscreenPackages: List<String>,
desktopPackages: List<String>,
) {
val defaultDisplayId = context.virtualDisplay.display.displayId
val tasks: List<GroupTask> =
fullscreenPackages.mapIndexed({ index, p ->
SingleTask(
Task(
Task.TaskKey(
index,
WindowConfiguration.WINDOWING_MODE_FULLSCREEN,
Intent().apply { `package` = p },
ComponentName(p, ""),
Process.myUserHandle().identifier,
2000,
)
)
)
})
val desktopTasks =
desktopPackages.mapIndexed({ index, p ->
Task(
Task.TaskKey(
index,
0,
index + fullscreenPackages.size,
WindowConfiguration.WINDOWING_MODE_FREEFORM,
Intent().apply { `package` = p },
ComponentName(p, ""),
Process.myUserHandle().identifier,
@@ -592,10 +651,11 @@ class TaskbarOverflowTest {
)
})
val displayId = context.virtualDisplay.display.displayId
recentsModel.updateRecentTasks(listOf(DesktopTask(deskId = 0, displayId, tasks)))
for (task in 1..tasks.size) {
desktopTaskListener?.onTasksVisibilityChanged(displayId, task)
recentsModel.updateRecentTasks(
tasks + listOf(DesktopTask(deskId = 0, defaultDisplayId, desktopTasks))
)
for (task in 1..desktopTasks.size) {
desktopTaskListener?.onTasksVisibilityChanged(defaultDisplayId, task)
}
runOnMainSync { recentsModel.resolvePendingTaskRequests() }
}