From a6951ba7311e286144ed46d6068154a8ddd19788 Mon Sep 17 00:00:00 2001 From: Schneider Victor-Tulias Date: Thu, 17 Apr 2025 15:39:00 -0400 Subject: [PATCH 01/10] Fix broken TaplStartLauncherViaGestureTests close activity flow When trying to destroy the launcher activity in TaplStartLauncherViaGestureTests test cases, we weren't cleaning up the recents window properly. This was also causing following tests to fail since they didn't expect the recents window to already be open. Flag: com.android.launcher3.enable_launcher_overview_in_window Bug: 377678992 Test: pre/postsubmit Change-Id: Ibf568fd1e9abf946c3d3be933b575aa4501828de --- .../android/quickstep/AbstractQuickStepTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java index b059ec4034..f4b13224b6 100644 --- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java +++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java @@ -32,12 +32,14 @@ import com.android.launcher3.ui.AbstractLauncherUiTest; import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.TestUtil; import com.android.launcher3.util.Wait; +import com.android.quickstep.fallback.window.RecentsWindowFlags; import com.android.quickstep.fallback.window.RecentsWindowManager; import com.android.quickstep.views.RecentsView; import org.junit.rules.RuleChain; import org.junit.rules.TestRule; +import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; @@ -57,6 +59,10 @@ public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest f) { + if (!TestHelpers.isInLauncherProcess()) return; + getFromRecentsWindow(recentsWindowManager -> { + f.accept(recentsWindowManager); + return null; + }); + } + // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide // flakiness. protected void waitForRecentsWindowCondition( From af2f3b43ca44b175717d5fc3bdfe968fcc9bda09 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Fri, 18 Apr 2025 17:21:00 +0000 Subject: [PATCH 02/10] Use SplitPosition instead of StagePosition in TaskViewSimulator * Ultimately we want to migrate to SplitIndex, but first we'll slowly remove all usages of StagePosition Test: Compiles Flag: EXEMPT cleanup Bug: 254378592 Change-Id: I44651b4c378dedd4409d99986f7c92371180afd2 --- .../quickstep/util/TaskViewSimulator.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 8f63e804a4..0fb7b4331e 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -20,13 +20,12 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static com.android.launcher3.states.RotationHelper.deltaRotation; import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE; import static com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview; -import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT; -import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; -import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED; -import static com.android.launcher3.util.SplitConfigurationOptions.StagePosition; import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation; import static com.android.quickstep.util.RecentsOrientedState.preDisplayRotation; import static com.android.wm.shell.Flags.enableFlexibleTwoAppSplit; +import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; +import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT; +import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED; import android.animation.TimeInterpolator; import android.content.Context; @@ -56,6 +55,7 @@ import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.recents.utilities.PreviewPositionHelper; import com.android.wm.shell.shared.split.SplitBounds; +import com.android.wm.shell.shared.split.SplitScreenConstants; /** * A utility class which emulates the layout behavior of TaskView and RecentsView @@ -82,8 +82,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { private PointF mPivotOverride = null; private final PointF mPivot = new PointF(); private DeviceProfile mDp; - @StagePosition - private int mStagePosition = STAGE_POSITION_UNDEFINED; + @SplitScreenConstants.SplitPosition + private int mSplitPosition = SPLIT_POSITION_UNDEFINED; private final Matrix mMatrix = new Matrix(); private final Matrix mMatrixTmp = new Matrix(); @@ -184,7 +184,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { // sized task space bounds mTaskRect.set(mFullTaskSize); mOrientationState.getOrientationHandler() - .setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mStagePosition); + .setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mSplitPosition); } else if (mIsDesktopTask) { // For desktop, tasks can take up only part of the screen size. // Full task size represents the whole screen size, but scaled down to fit in recents. @@ -259,12 +259,12 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { setPreview(runningTarget); mSplitBounds = splitInfo; if (mSplitBounds == null) { - mStagePosition = STAGE_POSITION_UNDEFINED; + mSplitPosition = SPLIT_POSITION_UNDEFINED; } else { - mStagePosition = runningTarget.taskId == splitInfo.leftTopTaskId - ? STAGE_POSITION_TOP_OR_LEFT : STAGE_POSITION_BOTTOM_OR_RIGHT; + mSplitPosition = runningTarget.taskId == splitInfo.leftTopTaskId + ? SPLIT_POSITION_TOP_OR_LEFT : SPLIT_POSITION_BOTTOM_OR_RIGHT; if (enableFlexibleTwoAppSplit()) { - mPositionHelper.setSplitBounds(mSplitBounds, mStagePosition); + mPositionHelper.setSplitBounds(mSplitBounds, mSplitPosition); } } calculateTaskSize(); From ac7db52a91365d854ebdfae4cd2e65efac312cb9 Mon Sep 17 00:00:00 2001 From: Mykola Podolian Date: Fri, 18 Apr 2025 17:27:46 -0700 Subject: [PATCH 03/10] Revert^3 "Maximised the taskbar window to the default size" This reverts commit de74f01f01bfe8192032b5c98eb5e387f62a2f8a. Reason for revert: regression Change-Id: Ia21a7bfb5cb98e0219e32d884d773276ba804e6b --- .../taskbar/TaskbarActivityContext.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 3039bfe0fa..1dadfefa98 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -1296,25 +1296,20 @@ public class TaskbarActivityContext extends BaseTaskbarContext { } /** - * Updates the TaskbarContainer size, using the maximum of the provided {@code size} - * and the default size from {@link #getDefaultTaskbarWindowSize()}. + * Updates the TaskbarContainer size (pass {@link #getDefaultTaskbarWindowSize()} to reset). */ public void setTaskbarWindowSize(int size) { // In landscape phone button nav mode, we should set the task bar width instead of height // because this is the only case in which the nav bar is not on the display bottom. - int windowSize = size; - if (windowSize != MATCH_PARENT) { - windowSize = Math.max(size, getDefaultTaskbarWindowSize()); - } boolean landscapePhoneButtonNav = isPhoneButtonNavMode() && mDeviceProfile.isLandscape; if ((landscapePhoneButtonNav ? mWindowLayoutParams.width : mWindowLayoutParams.height) - == windowSize || mIsDestroyed) { + == size || mIsDestroyed) { return; } - if (windowSize == MATCH_PARENT) { - windowSize = mDeviceProfile.heightPx; + if (size == MATCH_PARENT) { + size = mDeviceProfile.heightPx; } else { - mLastRequestedNonFullscreenSize = windowSize; + mLastRequestedNonFullscreenSize = size; if (mIsFullscreen || mIsTaskbarSizeFrozenForAnimatingBubble) { // We either still need to be fullscreen or a bubble is still animating, so defer // any change to our height until setTaskbarWindowFullscreen(false) is called or @@ -1326,14 +1321,14 @@ public class TaskbarActivityContext extends BaseTaskbarContext { } } if (landscapePhoneButtonNav) { - mWindowLayoutParams.width = windowSize; + mWindowLayoutParams.width = size; for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) { - mWindowLayoutParams.paramsForRotation[rot].width = windowSize; + mWindowLayoutParams.paramsForRotation[rot].width = size; } } else { - mWindowLayoutParams.height = windowSize; + mWindowLayoutParams.height = size; for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) { - mWindowLayoutParams.paramsForRotation[rot].height = windowSize; + mWindowLayoutParams.paramsForRotation[rot].height = size; } } mControllers.runAfterInit( From ed04537faa5025e06462823f1b33490483e5540e Mon Sep 17 00:00:00 2001 From: Wen-Chien Wang Date: Tue, 18 Mar 2025 19:02:41 +0000 Subject: [PATCH 04/10] pin-shortcut: Add tests to verify the behavior Bug: 375648361 Test: This is the cl for tests Flag: EXEMPT tests Change-Id: I7209cebcc7e7c34d5f1362121fea5e062e3170de --- .../taskbar/TaskbarPopupController.java | 4 +- .../launcher3/taskbar/TaskbarOverflowTest.kt | 164 ++++++++++++++++++ .../launcher3/taskbar/TaskbarViewTestUtil.kt | 20 ++- 3 files changed, 179 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index f8240720ce..b92357bddc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -32,6 +32,7 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.VisibleForTesting; import com.android.internal.logging.InstanceId; import com.android.launcher3.AbstractFloatingView; @@ -222,7 +223,8 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba } @Nullable - private SystemShortcut createPinShortcut(BaseTaskbarContext target, ItemInfo itemInfo, + @VisibleForTesting + SystemShortcut createPinShortcut(BaseTaskbarContext target, ItemInfo itemInfo, BubbleTextView originalView) { // Predicted items use {@code HotseatPredictionController.PinPrediction} shortcut to pin. if (itemInfo.isPredictedItem()) { 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 dd8d73118e..9966bef7b0 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt @@ -25,11 +25,17 @@ import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import android.view.Display.DEFAULT_DISPLAY import androidx.test.core.app.ApplicationProvider +import com.android.launcher3.BubbleTextView import com.android.launcher3.Flags.FLAG_ENABLE_MULTI_INSTANCE_MENU_TASKBAR import com.android.launcher3.Flags.FLAG_TASKBAR_OVERFLOW import com.android.launcher3.R import com.android.launcher3.dagger.LauncherAppSingleton +import com.android.launcher3.dagger.LauncherComponentProvider.appComponent +import com.android.launcher3.model.BgDataModel import com.android.launcher3.model.data.ItemInfo +import com.android.launcher3.model.data.TaskItemInfo +import com.android.launcher3.model.data.WorkspaceItemInfo +import com.android.launcher3.popup.SystemShortcut import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync import com.android.launcher3.taskbar.TaskbarViewTestUtil.createHotseatItems import com.android.launcher3.taskbar.bubbles.BubbleBarViewController @@ -50,18 +56,24 @@ import com.android.launcher3.util.AllModulesForTest import com.android.launcher3.util.FakePrefsModule import com.android.launcher3.util.LauncherMultivalentJUnit import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices +import com.android.launcher3.util.Preconditions.assertNotNull import com.android.launcher3.util.TestUtil.getOnUiThread import com.android.quickstep.RecentsModel import com.android.quickstep.SystemUiProxy import com.android.quickstep.util.DesktopTask +import com.android.quickstep.util.GroupTask +import com.android.quickstep.util.SingleTask +import com.android.quickstep.util.SingleTask.Companion.createTaskItemInfo import com.android.systemui.shared.recents.model.Task import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_TASKBAR_RUNNING_APPS +import com.android.window.flags.Flags.FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR import com.android.wm.shell.desktopmode.IDesktopTaskListener import com.google.common.truth.Truth.assertThat import dagger.BindsInstance import dagger.Component +import java.util.function.Predicate import org.junit.Before import org.junit.Rule import org.junit.Test @@ -117,6 +129,10 @@ class TaskbarOverflowTest { @InjectController lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController private var desktopTaskListener: IDesktopTaskListener? = null + private val modelCallback = ModelCallbacks() + + private val taskbarContext: TaskbarActivityContext + get() = taskbarUnitTestRule.activityContext private var currentControllerInitCallback: () -> Unit = {} set(value) { @@ -431,6 +447,126 @@ class TaskbarOverflowTest { .containsExactlyElementsIn(listOf(0) + (2..? = null + var hotseatIcon: BubbleTextView? = null + runOnMainSync { + val taskbarView = setUpTaskbarAndModelCallback(hotseatItems) + hotseatIcon = + taskbarView.iconViews.filterIsInstance().first { + it.tag is WorkspaceItemInfo + } + shortcut = + taskbarContext.controllers.taskbarPopupController.createPinShortcut( + taskbarContext, + hotseatIcon!!.tag as ItemInfo, + hotseatIcon, + ) as SystemShortcut<*> + } + assertNotNull(shortcut) + runOnMainSync { shortcut?.onClick(hotseatIcon) } + // After unpinning the first item, only the second app is left. + assertThat(modelCallback.hotseatItems.map { info -> info.title }) + .isEqualTo(listOf("Test App 1")) + // The unpinned app doesn't have a task so the shown tasks won't change. + assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }) + .isEqualTo(listOf(0, 1)) + } + + @Test + @TaskbarMode(PINNED) + @EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU) + fun pinToTaskbarShortcut_unpinPinnedItemWithTask() { + // Create two hotseat items with a task for both of them respectively. + var hotseatItems = + createHotseatItems(2).mapIndexed { idx, item -> TaskItemInfo(idx, item) }.toTypedArray() + createDesktopTaskWithTasksFromPackages(hotseatItems.mapNotNull { it.targetPackage }) + var shortcut: SystemShortcut<*>? = null + var hotseatIcon: BubbleTextView? = null + runOnMainSync { + val taskbarView = setUpTaskbarAndModelCallback(hotseatItems.map { it }.toTypedArray()) + hotseatIcon = + taskbarView.iconViews.filterIsInstance().first { + it.tag is WorkspaceItemInfo + } + shortcut = + taskbarContext.controllers.taskbarPopupController.createPinShortcut( + taskbarContext, + hotseatIcon!!.tag as ItemInfo, + hotseatIcon, + ) as SystemShortcut<*> + } + // Before unpinning the app, both of the apps should be pinned and no shown task available. + assertThat(modelCallback.hotseatItems.map { info -> info.title }) + .isEqualTo(listOf("Test App 0", "Test App 1")) + assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }) + .isEqualTo(emptyList()) + assertNotNull(shortcut) + runOnMainSync { shortcut?.onClick(hotseatIcon) } + // After unpinning the app, app 0 is removed and its task is shown as a recent task. + assertThat(modelCallback.hotseatItems.map { info -> info.title }) + .isEqualTo(listOf("Test App 1")) + assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }).isEqualTo(listOf(0)) + } + + @Test + @TaskbarMode(PINNED) + @EnableFlags(FLAG_ENABLE_PINNING_APP_WITH_CONTEXT_MENU) + fun pinToTaskbarShortcut_pinRecentTask() { + // Create two tasks and two pinned items. + createDesktopTask(2) + val hotseatItems = createHotseatItems(2) + + var shortcut: SystemShortcut<*>? = null + var recentTaskIcon: BubbleTextView? = null + runOnMainSync { + val taskbarView = setUpTaskbarAndModelCallback(hotseatItems) + // Get the first recent task icon + recentTaskIcon = + taskbarView.iconViews.filterIsInstance().first { + it.tag is GroupTask + } + val recentTaskInfo = + createTaskItemInfo( + recentTaskIcon!!.tag as SingleTask, + WorkspaceItemInfo().apply { + title = "Test App 2" + intent = Intent().apply { `package` = "fake" } + }, + ) + shortcut = + taskbarContext.controllers.taskbarPopupController.createPinShortcut( + taskbarContext, + recentTaskInfo, + recentTaskIcon, + ) as SystemShortcut<*> + } + assertNotNull(shortcut) + runOnMainSync { shortcut?.onClick(recentTaskIcon) } + + // After pinning the recent task, it should be included in the hotseat items. + assertThat(modelCallback.hotseatItems.map { info -> info.title }) + .isEqualTo(listOf("Test App 0", "Test App 1", "Test App 2")) + // As the task is pinned, the shown tasks should remove it from the list + assertThat(recentAppsController.shownTasks.map { it.tasks[0].key.id }).isEqualTo(listOf(1)) + } + + private fun setUpTaskbarAndModelCallback(hotseatItems: Array): TaskbarView { + val taskbarView: TaskbarView = + taskbarUnitTestRule.activityContext.dragLayer.findViewById(R.id.taskbar_view) + taskbarView.updateItems(hotseatItems, recentAppsController.shownTasks) + modelCallback.recentAppsController = recentAppsController + context.baseContext.appComponent.launcherAppState.model.addCallbacksAndLoad(modelCallback) + modelCallback.bindItems(hotseatItems.toList(), false) + return taskbarView + } + private fun createDesktopTask(tasksToAdd: Int) { createDesktopTaskWithTasksFromPackages((0..() + var recentAppsController: TaskbarRecentAppsController? = null + + override fun bindItems(shortcuts: List, forceAnimateIcons: Boolean) { + runOnMainSync { + shortcuts + .filter { item -> + item is WorkspaceItemInfo && + !hotseatItems.any { it.targetPackage == item.targetPackage } + } + .forEach { item -> hotseatItems.add(item as WorkspaceItemInfo) } + recentAppsController?.updateHotseatItemInfos(hotseatItems.toTypedArray()) + } + } + + override fun bindWorkspaceComponentsRemoved(matcher: Predicate) { + runOnMainSync { + for (i in hotseatItems.size - 1 downTo 0) { + if (matcher.test(hotseatItems[i])) { + hotseatItems.removeAt(i) + } + } + recentAppsController?.updateHotseatItemInfos(hotseatItems.toTypedArray()) + } + } + } } /** TaskbarOverflowComponent used to bind the RecentsModel. */ diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewTestUtil.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewTestUtil.kt index 8f6f02e7e4..faba297512 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewTestUtil.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarViewTestUtil.kt @@ -21,6 +21,7 @@ import android.content.Intent import android.graphics.Bitmap import android.graphics.Bitmap.createBitmap import android.os.Process +import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT import com.android.launcher3.icons.BitmapInfo import com.android.launcher3.model.data.AppInfo import com.android.launcher3.model.data.AppPairInfo @@ -50,16 +51,17 @@ object TaskbarViewTestUtil { } /** Creates an array of fake hotseat items. */ - fun createHotseatItems(size: Int): Array { + fun createHotseatItems(size: Int): Array { return Array(size) { createHotseatWorkspaceItem(it) } } fun createHotseatWorkspaceItem(id: Int = 0): WorkspaceItemInfo { return WorkspaceItemInfo( - AppInfo(TEST_COMPONENT, "Test App $id", Process.myUserHandle(), Intent()) + AppInfo(testComponent(id), "Test App $id", Process.myUserHandle(), testIntent(id)) ) .apply { this.id = id + container = CONTAINER_HOTSEAT // Create a placeholder icon so that the test doesn't try to load a high-res icon. this.bitmap = BitmapInfo.fromBitmap(createBitmap(1, 1, Bitmap.Config.ALPHA_8)) } @@ -93,8 +95,8 @@ object TaskbarViewTestUtil { TaskKey( id, 5, - TEST_INTENT, - TEST_COMPONENT, + testIntent(id), + testComponent(id), Process.myUserHandle().identifier, System.currentTimeMillis(), ) @@ -149,8 +151,10 @@ enum class TaskbarIconType { } private const val TEST_PACKAGE = "com.android.launcher3.taskbar" -private val TEST_COMPONENT = ComponentName(TEST_PACKAGE, "Activity") -private val TEST_INTENT = Intent().apply { - `package` = TEST_PACKAGE - component = TEST_COMPONENT +private val testComponent = { i: Int -> ComponentName(TEST_PACKAGE, "Activity $i") } +private val testIntent = { i: Int -> + Intent().apply { + `package` = TEST_PACKAGE + component = testComponent(i) + } } From 291438aaec5841a68ea605e1e0d70cafcab9cfb0 Mon Sep 17 00:00:00 2001 From: Anushree Ganjam Date: Thu, 17 Apr 2025 22:26:08 +0000 Subject: [PATCH 05/10] Move StatsLogManager to Dagger Helps us to delete ResourceBasedOverride class. Delete "stats_log_manager_class" resource from config. Delete unused "app_launch_tracker_class" resource from config. Bug: 361850561 Test: Presubmit Flag: EXEMPT dagger Change-Id: I71ed7ffca62e7c74d4ee0d0b4c045ffed9599cfe --- quickstep/res/values/config.xml | 2 -- .../com/android/launcher3/dagger/Modules.kt | 7 +++++ .../logging/SettingsChangeLogger.java | 15 ++-------- .../logging/StatsLogCompatManager.java | 21 +++++++++++++- .../logging/SettingsChangeLoggerTest.kt | 10 ++++--- res/values/config.xml | 2 -- .../dagger/LauncherBaseAppComponent.java | 5 ++-- .../launcher3/logging/StatsLogManager.java | 28 +++++++++++++++---- 8 files changed, 62 insertions(+), 28 deletions(-) diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml index 7b678ec934..b442264d46 100644 --- a/quickstep/res/values/config.xml +++ b/quickstep/res/values/config.xml @@ -21,9 +21,7 @@ com.android.launcher3/com.android.quickstep.interaction.GestureSandboxActivity - com.android.quickstep.logging.StatsLogCompatManager com.android.quickstep.QuickstepTestInformationHandler - com.android.launcher3.appprediction.PredictionAppTracker com.android.quickstep.QuickstepProcessInitializer com.android.launcher3.secondarydisplay.SecondaryDisplayQuickstepDelegateImpl com.android.launcher3.taskbar.TaskbarModelCallbacksFactory diff --git a/quickstep/src/com/android/launcher3/dagger/Modules.kt b/quickstep/src/com/android/launcher3/dagger/Modules.kt index 7b3504a7cd..2456534020 100644 --- a/quickstep/src/com/android/launcher3/dagger/Modules.kt +++ b/quickstep/src/com/android/launcher3/dagger/Modules.kt @@ -18,6 +18,7 @@ package com.android.launcher3.dagger import com.android.launcher3.icons.LauncherIconProvider import com.android.launcher3.icons.LauncherIconProviderImpl +import com.android.launcher3.logging.StatsLogManager.StatsLogManagerFactory import com.android.launcher3.uioverrides.QuickstepWidgetHolder.QuickstepWidgetHolderFactory import com.android.launcher3.uioverrides.SystemApiWrapper import com.android.launcher3.uioverrides.plugins.PluginManagerWrapperImpl @@ -28,6 +29,7 @@ import com.android.launcher3.util.window.RefreshRateTracker import com.android.launcher3.util.window.WindowManagerProxy import com.android.launcher3.widget.LauncherWidgetHolder.WidgetHolderFactory import com.android.quickstep.InstantAppResolverImpl +import com.android.quickstep.logging.StatsLogCompatManager.StatsLogCompatManagerFactory import com.android.quickstep.util.ChoreographerFrameRateTracker import com.android.quickstep.util.GestureExclusionManager import com.android.quickstep.util.SystemWindowManagerProxy @@ -44,6 +46,11 @@ abstract class WindowManagerProxyModule { @Module abstract class ApiWrapperModule { + @Binds + abstract fun bindStatsLogManagerFactory( + impl: StatsLogCompatManagerFactory + ): StatsLogManagerFactory + @Binds abstract fun bindApiWrapper(systemApiWrapper: SystemApiWrapper): ApiWrapper @Binds diff --git a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java index 190eb5423c..c9d1207a07 100644 --- a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java +++ b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java @@ -107,19 +107,10 @@ public class SettingsChangeLogger implements SettingsChangeLogger(@ApplicationContext Context context, DaggerSingletonTracker tracker, DisplayController displayController, - SettingsCache settingsCache) { - this(context, StatsLogManager.newInstance(context), tracker, displayController, - settingsCache); - } - - @VisibleForTesting - SettingsChangeLogger(@ApplicationContext Context context, - StatsLogManager statsLogManager, - DaggerSingletonTracker tracker, - DisplayController displayController, - SettingsCache settingsCache) { + SettingsCache settingsCache, + StatsLogManager.StatsLogManagerFactory factory) { mContext = context; - mStatsLogManager = statsLogManager; + mStatsLogManager = factory.create(context); mLoggablePrefs = loadPrefKeys(context); displayController.addChangeListener(this); diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java index 58e54cffbf..5c2aff6585 100644 --- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java +++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java @@ -82,6 +82,8 @@ import java.util.Optional; import java.util.OptionalInt; import java.util.concurrent.CopyOnWriteArrayList; +import javax.inject.Inject; + /** * This class calls StatsLog compile time generated methods. * @@ -121,10 +123,27 @@ public class StatsLogCompatManager extends StatsLogManager { public static final CopyOnWriteArrayList LOGS_CONSUMER = new CopyOnWriteArrayList<>(); - public StatsLogCompatManager(Context context) { + private StatsLogCompatManager(Context context) { super(context); } + /** + * This class is purely used to support dagger bindings to be overridden in launcher variants. + * Very similar to {@link dagger.assisted.AssistedFactory}. But + * {@link dagger.assisted.AssistedFactory} cannot be overridden and this makes dagger binding + * difficult. + */ + public static class StatsLogCompatManagerFactory extends StatsLogManagerFactory { + @Inject + StatsLogCompatManagerFactory() { + super(); + } + + public StatsLogManager create(Context context) { + return new StatsLogCompatManager(context); + } + } + @Override protected StatsLogger createLogger() { return new StatsCompatLogger(mContext, mActivityContext); diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt index 08b1ffaf9a..9c655a70cd 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt @@ -60,6 +60,8 @@ class SettingsChangeLoggerTest { private lateinit var mSystemUnderTest: SettingsChangeLogger + @Mock private lateinit var mStatsLogFactory: StatsLogManager.StatsLogManagerFactory + @Mock private lateinit var mStatsLogManager: StatsLogManager @Mock private lateinit var mMockLogger: StatsLogManager.StatsLogger @@ -78,7 +80,7 @@ class SettingsChangeLoggerTest { @Before fun setUp() { MockitoAnnotations.initMocks(this) - + whenever(mStatsLogFactory.create(mContext)).doReturn(mStatsLogManager) whenever(mStatsLogManager.logger()).doReturn(mMockLogger) whenever(mStatsLogManager.logger().withInstanceId(any())).doReturn(mMockLogger) mDefaultThemedIcons = themeManager.isMonoThemeEnabled @@ -91,10 +93,10 @@ class SettingsChangeLoggerTest { mSystemUnderTest = SettingsChangeLogger( mContext, - mStatsLogManager, mTracker, displayController, settingsCache, + mStatsLogFactory, ) } @@ -109,10 +111,10 @@ class SettingsChangeLoggerTest { val systemUnderTest = SettingsChangeLogger( mContext, - mStatsLogManager, mTracker, displayController, settingsCache, + mStatsLogFactory, ) assertThat(systemUnderTest.loggingPrefs[ALLOW_ROTATION_PREFERENCE_KEY]!!.defaultValue) @@ -139,7 +141,7 @@ class SettingsChangeLoggerTest { LauncherPrefs.get(mContext).put(item = ALLOW_ROTATION, value = true) // This a new object so the values of mLoggablePrefs will be different - SettingsChangeLogger(mContext, mStatsLogManager, mTracker, displayController, settingsCache) + SettingsChangeLogger(mContext, mTracker, displayController, settingsCache, mStatsLogFactory) .logSnapshot(mInstanceId) verify(mMockLogger, atLeastOnce()).log(mEventCaptor.capture()) diff --git a/res/values/config.xml b/res/values/config.xml index 98d3e86388..f8c95ab974 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -62,9 +62,7 @@ - - diff --git a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java index 519c2bf8db..a9bad2049d 100644 --- a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java +++ b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java @@ -27,6 +27,8 @@ import com.android.launcher3.RemoveAnimationSettingsTracker; import com.android.launcher3.graphics.GridCustomizationsProxy; import com.android.launcher3.graphics.ThemeManager; import com.android.launcher3.icons.LauncherIcons.IconPool; +import com.android.launcher3.logging.DumpManager; +import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.ItemInstallQueue; import com.android.launcher3.model.LoaderCursor.LoaderCursorFactory; import com.android.launcher3.pm.InstallSessionHelper; @@ -34,7 +36,6 @@ import com.android.launcher3.pm.UserCache; import com.android.launcher3.util.ApiWrapper; import com.android.launcher3.util.DaggerSingletonTracker; import com.android.launcher3.util.DisplayController; -import com.android.launcher3.logging.DumpManager; import com.android.launcher3.util.DynamicResource; import com.android.launcher3.util.InstantAppResolver; import com.android.launcher3.util.LockedUserState; @@ -93,8 +94,8 @@ public interface LauncherBaseAppComponent { WidgetHolderFactory getWidgetHolderFactory(); RefreshRateTracker getFrameRateProvider(); InstantAppResolver getInstantAppResolver(); - DumpManager getDumpManager(); + StatsLogManager.StatsLogManagerFactory getStatsLogManagerFactory(); /** Builder for LauncherBaseAppComponent. */ interface Builder { diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index 8e18a76f60..27bc3a3f73 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -28,14 +28,16 @@ import androidx.annotation.Nullable; import androidx.slice.SliceItem; import com.android.launcher3.R; +import com.android.launcher3.dagger.LauncherComponentProvider; import com.android.launcher3.logger.LauncherAtom; import com.android.launcher3.logger.LauncherAtom.ContainerInfo; import com.android.launcher3.logger.LauncherAtom.FromState; import com.android.launcher3.logger.LauncherAtom.ToState; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.util.ResourceBasedOverride; import com.android.launcher3.views.ActivityContext; +import javax.inject.Inject; + /** * Handles the user event logging in R+. * @@ -45,7 +47,7 @@ import com.android.launcher3.views.ActivityContext; * Actual call happens only for Launcher variant that implements QuickStep. * */ -public class StatsLogManager implements ResourceBasedOverride { +public class StatsLogManager { public static final int LAUNCHER_STATE_UNSPECIFIED = 0; public static final int LAUNCHER_STATE_BACKGROUND = 1; @@ -62,11 +64,28 @@ public class StatsLogManager implements ResourceBasedOverride { private KeyboardStateManager mKeyboardStateManager; private InstanceId mInstanceId; - public StatsLogManager(@NonNull Context context) { + + protected StatsLogManager(@NonNull Context context) { mContext = context; mActivityContext = ActivityContext.lookupContextNoThrow(context); } + /** + * This class is purely used to support dagger bindings to be overridden in launcher variants. + * Very similar to {@link dagger.assisted.AssistedFactory}. But + * {@link dagger.assisted.AssistedFactory} cannot be overridden and this makes dagger binding + * difficult. + */ + public static class StatsLogManagerFactory { + @Inject + public StatsLogManagerFactory() { + } + + public StatsLogManager create(Context context) { + return new StatsLogManager(context); + } + } + /** * Returns event enum based on the two state transition information when swipe * gesture happens(to be removed during UserEventDispatcher cleanup). @@ -1356,7 +1375,6 @@ public class StatsLogManager implements ResourceBasedOverride { * Creates a new instance of {@link StatsLogManager} based on provided context. */ public static StatsLogManager newInstance(Context context) { - return Overrides.getObject( - StatsLogManager.class, context, R.string.stats_log_manager_class); + return LauncherComponentProvider.get(context).getStatsLogManagerFactory().create(context); } } From 007cfecf5e7b095ccafb568339500226f8ec4681 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 16 Apr 2025 22:48:24 -0700 Subject: [PATCH 06/10] Merging update and modify model callbacks Instead of the dispatcher specifying the type, the UI checks th diff. This ensures that the UI is updated correctly in all paths Bug: 390572144 Flag: EXEMPT refactor Test: Manually verified folder edit path where these callbacks were getting dispatched Change-Id: Ib73eed5da87a847753a78453a48ab4fc495c1199 --- .../taskbar/TaskbarModelCallbacks.java | 36 ++++++++++----- .../launcher3/taskbar/TaskbarView.java | 45 ++++++++++++++++++- src/com/android/launcher3/CellLayout.java | 12 ++--- src/com/android/launcher3/Launcher.java | 5 --- .../android/launcher3/LauncherSettings.java | 11 ----- src/com/android/launcher3/ModelCallbacks.kt | 22 +++++---- src/com/android/launcher3/Workspace.java | 40 ++++++++++++++--- .../android/launcher3/celllayout/CellInfo.kt | 41 ++++++++++++----- src/com/android/launcher3/folder/Folder.java | 5 +++ .../launcher3/folder/FolderGridOrganizer.java | 14 +++--- .../launcher3/folder/FolderPagedView.java | 8 ++-- .../android/launcher3/model/BgDataModel.java | 9 +--- .../android/launcher3/model/ModelWriter.java | 5 ++- .../util/LauncherBindableItemsContainer.kt | 45 ++++++++++++++++--- 14 files changed, 211 insertions(+), 87 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java index 15c7a8d59d..836c06cb38 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java @@ -15,17 +15,23 @@ */ package com.android.launcher3.taskbar; +import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT; +import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION; + import android.util.SparseArray; import android.view.View; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.UiThread; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.celllayout.CellInfo; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.taskbar.TaskbarView.TaskbarLayoutParams; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; @@ -104,7 +110,7 @@ public class TaskbarModelCallbacks implements } } - private boolean handleItemsAdded(List items) { + private boolean handleItemsAdded(Iterable items) { boolean modified = false; for (ItemInfo item : items) { if (item.container == Favorites.CONTAINER_HOTSEAT) { @@ -117,7 +123,24 @@ public class TaskbarModelCallbacks implements @Override public void bindItemsUpdated(Set updates) { - updateContainerItems(updates, mContext); + Set itemsToRebind = updateContainerItems(updates, mContext); + + boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(itemsToRebind)); + boolean added = handleItemsAdded(itemsToRebind); + if (removed || added) { + commitItemsToUI(); + } + } + + @Nullable + @Override + public CellInfo getCellInfoForView(@NonNull View view) { + return view.getLayoutParams() instanceof TaskbarLayoutParams tlp ? tlp.bindInfo : null; + } + + @Override + public boolean isContainerSupported(int container) { + return container == CONTAINER_HOTSEAT || container == CONTAINER_HOTSEAT_PREDICTION; } @Override @@ -150,15 +173,6 @@ public class TaskbarModelCallbacks implements return modified; } - @Override - public void bindItemsModified(List items) { - boolean removed = handleItemsRemoved(ItemInfoMatcher.ofItems(items)); - boolean added = handleItemsAdded(items); - if (removed || added) { - commitItemsToUI(); - } - } - @Override public void bindExtraContainerItems(FixedContainerItems item) { if (item.containerId == Favorites.CONTAINER_HOTSEAT_PREDICTION) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index b4eb16d0b6..60e4cd8606 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -38,6 +38,7 @@ import android.view.InputDevice; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.LayoutRes; @@ -51,6 +52,7 @@ import com.android.launcher3.Insettable; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.apppairs.AppPairIcon; +import com.android.launcher3.celllayout.CellInfo; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.folder.PreviewBackground; import com.android.launcher3.model.data.AppPairInfo; @@ -570,7 +572,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar } else { hotseatView = inflate(expectedLayoutResId); } - LayoutParams lp = new LayoutParams(mIconTouchSize, mIconTouchSize); + LayoutParams lp = new TaskbarLayoutParams(mIconTouchSize, mIconTouchSize); hotseatView.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding); addView(hotseatView, mNextViewIndex, lp); } else if (hotseatView instanceof FolderIcon fi) { @@ -578,6 +580,13 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar fi.getFolder().reapplyItemInfo(); } + if (hotseatView.getLayoutParams() instanceof TaskbarLayoutParams tlp) { + tlp.bindInfo = new CellInfo(hotseatView, + hotseatItemInfo.screenId, hotseatItemInfo.container, + hotseatItemInfo.cellX, hotseatItemInfo.cellY, + hotseatItemInfo.spanX, hotseatItemInfo.spanY); + } + // Apply the Hotseat ItemInfos, or hide the view if there is none for a given index. if (hotseatView instanceof BubbleTextView btv && hotseatItemInfo instanceof WorkspaceItemInfo workspaceInfo) { @@ -696,7 +705,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar if (recentIcon == null) { // TODO(b/343289567 and b/316004172): support app pairs and desktop mode. recentIcon = inflate(expectedLayoutResId); - LayoutParams lp = new LayoutParams(mIconTouchSize, mIconTouchSize); + LayoutParams lp = new TaskbarLayoutParams(mIconTouchSize, mIconTouchSize); recentIcon.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding); addView(recentIcon, mNextViewIndex, lp); } @@ -1130,4 +1139,36 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar return navSpaceNeeded + getIconLayoutWidth(); } } + + @Override + protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { + return new TaskbarLayoutParams(lp); + } + + @Override + public LayoutParams generateLayoutParams(AttributeSet attrs) { + return new TaskbarLayoutParams(getContext(), attrs); + } + + @Override + protected boolean checkLayoutParams(ViewGroup.LayoutParams p) { + return p instanceof TaskbarLayoutParams; + } + + public static class TaskbarLayoutParams extends FrameLayout.LayoutParams { + + @Nullable public CellInfo bindInfo; + + public TaskbarLayoutParams(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public TaskbarLayoutParams(ViewGroup.LayoutParams source) { + super(source); + } + + public TaskbarLayoutParams(int width, int height) { + super(width, height); + } + } } diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index 0ce966b99b..74572fc38a 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -1076,10 +1076,8 @@ public class CellLayout extends ViewGroup { int delay, boolean permanent, boolean adjustOccupied) { ShortcutAndWidgetContainer clc = getShortcutsAndWidgets(); - if (clc.indexOfChild(child) != -1 && (child instanceof Reorderable)) { + if (clc.indexOfChild(child) != -1 && (child instanceof Reorderable item)) { final CellLayoutLayoutParams lp = (CellLayoutLayoutParams) child.getLayoutParams(); - final ItemInfo info = (ItemInfo) child.getTag(); - final Reorderable item = (Reorderable) child; // We cancel any existing animations if (mReorderAnimators.containsKey(lp)) { @@ -1485,7 +1483,7 @@ public class CellLayout extends ViewGroup { lp.setCellX(lp.getTmpCellX()); lp.setCellY(lp.getTmpCellY()); if (requiresDbUpdate) { - Launcher.cast(mActivity).getModelWriter().modifyItemInDatabase(info, container, + mActivity.getModelWriter().modifyItemInDatabase(info, container, screenId, lp.getCellX(), lp.getCellY(), lp.cellHSpan, lp.cellVSpan); } } @@ -1855,8 +1853,7 @@ public class CellLayout extends ViewGroup { public void markCellsAsOccupiedForView(View view) { if (view instanceof LauncherAppWidgetHostView - && view.getTag() instanceof LauncherAppWidgetInfo) { - LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag(); + && view.getTag() instanceof LauncherAppWidgetInfo info) { CellPos pos = mActivity.getCellPosMapper().mapModelToPresenter(info); mOccupied.markCells(pos.cellX, pos.cellY, info.spanX, info.spanY, true); return; @@ -1869,8 +1866,7 @@ public class CellLayout extends ViewGroup { public void markCellsAsUnoccupiedForView(View view) { if (view instanceof LauncherAppWidgetHostView - && view.getTag() instanceof LauncherAppWidgetInfo) { - LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) view.getTag(); + && view.getTag() instanceof LauncherAppWidgetInfo info) { CellPos pos = mActivity.getCellPosMapper().mapModelToPresenter(info); mOccupied.markCells(pos.cellX, pos.cellY, info.spanX, info.spanY, false); return; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index fccec91e7e..2d77762563 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2526,11 +2526,6 @@ public class Launcher extends StatefulActivity mModelCallbacks.bindWorkspaceComponentsRemoved(matcher); } - @Override - public void bindItemsModified(List items) { - mModelCallbacks.bindItemsModified(items); - } - /** * See {@code LauncherBindingDelegate} */ diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java index bd730feab1..b17f44f5ba 100644 --- a/src/com/android/launcher3/LauncherSettings.java +++ b/src/com/android/launcher3/LauncherSettings.java @@ -197,17 +197,6 @@ public class LauncherSettings { public static final int CONTAINER_UNKNOWN = -1; - - /** - * Function to know if a container belongs to the Workspace. - */ - public static boolean containerBelongsToWorkspace(int container) { - return container == CONTAINER_DESKTOP - || container == CONTAINER_HOTSEAT - || container == CONTAINER_PREDICTION - || container == CONTAINER_HOTSEAT_PREDICTION; - } - public static final String containerToString(int container) { switch (container) { case CONTAINER_DESKTOP: return "desktop"; diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index 0ea27db319..cc5ac499a8 100644 --- a/src/com/android/launcher3/ModelCallbacks.kt +++ b/src/com/android/launcher3/ModelCallbacks.kt @@ -6,7 +6,6 @@ import android.os.Trace import android.util.Log import androidx.annotation.UiThread import com.android.launcher3.LauncherConstants.TraceEvents -import com.android.launcher3.LauncherSettings.Favorites.containerBelongsToWorkspace import com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID import com.android.launcher3.allapps.AllAppsStore @@ -204,8 +203,20 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { * method from LauncherModel.Callbacks. */ override fun bindItemsUpdated(updates: Set) { - launcher.workspace.updateContainerItems(updates, launcher) + val workspace = launcher.workspace + val itemsToRebind = workspace.updateContainerItems(updates, launcher) PopupContainerWithArrow.dismissInvalidPopup(launcher) + + if (itemsToRebind.isEmpty()) return + workspace.removeItemsByMatcher(ItemInfoMatcher.ofItems(itemsToRebind), false) + itemsToRebind + .filter { workspace.isContainerSupported(it.container) } + .let { + if (it.isNotEmpty()) { + launcher.bindItems(it, false) + } + } + workspace.stripEmptyScreens() } /** @@ -220,13 +231,6 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { PopupContainerWithArrow.dismissInvalidPopup(launcher) } - override fun bindItemsModified(itemsParam: MutableList) { - val items = itemsParam.filter { containerBelongsToWorkspace(it.container) } - launcher.workspace.removeItemsByMatcher(ItemInfoMatcher.ofItems(items), false) - launcher.bindItems(items, false) - launcher.workspace.stripEmptyScreens() - } - override fun bindAllWidgets(allWidgets: List) { launcher.widgetPickerDataProvider.setWidgets(allWidgets) } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index ba3c6b102d..db5dc8054e 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -19,7 +19,10 @@ package com.android.launcher3; import static com.android.launcher3.AbstractFloatingView.TYPE_WIDGET_RESIZE_FRAME; import static com.android.launcher3.BubbleTextView.DISPLAY_FOLDER; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; +import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP; +import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION; +import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PREDICTION; import static com.android.launcher3.LauncherState.ALL_APPS; import static com.android.launcher3.LauncherState.EDIT_MODE; import static com.android.launcher3.LauncherState.FLAG_MULTI_PAGE; @@ -62,6 +65,7 @@ import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; import android.widget.Toast; @@ -2043,9 +2047,7 @@ public class Workspace extends PagedView // Move internally boolean hasMovedLayouts = (getParentCellLayoutForView(cell) != dropTargetLayout); boolean hasMovedIntoHotseat = mLauncher.isHotseatLayout(dropTargetLayout); - int container = hasMovedIntoHotseat ? - LauncherSettings.Favorites.CONTAINER_HOTSEAT : - LauncherSettings.Favorites.CONTAINER_DESKTOP; + int container = hasMovedIntoHotseat ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP; int screenId = (mTargetCell[0] < 0) ? mDragInfo.screenId : getCellLayoutId(dropTargetLayout); int spanX = mDragInfo != null ? mDragInfo.spanX : 1; @@ -2148,8 +2150,8 @@ public class Workspace extends PagedView lp.cellVSpan = item.spanY; lp.isLockedToGrid = true; - if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT && - cell instanceof LauncherAppWidgetHostView) { + if (container != CONTAINER_HOTSEAT + && cell instanceof LauncherAppWidgetHostView) { // We post this call so that the widget has a chance to be placed // in its final location @@ -2805,8 +2807,8 @@ public class Workspace extends PagedView */ private void onDropExternal(final int[] touchXY, final CellLayout cellLayout, DragObject d) { final int container = mLauncher.isHotseatLayout(cellLayout) - ? LauncherSettings.Favorites.CONTAINER_HOTSEAT - : LauncherSettings.Favorites.CONTAINER_DESKTOP; + ? CONTAINER_HOTSEAT + : CONTAINER_DESKTOP; if (d.dragInfo instanceof PendingAddShortcutInfo) { WorkspaceItemInfo si = ((PendingAddShortcutInfo) d.dragInfo) .getActivityInfo(mLauncher).createWorkspaceItemInfo(); @@ -3347,6 +3349,30 @@ public class Workspace extends PagedView } } + @Nullable + @Override + public CellInfo getCellInfoForView(@NonNull View view) { + ViewParent parent = view.getParent(); + if (parent != null + && parent.getParent() instanceof CellLayout cl + && view.getLayoutParams() instanceof CellLayoutLayoutParams lp) { + int container = mLauncher.isHotseatLayout(cl) ? CONTAINER_HOTSEAT : CONTAINER_DESKTOP; + CellPos pos = getCellPosMapper().mapPresenterToModel( + lp.getCellX(), lp.getCellY(), getCellLayoutId(cl), container); + return new CellInfo(view, + pos.screenId, container, pos.cellX, pos.cellY, lp.cellHSpan, lp.cellVSpan); + } + return null; + } + + @Override + public boolean isContainerSupported(int container) { + return container == CONTAINER_DESKTOP + || container == CONTAINER_HOTSEAT + || container == CONTAINER_PREDICTION + || container == CONTAINER_HOTSEAT_PREDICTION; + } + @Override public View mapOverItems(@NonNull ItemOperator op) { return mapOverCellLayouts(getWorkspaceAndHotseatCellLayouts(), op); diff --git a/src/com/android/launcher3/celllayout/CellInfo.kt b/src/com/android/launcher3/celllayout/CellInfo.kt index 5a3b7f7685..817857985e 100644 --- a/src/com/android/launcher3/celllayout/CellInfo.kt +++ b/src/com/android/launcher3/celllayout/CellInfo.kt @@ -26,17 +26,38 @@ import com.android.launcher3.util.CellAndSpan // 2. When long clicking on an empty cell in a CellLayout, we save information about the // cellX and cellY coordinates and which page was clicked. We then set this as a tag on // the CellLayout that was long clicked -class CellInfo(v: View?, info: ItemInfo, cellPos: CellPos) : - CellAndSpan(cellPos.cellX, cellPos.cellY, info.spanX, info.spanY) { - @JvmField val cell: View? - @JvmField val screenId: Int - @JvmField val container: Int +class CellInfo( + @JvmField val cell: View?, + @JvmField val screenId: Int, + @JvmField val container: Int, + cellX: Int, + cellY: Int, + spanX: Int, + spanY: Int, +) : CellAndSpan(cellX, cellY, spanX, spanY) { - init { - cell = v - screenId = cellPos.screenId - container = info.container - } + constructor( + cell: View?, + info: ItemInfo, + cellPos: CellPos, + ) : this( + cell, + cellPos.screenId, + info.container, + cellPos.cellX, + cellPos.cellY, + info.spanX, + info.spanY, + ) + + /** Returns if the provided [item] represents the same position info as itself */ + fun isSameAs(item: ItemInfo) = + item.container == container && + item.screenId == screenId && + item.cellX == cellX && + item.cellY == cellY && + item.spanX == spanX && + item.spanY == spanY override fun toString(): String { return "CellInfo(cell=$cell, screenId=$screenId, container=$container)" diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 7998b6fd5d..3a16be3a41 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -1594,6 +1594,11 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo return mContent.iterateOverItems((info, view) -> info == item); } + @Override + public boolean isContainerSupported(int container) { + return container == mInfo.id; + } + /** * Utility methods to iterate over items of the view */ diff --git a/src/com/android/launcher3/folder/FolderGridOrganizer.java b/src/com/android/launcher3/folder/FolderGridOrganizer.java index 06286d62f7..ce76d505ac 100644 --- a/src/com/android/launcher3/folder/FolderGridOrganizer.java +++ b/src/com/android/launcher3/folder/FolderGridOrganizer.java @@ -141,11 +141,8 @@ public class FolderGridOrganizer { * @return true if there was any change */ public boolean updateRankAndPos(ItemInfo item, int rank) { - Point pos = getPosForRank(rank); - if (!pos.equals(item.cellX, item.cellY) || rank != item.rank) { + if (rank != item.rank) { item.rank = rank; - item.cellX = pos.x; - item.cellY = pos.y; return true; } return false; @@ -156,8 +153,13 @@ public class FolderGridOrganizer { */ public Point getPosForRank(int rank) { int pagePos = rank % mMaxItemsPerPage; - mPoint.x = pagePos % mCountX; - mPoint.y = pagePos / mCountX; + if (mCountX == 0) { + mPoint.x = 0; + mPoint.y = 0; + } else { + mPoint.x = pagePos % mCountX; + mPoint.y = pagePos / mCountX; + } return mPoint; } diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java index ceac72d5c4..6510f681c8 100644 --- a/src/com/android/launcher3/folder/FolderPagedView.java +++ b/src/com/android/launcher3/folder/FolderPagedView.java @@ -25,6 +25,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Canvas; import android.graphics.Path; +import android.graphics.Point; import android.util.ArrayMap; import android.util.AttributeSet; import android.util.Log; @@ -262,12 +263,11 @@ public class FolderPagedView extends PagedView implements Cli icon.setOnFocusChangeListener(mFocusIndicatorHelper); CellLayoutLayoutParams lp = (CellLayoutLayoutParams) icon.getLayoutParams(); + Point pos = mOrganizer.getPosForRank(item.rank); if (lp == null) { - icon.setLayoutParams(new CellLayoutLayoutParams( - item.cellX, item.cellY, item.spanX, item.spanY)); + icon.setLayoutParams(new CellLayoutLayoutParams(pos.x, pos.y, 1, 1)); } else { - lp.setCellX(item.cellX); - lp.setCellY(item.cellY); + lp.setCellXY(pos); lp.cellHSpan = lp.cellVSpan = 1; } diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java index 4ca832d5b5..9189eb8e3a 100644 --- a/src/com/android/launcher3/model/BgDataModel.java +++ b/src/com/android/launcher3/model/BgDataModel.java @@ -46,6 +46,8 @@ import com.android.launcher3.Flags; import com.android.launcher3.Workspace; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dagger.LauncherAppSingleton; +import com.android.launcher3.logging.DumpManager; +import com.android.launcher3.logging.DumpManager.LauncherDumpable; import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.CollectionInfo; @@ -61,8 +63,6 @@ import com.android.launcher3.shortcuts.ShortcutRequest; import com.android.launcher3.shortcuts.ShortcutRequest.QueryResult; import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.DaggerSingletonTracker; -import com.android.launcher3.logging.DumpManager; -import com.android.launcher3.logging.DumpManager.LauncherDumpable; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.IntSparseArrayMap; @@ -465,11 +465,6 @@ public class BgDataModel implements LauncherDumpable { default void bindAppsAdded(IntArray newScreens, ArrayList addNotAnimated, ArrayList addAnimated) { } - /** - * Called when some persistent property of an item is modified - */ - default void bindItemsModified(List items) { } - /** * Binds updated incremental download progress */ diff --git a/src/com/android/launcher3/model/ModelWriter.java b/src/com/android/launcher3/model/ModelWriter.java index db3ad8a91a..01e1730f47 100644 --- a/src/com/android/launcher3/model/ModelWriter.java +++ b/src/com/android/launcher3/model/ModelWriter.java @@ -51,6 +51,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.function.Predicate; import java.util.function.Supplier; @@ -177,7 +178,7 @@ public class ModelWriter { public void moveItemsInDatabase(final ArrayList items, int container, int screen) { ArrayList contentValues = new ArrayList<>(); int count = items.size(); - notifyOtherCallbacks(c -> c.bindItemsModified(items)); + notifyOtherCallbacks(c -> c.bindItemsUpdated(new HashSet<>(items))); for (int i = 0; i < count; i++) { ItemInfo item = items.get(i); @@ -229,7 +230,7 @@ public class ModelWriter { } public void notifyItemModified(ItemInfo item) { - notifyOtherCallbacks(c -> c.bindItemsModified(Collections.singletonList(item))); + notifyOtherCallbacks(c -> c.bindItemsUpdated(Collections.singleton(item))); } /** diff --git a/src/com/android/launcher3/util/LauncherBindableItemsContainer.kt b/src/com/android/launcher3/util/LauncherBindableItemsContainer.kt index 8fdedef77e..ea1eecfb1d 100644 --- a/src/com/android/launcher3/util/LauncherBindableItemsContainer.kt +++ b/src/com/android/launcher3/util/LauncherBindableItemsContainer.kt @@ -19,6 +19,7 @@ package com.android.launcher3.util import android.view.View import com.android.launcher3.BubbleTextView import com.android.launcher3.apppairs.AppPairIcon +import com.android.launcher3.celllayout.CellInfo import com.android.launcher3.folder.Folder import com.android.launcher3.folder.FolderIcon import com.android.launcher3.model.data.AppPairInfo @@ -31,18 +32,28 @@ import com.android.launcher3.widget.PendingAppWidgetHostView import java.util.function.Predicate /** Interface representing a container which can bind Launcher items with some utility methods */ -interface LauncherBindableItemsContainer { +fun interface LauncherBindableItemsContainer { /** - * Called to update workspace items as a result of {@link - * com.android.launcher3.model.BgDataModel.Callbacks#bindItemsUpdated(Set)} + * Called to update items in a specific container as a result of + * [com.android.launcher3.model.BgDataModel.Callbacks.bindItemsUpdated]. Returns a set of items + * which were potentially moved and need to be rebound to the container. */ - fun updateContainerItems(updates: Set, context: ActivityContext) { + fun updateContainerItems(updates: Set, context: ActivityContext): Set { val op = ItemOperator { info, v -> when { v is BubbleTextView && info is WorkspaceItemInfo && updates.contains(info) -> v.applyFromWorkspaceItem(info) - v is FolderIcon && info is FolderInfo -> v.updatePreviewItems(updates::contains) + v is FolderIcon && info is FolderInfo -> { + v.updatePreviewItems(updates::contains) + if (updates.contains(info)) { + v.onItemsChanged(false) + v.folder.apply { + reapplyItemInfo() + if (isOpen()) close(false) + } + } + } v is AppPairIcon && info is AppPairInfo -> v.maybeRedrawForWorkspaceUpdate(updates::contains) v is PendingAppWidgetHostView && updates.contains(info) -> { @@ -57,6 +68,20 @@ interface LauncherBindableItemsContainer { mapOverItems(op) Folder.getOpen(context)?.mapOverItems(op) + + // Check for moved items + val itemsToRebind = updates.filterTo(mutableSetOf()) { isContainerSupported(it.container) } + mapOverItems { info, v -> + info?.apply { + if (!updates.contains(this)) return@apply + val uiInfo = getCellInfoForView(v) ?: return@apply + if (uiInfo.isSameAs(this)) itemsToRebind.remove(this) else itemsToRebind.add(this) + } + + // Iterate all items + false + } + return itemsToRebind } /** Returns the first view, matching the [op] */ @@ -69,6 +94,16 @@ interface LauncherBindableItemsContainer { fun getViewByItemId(id: Int): View? = mapOverItems { info, _ -> info != null && info.id == id } + /** + * Returns the currently bound info for the [view] or null if the view is not bound. It can be + * used to determine if the UI needs to be updated if it is different that the info represented + * underlying item + */ + fun getCellInfoForView(view: View): CellInfo? = null + + /** Returns if the provided [container] is supported by to this container */ + fun isContainerSupported(container: Int) = false + /** * Map the [op] over the shortcuts and widgets. Once we found the first view which matches, we * will stop the iteration and return that view. From 076df25a4f0abf4c28711a991ae136c8ffdc1c3f Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Thu, 17 Apr 2025 15:08:56 +0100 Subject: [PATCH 07/10] Fix extraWidth used to calculate visibleTaskData - getLastComputedGridTaskSize should be used to get the correct size for grid tasks Fix: 406988799 Test: manual Flag: com.android.launcher3.enable_grid_only_overview Change-Id: I7b94e8e03dd7a463417c03e600636cffc3696fdb --- quickstep/src/com/android/quickstep/views/RecentsView.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 3d6703d90e..99cc9a1b0c 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2604,9 +2604,9 @@ public abstract class RecentsView< int pageOrientedSize = getPagedOrientationHandler().getMeasuredSize(this); // For GRID_ONLY_OVERVIEW, use +/- 1 task column as visible area for preloading // adjacent thumbnails, otherwise use +/-50% screen width - int extraWidth = - enableGridOnlyOverview() ? getLastComputedTaskSize().width() + getPageSpacing() - : pageOrientedSize / 2; + int extraWidth = enableGridOnlyOverview() + ? getLastComputedGridTaskSize().width() + getPageSpacing() + : pageOrientedSize / 2; lowerIndex = upperIndex = 0; visibleStart = screenStart - extraWidth; visibleEnd = screenStart + pageOrientedSize + extraWidth; From 8b65ad809ef7c16ba6aa8b9a1342bab564c879c4 Mon Sep 17 00:00:00 2001 From: samcackett Date: Mon, 14 Apr 2025 17:31:39 +0100 Subject: [PATCH 08/10] Decouple actionsView disabled state from clearAllButton visibility Prior to this change, actionsView buttons enabled / disabled state was coupled to clearAllButton visibility, which was then coupled to scroll state. Due to an issue where outdated scroll values caused incorrect visibility calculations for the "clear all" button and consequently disabled the overview actions, we remove this check. Fix: 391276638 Flag: EXEMPT. Bugfix Test: Manual & TaplTestsQuickstep Change-Id: Ib313deb72e8f01125f15f62e7e9a4af307062060 --- quickstep/src/com/android/quickstep/views/RecentsView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index fd215674d1..147f0fced8 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1702,7 +1702,7 @@ public abstract class RecentsView< protected void onPageEndTransition() { super.onPageEndTransition(); ActiveGestureProtoLogProxy.logOnPageEndTransition(getNextPage()); - if (isClearAllHidden() && !mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().isTablet) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false); } if (getNextPage() > 0) { @@ -4235,7 +4235,7 @@ public abstract class RecentsView< // Update various scroll-dependent UI. dispatchScrollChanged(); updateActionsViewFocusedScroll(); - if (isClearAllHidden() && !mContainer.getDeviceProfile().isTablet) { + if (!mContainer.getDeviceProfile().isTablet) { mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING, false); } From c96b9adf79f497f1ed28e42d8bdff60bba2ecc5e Mon Sep 17 00:00:00 2001 From: Ajinkya Chalke Date: Wed, 16 Apr 2025 17:07:05 +0000 Subject: [PATCH 09/10] Add unit tests for KQS CD changes Bug: 382762871 Bug: 382769617 Test: KeyboardQuickSwitchControllerTest and TaskbarOverflowTest Flag: EXEMPT adding tests Change-Id: I053af97774230a9bc3d21ff8e1e328344519f728 --- .../KeyboardQuickSwitchViewController.java | 20 +- .../KeyboardQuickSwitchControllerTest.kt | 391 ++++++++++++++++++ .../launcher3/taskbar/TaskbarOverflowTest.kt | 3 + 3 files changed, 398 insertions(+), 16 deletions(-) create mode 100644 quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/KeyboardQuickSwitchControllerTest.kt diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index 47791b79fb..fdd0887a5a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -313,11 +313,11 @@ public class KeyboardQuickSwitchViewController { // All DesktopTasks, irrespective of whether desktop mode is active, are launched here as // the class DesktopTask is used in a special way by KQS view for showing thumbnails of // freeform tasks. - if (task instanceof DesktopTask) { + if (task instanceof DesktopTask desktopTask) { boolean canUnminimizeDesktopTask = context.canUnminimizeDesktopTask(taskId); - runOnUiWithJankMonitoring(() -> { + UI_HELPER_EXECUTOR.execute(() -> { if (!mOnDesktop) { - systemUiProxy.showDesktopApps(context.getDisplayId(), slideInTransition); + systemUiProxy.activateDesk(desktopTask.getDeskId(), slideInTransition); } systemUiProxy.showDesktopApp(taskId, @@ -327,7 +327,7 @@ public class KeyboardQuickSwitchViewController { return true; } else if (mOnDesktop && task instanceof SingleTask) { // Use the special API if user wants to switch to a fullscreen app while in desktop. - runOnUiWithJankMonitoring( + UI_HELPER_EXECUTOR.execute( () -> systemUiProxy.moveToFullscreen(taskId, DesktopModeTransitionSource.KEYBOARD_SHORTCUT, slideInTransition)); return true; @@ -337,18 +337,6 @@ public class KeyboardQuickSwitchViewController { return false; } - private void runOnUiWithJankMonitoring(Runnable runnable) { - Runnable onStartCallback = () -> InteractionJankMonitorWrapper.begin( - mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH); - Runnable onFinishCallback = () -> InteractionJankMonitorWrapper.end( - Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH); - UI_HELPER_EXECUTOR.execute(() -> { - onStartCallback.run(); - runnable.run(); - onFinishCallback.run(); - }); - } - private RemoteTransition getUnminimizeTransition() { return new RemoteTransition( new DesktopAppLaunchTransition( diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/KeyboardQuickSwitchControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/KeyboardQuickSwitchControllerTest.kt new file mode 100644 index 0000000000..75dfbdaa08 --- /dev/null +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/KeyboardQuickSwitchControllerTest.kt @@ -0,0 +1,391 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.launcher3.taskbar + +import android.content.ComponentName +import android.content.Intent +import android.graphics.Rect +import android.os.Process +import android.platform.test.annotations.DisableFlags +import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.SetFlagsRule +import android.view.Display.DEFAULT_DISPLAY +import android.window.RemoteTransition +import androidx.test.core.app.ApplicationProvider +import com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_FLATENNING +import com.android.launcher3.Flags.FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS +import com.android.launcher3.dagger.LauncherAppSingleton +import com.android.launcher3.statehandlers.DesktopVisibilityController +import com.android.launcher3.taskbar.TaskbarControllerTestUtil.runOnMainSync +import com.android.launcher3.taskbar.rules.DisplayControllerModule +import com.android.launcher3.taskbar.rules.MockedRecentsModelHelper +import com.android.launcher3.taskbar.rules.MockedRecentsModelTestRule +import com.android.launcher3.taskbar.rules.SandboxParams +import com.android.launcher3.taskbar.rules.TaskbarSandboxComponent +import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule +import com.android.launcher3.taskbar.rules.TaskbarUnitTestRule.InjectController +import com.android.launcher3.taskbar.rules.TaskbarWindowSandboxContext +import com.android.launcher3.util.AllModulesForTest +import com.android.launcher3.util.FakePrefsModule +import com.android.launcher3.util.LauncherMultivalentJUnit +import com.android.launcher3.util.LauncherMultivalentJUnit.EmulatedDevices +import com.android.launcher3.util.TestUtil.getOnUiThread +import com.android.quickstep.RecentsModel +import com.android.quickstep.SystemUiProxy +import com.android.quickstep.util.DesktopTask +import com.android.quickstep.util.GroupTask +import com.android.quickstep.util.SingleTask +import com.android.quickstep.util.SlideInRemoteTransition +import com.android.quickstep.util.SplitTask +import com.android.systemui.shared.recents.model.Task +import com.android.wm.shell.desktopmode.IDesktopTaskListener +import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource +import com.android.wm.shell.shared.desktopmode.DesktopTaskToFrontReason +import com.android.wm.shell.shared.split.SplitBounds +import com.android.wm.shell.shared.split.SplitScreenConstants +import com.google.common.truth.Truth.assertThat +import dagger.BindsInstance +import dagger.Component +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.ArgumentMatchers.anyInt +import org.mockito.kotlin.anyOrNull +import org.mockito.kotlin.doAnswer +import org.mockito.kotlin.eq +import org.mockito.kotlin.mock +import org.mockito.kotlin.spy +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever + +@RunWith(LauncherMultivalentJUnit::class) +@EmulatedDevices(["pixelTablet2023"]) +class KeyboardQuickSwitchControllerTest { + private var systemUiProxySpy: SystemUiProxy? = null + private var desktopTaskListener: IDesktopTaskListener? = null + private val mockRecentsModelHelper: MockedRecentsModelHelper = MockedRecentsModelHelper() + private val desktopVisibilityController: DesktopVisibilityController = mock() + private val taskIdCaptor = ArgumentCaptor.forClass(Int::class.java) + private val transitionCaptor = ArgumentCaptor.forClass(RemoteTransition::class.java) + + @get:Rule(order = 0) val setFlagsRule = SetFlagsRule() + @get:Rule(order = 1) + val context = + TaskbarWindowSandboxContext.create( + SandboxParams( + { + spy(SystemUiProxy(ApplicationProvider.getApplicationContext())) { proxy -> + systemUiProxySpy = proxy + doAnswer { desktopTaskListener = it.getArgument(0) } + .whenever(proxy) + .setDesktopTaskListener(anyOrNull()) + } + }, + builderBase = + DaggerKeyboardQuickSwitchControllerComponent.builder() + .bindRecentsModel(mockRecentsModelHelper.mockRecentsModel) + .bindDesktopVisibilityController(desktopVisibilityController), + ) + ) + + @get:Rule(order = 2) val recentsModel = MockedRecentsModelTestRule(mockRecentsModelHelper) + @get:Rule(order = 3) val taskbarUnitTestRule = TaskbarUnitTestRule(this, context) + + @InjectController lateinit var keyboardQuickSwitchController: KeyboardQuickSwitchController + + private val isKqsShown: Boolean + get() = getOnUiThread { keyboardQuickSwitchController.isShown } + + private val shownTaskIds: List + get() = getOnUiThread { keyboardQuickSwitchController.shownTaskIds() } + + @Test + fun noRecentTasks_noShownTaskIds() { + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).isEmpty() + } + + @Test + fun onlySingleTasksPresent_shouldShowAllTaskIds() { + updateRecentsModel( + listOf(createSingleTask(PREVIOUS_TASK_ID), createSingleTask(RUNNING_TASK_ID)) + ) + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID).inOrder() + } + + @Test + fun onlyDesktopTasksPresent_shouldShowAllTaskIds() { + updateRecentsModel(listOf(createDesktopTask(listOf(RUNNING_TASK_ID, PREVIOUS_TASK_ID)))) + enableDesktopMode() + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID).inOrder() + } + + @Test + @DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun singleAndDesktopTasksPresent_notOnDesktopWithFlatenningOff_onlyShowSingleTaskIds() { + updateRecentsModel( + listOf( + createDesktopTask(listOf(PREVIOUS_TASK_ID, OLDEST_TASK_ID)), + createSingleTask(RUNNING_TASK_ID), + ) + ) + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID) + } + + @Test + @DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun singleAndDesktopTasksPresent_onDesktopWithFlatenningOff_onlyShowDesktopTaskIds() { + updateRecentsModel( + listOf( + createDesktopTask(listOf(RUNNING_TASK_ID, OLDEST_TASK_ID)), + createSingleTask(PREVIOUS_TASK_ID), + ) + ) + enableDesktopMode() + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, OLDEST_TASK_ID).inOrder() + } + + @Test + @EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun singleAndDesktopTasksPresent_onDesktopWithFlatenningOn_showAllTaskIds() { + updateRecentsModel( + listOf( + createDesktopTask(listOf(RUNNING_TASK_ID, OLDEST_TASK_ID)), + createSingleTask(PREVIOUS_TASK_ID), + ) + ) + enableDesktopMode() + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds) + .containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID, OLDEST_TASK_ID) + .inOrder() + } + + @Test + @EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun singleAndDesktopTasksPresent_notOnDesktopWithFlatenningOn_showAllTaskIds() { + updateRecentsModel( + listOf( + createDesktopTask(listOf(PREVIOUS_TASK_ID, OLDEST_TASK_ID)), + createSingleTask(RUNNING_TASK_ID), + ) + ) + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds) + .containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID, OLDEST_TASK_ID) + .inOrder() + } + + @Test + @DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING, FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS) + fun multipleDesktopTasksPresent_onDesktopWithCdFlagOff_onlyShowCurrentDesktopTasks() { + updateRecentsModel( + listOf( + createDesktopTask(listOf(RUNNING_TASK_ID)), + createDesktopTask(listOf(PREVIOUS_TASK_ID)), + ) + ) + enableDesktopMode() + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID) + } + + @Test + @DisableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + @EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_ON_CONNECTED_DISPLAYS) + fun multipleDesktopTasksPresent_onDesktopWithCdFlagON_showAllDesktopTasks() { + updateRecentsModel( + listOf( + createDesktopTask(listOf(RUNNING_TASK_ID)), + createDesktopTask(listOf(PREVIOUS_TASK_ID)), + ) + ) + enableDesktopMode() + + triggerAltTab() + + assertThat(isKqsShown).isTrue() + assertThat(shownTaskIds).containsExactly(RUNNING_TASK_ID, PREVIOUS_TASK_ID).inOrder() + } + + @Test + @EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun splitAndSingleTaskPresent_withFlatenningOn_shouldSortTaskIds() { + updateRecentsModel( + listOf( + createSplitTask(OLDEST_TASK_ID to RUNNING_TASK_ID), + createSingleTask(PREVIOUS_TASK_ID), + ) + ) + + triggerAltTab() + + // Although single task is more recent than one of the split tasks, the split tasks should + // be together. Furthermore, the shownTaskIds returns left split task first. + assertThat(shownTaskIds) + .containsExactly(OLDEST_TASK_ID, RUNNING_TASK_ID, PREVIOUS_TASK_ID) + .inOrder() + } + + @Test + @EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun launchDesktopApp_notOnDesktop_shouldCallSysUIProxyToStartSpecificApp() { + val deskId = 1 + updateRecentsModel(listOf(createDesktopTask(listOf(PREVIOUS_TASK_ID), deskId))) + + triggerAltTabAndLaunchFocusedTask() + + val deskIdCaptor = ArgumentCaptor.forClass(Int::class.java) + verify(systemUiProxySpy)?.activateDesk(deskIdCaptor.capture(), transitionCaptor.capture()) + assertThat(deskIdCaptor.value).isEqualTo(deskId) + assertThat(transitionCaptor.value.remoteTransition) + .isInstanceOf(SlideInRemoteTransition::class.java) + + verify(systemUiProxySpy) + ?.showDesktopApp(taskIdCaptor.capture(), eq(null), eq(DesktopTaskToFrontReason.ALT_TAB)) + assertThat(taskIdCaptor.value).isEqualTo(PREVIOUS_TASK_ID) + } + + @Test + @EnableFlags(FLAG_ENABLE_ALT_TAB_KQS_FLATENNING) + fun launchSingleApp_onDesktop_shouldCallSysUIProxyToMoveToFullscreen() { + updateRecentsModel(listOf(createSingleTask(PREVIOUS_TASK_ID))) + enableDesktopMode() + + triggerAltTabAndLaunchFocusedTask() + + verify(systemUiProxySpy) + ?.moveToFullscreen( + taskIdCaptor.capture(), + eq(DesktopModeTransitionSource.KEYBOARD_SHORTCUT), + transitionCaptor.capture(), + ) + assertThat(taskIdCaptor.value).isEqualTo(PREVIOUS_TASK_ID) + assertThat(transitionCaptor.value.remoteTransition) + .isInstanceOf(SlideInRemoteTransition::class.java) + } + + private fun createSingleTask(taskId: Int) = SingleTask(createTask(taskId)) + + private fun createSplitTask(taskIds: Pair) = + SplitTask( + createTask(taskIds.first), + createTask(taskIds.second), + SplitBounds( + /* leftTopBounds = */ Rect(), + /* rightBottomBounds = */ Rect(), + /* leftTopTaskId = */ -1, + /* rightBottomTaskId = */ -1, + /* snapPosition = */ SplitScreenConstants.SNAP_TO_2_50_50, + ), + ) + + private fun createDesktopTask(taskIds: List, deskId: Int = 0) = + DesktopTask(deskId, DEFAULT_DISPLAY, taskIds.map { createTask(it) }) + + private fun enableDesktopMode() { + whenever(desktopVisibilityController.isInDesktopMode(anyInt())).thenReturn(true) + } + + /* + * Returns a task with the given ID and a fake package name. + * + * Note: the task ID is added to last active time, thus higher task ID indicates a more recent + * active task. + */ + private fun createTask(taskId: Int): Task { + return Task( + Task.TaskKey( + taskId, + 0, + Intent().apply { `package` = "Fake${taskId}" }, + ComponentName("Fake${taskId}", ""), + Process.myUserHandle().identifier, + 2000L + taskId, + ) + ) + } + + private fun updateRecentsModel(tasks: List) { + recentsModel.updateRecentTasks(tasks) + runOnMainSync { recentsModel.resolvePendingTaskRequests() } + } + + private fun triggerAltTab() = runOnMainSync { + keyboardQuickSwitchController.openQuickSwitchView() + recentsModel.resolvePendingTaskRequests() + } + + private fun triggerAltTabAndLaunchFocusedTask() { + triggerAltTab() + runOnMainSync { keyboardQuickSwitchController.launchFocusedTask() } + } + + private companion object { + const val OLDEST_TASK_ID = 1 + const val PREVIOUS_TASK_ID = 2 + const val RUNNING_TASK_ID = 3 + } +} + +/** KeyboardQuickSwitchControllerComponent used to bind the RecentsModel. */ +@LauncherAppSingleton +@Component( + modules = [AllModulesForTest::class, FakePrefsModule::class, DisplayControllerModule::class] +) +interface KeyboardQuickSwitchControllerComponent : TaskbarSandboxComponent { + + @Component.Builder + interface Builder : TaskbarSandboxComponent.Builder { + @BindsInstance fun bindRecentsModel(model: RecentsModel): Builder + + @BindsInstance + fun bindDesktopVisibilityController( + desktopVisibilityController: DesktopVisibilityController + ): Builder + + override fun build(): KeyboardQuickSwitchControllerComponent + } +} 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 9966bef7b0..61d7c77f2f 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt @@ -26,6 +26,7 @@ import android.platform.test.flag.junit.SetFlagsRule import android.view.Display.DEFAULT_DISPLAY 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.Flags.FLAG_TASKBAR_OVERFLOW import com.android.launcher3.R @@ -354,6 +355,7 @@ 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 @@ -413,6 +415,7 @@ 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 From 4b694fa2c4e12067abdcaaabb6a5b72edf7fbf74 Mon Sep 17 00:00:00 2001 From: minch Date: Fri, 18 Apr 2025 05:31:56 +0000 Subject: [PATCH 10/10] Get DesktopVisibilityController via dagger in TopTaskTracker Bug: None Test: m Flag: EXEMPT refactor Change-Id: I5adcf67be8a1afb6902820e30eec20630285f413 --- .../com/android/quickstep/TopTaskTracker.java | 26 +++++++++++-------- .../quickstep/AbsSwipeUpHandlerTestCase.java | 4 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/TopTaskTracker.java b/quickstep/src/com/android/quickstep/TopTaskTracker.java index 47200ce8ae..c4d6b1ad15 100644 --- a/quickstep/src/com/android/quickstep/TopTaskTracker.java +++ b/quickstep/src/com/android/quickstep/TopTaskTracker.java @@ -100,10 +100,11 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta private ArrayMap mVisibleTasks = new ArrayMap<>(); private final Context mContext; + private final DesktopVisibilityController mDesktopVisibilityController; @Inject public TopTaskTracker(@ApplicationContext Context context, DaggerSingletonTracker tracker, - SystemUiProxy systemUiProxy) { + SystemUiProxy systemUiProxy, DesktopVisibilityController desktopVisibilityController) { if (!enableShellTopTaskTracking()) { mMainStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_MAIN; mSideStagePosition.stageType = SplitConfigurationOptions.STAGE_TYPE_SIDE; @@ -122,6 +123,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta }); mContext = context; + mDesktopVisibilityController = desktopVisibilityController; } @Override @@ -346,6 +348,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta // explicit) return new CachedTaskInfo(mVisibleTasks.get(displayId)); } else { + int activeDeskId = mDesktopVisibilityController.getActiveDeskId(displayId); if (filterOnlyVisibleRecents) { // Since we only know about the top most task, any filtering may not be applied on // the cache. The second to top task may change while the top task is still the @@ -355,10 +358,10 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta if (enableOverviewOnConnectedDisplays()) { return new CachedTaskInfo(Arrays.stream(tasks).filter( info -> ExternalDisplaysKt.getSafeDisplayId(info) - == displayId).toList(), mContext, displayId); + == displayId).toList(), mContext, displayId, activeDeskId); } else { return new CachedTaskInfo(Arrays.asList(tasks), mContext, - displayId); + displayId, activeDeskId); } } @@ -384,7 +387,7 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta taskInfo -> !DesksUtils.isDesktopWallpaperTask(taskInfo)); } - return new CachedTaskInfo(taskStream.toList(), mContext, displayId); + return new CachedTaskInfo(taskStream.toList(), mContext, displayId, activeDeskId); } } @@ -416,22 +419,25 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta private final GroupedTaskInfo mVisibleTasks; private Context mContext; + private final int mActiveDeskId; // Only used when enableShellTopTaskTracking() is enabled CachedTaskInfo(@Nullable GroupedTaskInfo visibleTasks) { mAllCachedTasks = null; mTopTask = null; mVisibleTasks = visibleTasks; + mActiveDeskId = INACTIVE_DESK_ID; } // Only used when enableShellTopTaskTracking() is disabled CachedTaskInfo(@NonNull List allCachedTasks, Context context, - int displayId) { + int displayId, int activeDeskId) { mDisplayId = displayId; mVisibleTasks = null; mAllCachedTasks = allCachedTasks; mTopTask = allCachedTasks.isEmpty() ? null : allCachedTasks.get(0); mContext = context; + mActiveDeskId = activeDeskId; } /** @@ -541,7 +547,8 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta && t.getActivityType() != ACTIVITY_TYPE_RECENTS) .toList(); return visibleNonExcludedTasks.isEmpty() ? null - : new CachedTaskInfo(visibleNonExcludedTasks, mContext, mDisplayId); + : new CachedTaskInfo(visibleNonExcludedTasks, mContext, mDisplayId, + mActiveDeskId); } /** @@ -599,12 +606,9 @@ public class TopTaskTracker extends ISplitScreenListener.Stub implements TaskSta } else { final TaskInfo baseTaskInfo = getLegacyBaseTask(); if (enableMultipleDesktops(mContext)) { - DesktopVisibilityController desktopVisibilityController = - DesktopVisibilityController.INSTANCE.get(mContext); - if (desktopVisibilityController.isInDesktopMode(mDisplayId)) { + if (mActiveDeskId != INACTIVE_DESK_ID) { return GroupedTaskInfo.forDeskTasks( - desktopVisibilityController.getActiveDeskId(mDisplayId), - mDisplayId, mAllCachedTasks, + mActiveDeskId, mDisplayId, mAllCachedTasks, /* minimizedFreeformTaskIds = */ Collections.emptySet()); } } else if (isDesktopTask(baseTaskInfo)) { diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java index b458e3d282..732f332d65 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java @@ -18,6 +18,7 @@ package com.android.quickstep; import static android.view.Display.DEFAULT_DISPLAY; +import static com.android.launcher3.statehandlers.DesktopVisibilityController.INACTIVE_DESK_ID; import static com.android.quickstep.AbsSwipeUpHandler.STATE_HANDLER_INVALIDATED; import static com.android.wm.shell.shared.ShellSharedConstants.KEY_EXTRA_SHELL_CAN_HAND_OFF_ANIMATION; import static com.android.wm.shell.shared.split.SplitBounds.KEY_EXTRA_SPLIT_BOUNDS; @@ -111,7 +112,8 @@ public abstract class AbsSwipeUpHandlerTestCase< new ActivityManager.RunningTaskInfo(); protected final TopTaskTracker.CachedTaskInfo mCachedTaskInfo = new TopTaskTracker.CachedTaskInfo( - Collections.singletonList(mRunningTaskInfo), mContext, DEFAULT_DISPLAY); + Collections.singletonList(mRunningTaskInfo), mContext, DEFAULT_DISPLAY, + INACTIVE_DESK_ID); protected final RemoteAnimationTarget mRemoteAnimationTarget = new RemoteAnimationTarget( /* taskId= */ 0, /* mode= */ RemoteAnimationTarget.MODE_CLOSING,