diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index d4213e59dd..1595a0f3a5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -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 taskIdsToExclude) { @@ -246,11 +248,12 @@ public final class KeyboardQuickSwitchController implements && task.getTasks().stream().anyMatch(t -> taskIdsToExclude.contains(t.key.id)); } - private void processLoadedTasks(List tasks, Set taskIdsToExclude) { + private void processLoadedTasks(boolean openedFromTaskbar, List tasks, + Set taskIdsToExclude) { mHasDesktopTask = false; mWasDesktopTaskFilteredOut = false; - if (enableAltTabKqsFlatenning.isTrue()) { + if (enableAltTabKqsFlatenning.isTrue() && !openedFromTaskbar) { processLoadedTasksCombined(tasks, taskIdsToExclude); } else if (mControllers.taskbarDesktopModeController.shouldShowDesktopTasksInTaskbar()) { processLoadedTasksOnDesktop(tasks, taskIdsToExclude); diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt index a23ebe9914..7aa9640827 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt @@ -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..), + 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..) { - val tasks = - packages.mapIndexed({ index, p -> + createFullscreenAndDesktopTasksFromPackages(emptyList(), packages) + } + + private fun createFullscreenAndDesktopTasksFromPackages( + fullscreenPackages: List, + desktopPackages: List, + ) { + val defaultDisplayId = context.virtualDisplay.display.displayId + val tasks: List = + 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() } }