From 00614eae0ea00619564d6a6b401745e1a48b13df Mon Sep 17 00:00:00 2001 From: Alina Zaidi Date: Mon, 29 Jul 2024 11:02:34 +0000 Subject: [PATCH] Use DesktopModeStatus#canEnterDesktopMode instead of just Flag check. Test: Existing tests pass Bug: 349544589 Flag: EXEMPT minor refactoring Change-Id: Idf572d48d35b8eeedd7fd1b8c608834d27a818e7 --- .../launcher3/taskbar/TaskbarRecentAppsController.kt | 5 ++--- .../android/launcher3/uioverrides/QuickstepLauncher.java | 6 +++--- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 8 ++++---- quickstep/src/com/android/quickstep/RecentTasksList.java | 6 +++--- quickstep/src/com/android/quickstep/RecentsActivity.java | 4 ++-- .../com/android/quickstep/RecentsAnimationTargets.java | 6 +++--- quickstep/src/com/android/quickstep/SystemUiProxy.java | 5 ++--- .../launcher3/taskbar/TaskbarRecentAppsControllerTest.kt | 7 +++++++ .../src/com/android/quickstep/RecentTasksListTest.java | 9 +++++++++ 9 files changed, 35 insertions(+), 21 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt index 49fc0dd55a..6b5e51fe27 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt @@ -28,7 +28,7 @@ import com.android.quickstep.RecentsModel import com.android.quickstep.util.DesktopTask import com.android.quickstep.util.GroupTask import com.android.window.flags.Flags.enableDesktopWindowingTaskbarRunningApps -import com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus import java.io.PrintWriter /** @@ -44,9 +44,8 @@ class TaskbarRecentAppsController( private val desktopVisibilityControllerProvider: () -> DesktopVisibilityController?, ) : LoggableTaskbarController { - // TODO(b/335401172): unify DesktopMode checks in Launcher. var canShowRunningApps = - DESKTOP_WINDOWING_MODE.isEnabled(context) && enableDesktopWindowingTaskbarRunningApps() + DesktopModeStatus.canEnterDesktopMode(context) && enableDesktopWindowingTaskbarRunningApps() @VisibleForTesting set(isEnabledFromTest) { field = isEnabledFromTest diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index d678c46f1f..b2cc369376 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -67,7 +67,6 @@ import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SP import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; import static com.android.wm.shell.common.split.SplitScreenConstants.SNAP_TO_50_50; -import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -200,6 +199,7 @@ import com.android.systemui.unfold.config.UnfoldTransitionConfig; import com.android.systemui.unfold.dagger.UnfoldMain; import com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver; import com.android.systemui.unfold.updates.RotationChangeProvider; +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import kotlin.Unit; @@ -280,7 +280,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer // TODO(b/337863494): Explore use of the same OverviewComponentObserver across launcher OverviewComponentObserver overviewComponentObserver = new OverviewComponentObserver( asContext(), deviceState); - if (DESKTOP_WINDOWING_MODE.isEnabled(this)) { + if (DesktopModeStatus.canEnterDesktopMode(this)) { mDesktopRecentsTransitionController = new DesktopRecentsTransitionController( getStateManager(), systemUiProxy, getIApplicationThread(), getDepthController()); @@ -300,7 +300,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer mTISBindHelper = new TISBindHelper(this, this::onTISConnected); mDepthController = new DepthController(this); - if (DESKTOP_WINDOWING_MODE.isEnabled(this)) { + if (DesktopModeStatus.canEnterDesktopMode(this)) { mDesktopVisibilityController = new DesktopVisibilityController(this); mDesktopVisibilityController.registerSystemUiListener(); mSplitSelectStateController.initSplitFromDesktopController(this, diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 5a03ae650b..d4a9906157 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -62,7 +62,6 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_SETTLED_ON_END_TARGET; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; -import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -151,6 +150,7 @@ import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.shared.desktopmode.DesktopModeFlags; +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import com.android.wm.shell.startingsurface.SplashScreenExitAnimationUtils; import kotlin.Unit; @@ -1273,7 +1273,7 @@ public abstract class AbsSwipeUpHandler implem mFallbackRecentsView = rootView.findViewById(R.id.overview_panel); mActionsView = rootView.findViewById(R.id.overview_actions_view); - if (DESKTOP_WINDOWING_MODE.isEnabled(this)) { + if (DesktopModeStatus.canEnterDesktopMode(this)) { mDesktopRecentsTransitionController = new DesktopRecentsTransitionController( getStateManager(), systemUiProxy, getIApplicationThread(), null /* depthController */ diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java b/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java index d104911915..cf7e4993e6 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationTargets.java @@ -18,14 +18,14 @@ package com.android.quickstep; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.RemoteAnimationTarget.MODE_CLOSING; -import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; - import android.app.WindowConfiguration; import android.content.Context; import android.graphics.Rect; import android.os.Bundle; import android.view.RemoteAnimationTarget; +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; + import java.io.PrintWriter; /** @@ -56,7 +56,7 @@ public class RecentsAnimationTargets extends RemoteAnimationTargets { * @return {@code true} if at least one target app is a desktop task */ public boolean hasDesktopTasks(Context context) { - if (!DESKTOP_WINDOWING_MODE.isEnabled(context)) { + if (!DesktopModeStatus.canEnterDesktopMode(context)) { return false; } for (RemoteAnimationTarget target : apps) { diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index f2db5af0f8..baf669c7a9 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -24,7 +24,6 @@ import static com.android.launcher3.util.SplitConfigurationOptions.StagePosition import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.RECENT_TASKS_MISSING; import static com.android.quickstep.util.LogUtils.splitFailureMessage; import static com.android.window.flags.Flags.enableDesktopWindowingTaskbarRunningApps; -import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.DESKTOP_WINDOWING_MODE; import android.app.ActivityManager; import android.app.ActivityOptions; @@ -96,6 +95,7 @@ import com.android.wm.shell.onehanded.IOneHanded; import com.android.wm.shell.recents.IRecentTasks; import com.android.wm.shell.recents.IRecentTasksListener; import com.android.wm.shell.shared.IShellTransitions; +import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import com.android.wm.shell.splitscreen.ISplitScreen; import com.android.wm.shell.splitscreen.ISplitScreenListener; import com.android.wm.shell.splitscreen.ISplitSelectListener; @@ -1443,8 +1443,7 @@ public class SystemUiProxy implements ISystemUiProxy, NavHandle, SafeCloseable { } private boolean shouldEnableRunningTasksForDesktopMode() { - // TODO(b/335401172): unify DesktopMode checks in Launcher - return DESKTOP_WINDOWING_MODE.isEnabled(mContext) + return DesktopModeStatus.canEnterDesktopMode(mContext) && enableDesktopWindowingTaskbarRunningApps(); } diff --git a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt index c0ff1892b1..88ffeeaf99 100644 --- a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt +++ b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt @@ -20,10 +20,12 @@ import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM import android.content.ComponentName import android.content.Context import android.content.Intent +import android.content.res.Resources import android.os.Process import android.os.UserHandle import android.platform.test.rule.TestWatcher import android.testing.AndroidTestingRunner +import com.android.internal.R import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION import com.android.launcher3.model.data.AppInfo @@ -73,6 +75,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { @Mock private lateinit var mockIconCache: TaskIconCache @Mock private lateinit var mockRecentsModel: RecentsModel @Mock private lateinit var mockContext: Context + @Mock private lateinit var mockResources: Resources @Mock private lateinit var mockDesktopVisibilityController: DesktopVisibilityController private var taskListChangeId: Int = 1 @@ -88,6 +91,10 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { super.setup() userHandle = Process.myUserHandle() + // Set desktop mode supported + whenever(mockContext.getResources()).thenReturn(mockResources) + whenever(mockResources.getBoolean(R.bool.config_isDesktopModeSupported)).thenReturn(true) + whenever(mockRecentsModel.iconCache).thenReturn(mockIconCache) whenever(mockRecentsModel.unregisterRecentTasksChangedListener()).then { recentTasksChangedListener = null diff --git a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java index c213dbbf09..cbc8441b61 100644 --- a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +++ b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java @@ -30,9 +30,11 @@ import static org.mockito.Mockito.when; import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.Context; +import android.content.res.Resources; import androidx.test.filters.SmallTest; +import com.android.internal.R; import com.android.launcher3.util.LooperExecutor; import com.android.quickstep.util.GroupTask; import com.android.quickstep.views.TaskViewType; @@ -57,6 +59,8 @@ public class RecentTasksListTest { @Mock private Context mContext; @Mock + private Resources mResources; + @Mock private SystemUiProxy mSystemUiProxy; @Mock private TopTaskTracker mTopTaskTracker; @@ -69,6 +73,11 @@ public class RecentTasksListTest { MockitoAnnotations.initMocks(this); LooperExecutor mockMainThreadExecutor = mock(LooperExecutor.class); KeyguardManager mockKeyguardManager = mock(KeyguardManager.class); + + // Set desktop mode supported + when(mContext.getResources()).thenReturn(mResources); + when(mResources.getBoolean(R.bool.config_isDesktopModeSupported)).thenReturn(true); + mRecentTasksList = new RecentTasksList(mContext, mockMainThreadExecutor, mockKeyguardManager, mSystemUiProxy, mTopTaskTracker); }