diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java index e31b1d4075..f29980b6f9 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.java @@ -17,10 +17,10 @@ package com.android.launcher3.statehandlers; import static android.view.View.VISIBLE; -import static com.android.launcher3.LauncherState.BACKGROUND_APP; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.wm.shell.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; +import android.content.Context; import android.os.Debug; import android.util.Log; import android.view.View; @@ -30,14 +30,18 @@ import androidx.annotation.Nullable; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; +import com.android.launcher3.statemanager.BaseState; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; +import com.android.launcher3.views.ActivityContext; import com.android.quickstep.GestureState; import com.android.quickstep.SystemUiProxy; +import com.android.quickstep.fallback.RecentsState; import com.android.wm.shell.desktopmode.IDesktopTaskListener; import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; +import java.io.PrintWriter; import java.util.HashSet; import java.util.Set; @@ -49,7 +53,6 @@ public class DesktopVisibilityController { private static final String TAG = "DesktopVisController"; private static final boolean DEBUG = false; - private final Launcher mLauncher; private final Set mDesktopVisibilityListeners = new HashSet<>(); private final Set mTaskbarDesktopModeListeners = new HashSet<>(); @@ -61,23 +64,43 @@ public class DesktopVisibilityController { @Nullable private DesktopTaskListenerImpl mDesktopTaskListener; - public DesktopVisibilityController(Launcher launcher) { - mLauncher = launcher; + @Nullable + private Context mContext; + + public DesktopVisibilityController(@NonNull Context context) { + setContext(context); } - /** - * Register a listener with System UI to receive updates about desktop tasks state - */ - public void registerSystemUiListener() { - mDesktopTaskListener = new DesktopTaskListenerImpl(this, mLauncher.getDisplayId()); - SystemUiProxy.INSTANCE.get(mLauncher).setDesktopTaskListener(mDesktopTaskListener); + /** Sets the context and re-registers the System Ui listener */ + private void setContext(@Nullable Context context) { + unregisterSystemUiListener(); + mContext = context; + registerSystemUiListener(); + } + + /** Register a listener with System UI to receive updates about desktop tasks state */ + private void registerSystemUiListener() { + if (mContext == null) { + return; + } + if (mDesktopTaskListener != null) { + return; + } + mDesktopTaskListener = new DesktopTaskListenerImpl(this, mContext.getDisplayId()); + SystemUiProxy.INSTANCE.get(mContext).setDesktopTaskListener(mDesktopTaskListener); } /** * Clear listener from System UI that was set with {@link #registerSystemUiListener()} */ - public void unregisterSystemUiListener() { - SystemUiProxy.INSTANCE.get(mLauncher).setDesktopTaskListener(null); + private void unregisterSystemUiListener() { + if (mContext == null) { + return; + } + if (mDesktopTaskListener == null) { + return; + } + SystemUiProxy.INSTANCE.get(mContext).setDesktopTaskListener(null); mDesktopTaskListener.release(); mDesktopTaskListener = null; } @@ -126,6 +149,9 @@ public class DesktopVisibilityController { * it. */ public void setVisibleDesktopTasksCount(int visibleTasksCount) { + if (mContext == null) { + return; + } if (DEBUG) { Log.d(TAG, "setVisibleDesktopTasksCount: visibleTasksCount=" + visibleTasksCount + " currentValue=" + mVisibleDesktopTasksCount); @@ -141,7 +167,7 @@ public class DesktopVisibilityController { notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow); } - if (!WALLPAPER_ACTIVITY.isEnabled(mLauncher) && wasVisible != isVisible) { + if (!WALLPAPER_ACTIVITY.isEnabled(mContext) && wasVisible != isVisible) { // TODO: b/333533253 - Remove after flag rollout if (mVisibleDesktopTasksCount > 0) { setLauncherViewsVisibility(View.INVISIBLE); @@ -160,19 +186,33 @@ public class DesktopVisibilityController { } } + public void onLauncherStateChanged(LauncherState state) { + onLauncherStateChanged( + state, state == LauncherState.BACKGROUND_APP, state.isRecentsViewVisible); + } + + public void onLauncherStateChanged(RecentsState state) { + onLauncherStateChanged( + state, state == RecentsState.BACKGROUND_APP, state.isRecentsViewVisible()); + } + /** * Process launcher state change and update launcher view visibility based on desktop state */ - public void onLauncherStateChanged(LauncherState state) { + public void onLauncherStateChanged( + BaseState state, boolean isBackgroundAppState, boolean isRecentsViewVisible) { if (DEBUG) { Log.d(TAG, "onLauncherStateChanged: newState=" + state); } - setBackgroundStateEnabled(state == BACKGROUND_APP); + setBackgroundStateEnabled(isBackgroundAppState); // Desktop visibility tracks overview and background state separately - setOverviewStateEnabled(state != BACKGROUND_APP && state.isRecentsViewVisible); + setOverviewStateEnabled(!isBackgroundAppState && isRecentsViewVisible); } private void setOverviewStateEnabled(boolean overviewStateEnabled) { + if (mContext == null) { + return; + } if (DEBUG) { Log.d(TAG, "setOverviewStateEnabled: enabled=" + overviewStateEnabled + " currentValue=" + mInOverviewState); @@ -185,7 +225,7 @@ public class DesktopVisibilityController { notifyDesktopVisibilityListeners(areDesktopTasksVisibleNow); } - if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { + if (WALLPAPER_ACTIVITY.isEnabled(mContext)) { return; } // TODO: b/333533253 - Clean up after flag rollout @@ -203,13 +243,16 @@ public class DesktopVisibilityController { } private void notifyDesktopVisibilityListeners(boolean areDesktopTasksVisible) { + if (mContext == null) { + return; + } if (DEBUG) { Log.d(TAG, "notifyDesktopVisibilityListeners: visible=" + areDesktopTasksVisible); } for (DesktopVisibilityListener listener : mDesktopVisibilityListeners) { listener.onDesktopVisibilityChanged(areDesktopTasksVisible); } - DisplayController.handleInfoChangeForDesktopMode(mLauncher); + DisplayController.handleInfoChangeForDesktopMode(mContext); } private void notifyTaskbarDesktopModeListeners(boolean doesAnyTaskRequireTaskbarRounding) { @@ -295,22 +338,32 @@ public class DesktopVisibilityController { * TODO: b/333533253 - Remove after flag rollout */ private void setLauncherViewsVisibility(int visibility) { - if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { + if (mContext == null) { + return; + } + if (WALLPAPER_ACTIVITY.isEnabled(mContext)) { return; } if (DEBUG) { Log.d(TAG, "setLauncherViewsVisibility: visibility=" + visibility + " " + Debug.getCaller()); } - View workspaceView = mLauncher.getWorkspace(); - if (workspaceView != null) { - workspaceView.setVisibility(visibility); + if (!(mContext instanceof ActivityContext activity)) { + return; } - View dragLayer = mLauncher.getDragLayer(); + View dragLayer = activity.getDragLayer(); if (dragLayer != null) { dragLayer.setVisibility(visibility); } - if (mLauncher instanceof QuickstepLauncher ql && ql.getTaskbarUIController() != null + if (!(activity instanceof Launcher launcher)) { + return; + } + View workspaceView = launcher.getWorkspace(); + if (workspaceView != null) { + workspaceView.setVisibility(visibility); + } + if (launcher instanceof QuickstepLauncher ql + && ql.getTaskbarUIController() != null && mVisibleDesktopTasksCount != 0) { ql.getTaskbarUIController().onLauncherVisibilityChanged(visibility == VISIBLE); } @@ -320,7 +373,10 @@ public class DesktopVisibilityController { * TODO: b/333533253 - Remove after flag rollout */ private void markLauncherPaused() { - if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { + if (mContext == null) { + return; + } + if (WALLPAPER_ACTIVITY.isEnabled(mContext)) { return; } if (DEBUG) { @@ -337,7 +393,10 @@ public class DesktopVisibilityController { * TODO: b/333533253 - Remove after flag rollout */ private void markLauncherResumed() { - if (WALLPAPER_ACTIVITY.isEnabled(mLauncher)) { + if (mContext == null) { + return; + } + if (WALLPAPER_ACTIVITY.isEnabled(mContext)) { return; } if (DEBUG) { @@ -353,6 +412,22 @@ public class DesktopVisibilityController { } } + public void onDestroy() { + setContext(null); + } + + public void dumpLogs(String prefix, PrintWriter pw) { + pw.println(prefix + "DesktopVisibilityController:"); + + pw.println(prefix + "\tmDesktopVisibilityListeners=" + mDesktopVisibilityListeners); + pw.println(prefix + "\tmVisibleDesktopTasksCount=" + mVisibleDesktopTasksCount); + pw.println(prefix + "\tmInOverviewState=" + mInOverviewState); + pw.println(prefix + "\tmBackgroundStateEnabled=" + mBackgroundStateEnabled); + pw.println(prefix + "\tmGestureInProgress=" + mGestureInProgress); + pw.println(prefix + "\tmDesktopTaskListener=" + mDesktopTaskListener); + pw.println(prefix + "\tmContext=" + mContext); + } + /** A listener for when the user enters/exits Desktop Mode. */ public interface DesktopVisibilityListener { /** diff --git a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java index 06d9ee6c96..929e7936e0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/FallbackTaskbarUIController.java @@ -70,7 +70,6 @@ public class FallbackTaskbarUIController extends TaskbarUIController { @Override protected void init(TaskbarControllers taskbarControllers) { super.init(taskbarControllers); - mRecentsActivity.setTaskbarUIController(this); mRecentsActivity.getStateManager().addStateListener(mStateListener); } @@ -78,6 +77,7 @@ public class FallbackTaskbarUIController extends TaskbarUIController { @Override protected void onDestroy() { super.onDestroy(); + getRecentsView().setTaskLaunchListener(null); mRecentsActivity.setTaskbarUIController(null); mRecentsActivity.getStateManager().removeStateListener(mStateListener); } diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java index e4cc6bbd77..ea432f3d28 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchController.java @@ -23,9 +23,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.launcher3.R; -import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext; -import com.android.quickstep.LauncherActivityInterface; import com.android.quickstep.RecentsModel; import com.android.quickstep.util.DesktopTask; import com.android.quickstep.util.GroupTask; @@ -116,10 +114,8 @@ public final class KeyboardQuickSwitchController implements mQuickSwitchViewController = new KeyboardQuickSwitchViewController( mControllers, overlayContext, keyboardQuickSwitchView, mControllerCallbacks); - DesktopVisibilityController desktopController = - LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); final boolean onDesktop = - desktopController != null && desktopController.areDesktopTasksVisible(); + mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible(); if (mModel.isTaskListValid(mTaskListChangeId)) { // When we are opening the KQS with no focus override, check if the first task is diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 69da7b6c02..5513599a4f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -38,14 +38,12 @@ import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.InstanceIdSequence; import com.android.launcher3.model.data.ItemInfo; -import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.taskbar.bubbles.BubbleBarController; import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.OnboardingPrefs; import com.android.quickstep.HomeVisibilityState; -import com.android.quickstep.LauncherActivityInterface; import com.android.quickstep.RecentsAnimationCallbacks; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.GroupTask; @@ -128,8 +126,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController { @Override protected void onDestroy() { - super.onDestroy(); onLauncherVisibilityChanged(false); + super.onDestroy(); mTaskbarLauncherStateController.onDestroy(); mLauncher.setTaskbarUIController(null); @@ -235,11 +233,8 @@ public class LauncherTaskbarUIController extends TaskbarUIController { return null; } - DesktopVisibilityController desktopController = - LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); if (!WALLPAPER_ACTIVITY.isEnabled(mLauncher) - && desktopController != null - && desktopController.areDesktopTasksVisible()) { + && mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) { // TODO: b/333533253 - Remove after flag rollout isVisible = false; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 5f733b066e..6d80834447 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -100,6 +100,7 @@ import com.android.launcher3.model.data.TaskItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; +import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.taskbar.TaskbarAutohideSuspendController.AutohideSuspendFlag; import com.android.launcher3.taskbar.TaskbarTranslationController.TransitionCallback; import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController; @@ -140,7 +141,6 @@ import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.VibratorWrapper; import com.android.launcher3.util.ViewCache; import com.android.launcher3.views.ActivityContext; -import com.android.quickstep.LauncherActivityInterface; import com.android.quickstep.NavHandle; import com.android.quickstep.RecentsModel; import com.android.quickstep.SystemUiProxy; @@ -223,7 +223,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { public TaskbarActivityContext(Context windowContext, @Nullable Context navigationBarPanelContext, DeviceProfile launcherDp, TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider - unfoldTransitionProgressProvider) { + unfoldTransitionProgressProvider, + @NonNull DesktopVisibilityController desktopVisibilityController) { super(windowContext); mNavigationBarPanelContext = navigationBarPanelContext; @@ -336,17 +337,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext { new VoiceInteractionWindowController(this), new TaskbarTranslationController(this), new TaskbarSpringOnStashController(this), - new TaskbarRecentAppsController( - this, - RecentsModel.INSTANCE.get(this), - LauncherActivityInterface.INSTANCE::getDesktopVisibilityController), + new TaskbarRecentAppsController(this, RecentsModel.INSTANCE.get(this)), TaskbarEduTooltipController.newInstance(this), new KeyboardQuickSwitchController(), - new TaskbarPinningController(this, () -> - DisplayController.isInDesktopMode(this)), + new TaskbarPinningController(this), bubbleControllersOptional, - new TaskbarDesktopModeController( - LauncherActivityInterface.INSTANCE::getDesktopVisibilityController)); + new TaskbarDesktopModeController(desktopVisibilityController)); + mLauncherPrefs = LauncherPrefs.get(this); } @@ -1203,14 +1200,21 @@ public class TaskbarActivityContext extends BaseTaskbarContext { mControllers.uiController.startSplitSelection(splitSelectSource); } + boolean areDesktopTasksVisible() { + return mControllers != null + && mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible(); + } + protected void onTaskbarIconClicked(View view) { TaskbarUIController taskbarUIController = mControllers.uiController; RecentsView recents = taskbarUIController.getRecentsView(); boolean shouldCloseAllOpenViews = true; Object tag = view.getTag(); if (tag instanceof GroupTask groupTask) { - handleGroupTaskLaunch(groupTask, /* remoteTransition = */ null, - DisplayController.isInDesktopMode(this)); + handleGroupTaskLaunch( + groupTask, + /* remoteTransition= */ null, + areDesktopTasksVisible()); mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true); } else if (tag instanceof FolderInfo) { // Tapping an expandable folder icon on Taskbar diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt index 4ac7514f2f..d6ce3a43fd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt @@ -102,7 +102,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { shadowAlpha = LIGHT_THEME_SHADOW_ALPHA } - if (DisplayController.isInDesktopMode(context)) { + if (context.areDesktopTasksVisible()) { fullCornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context) cornerRadius = fullCornerRadius } else { @@ -200,7 +200,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { mapRange( scale, 0f, - res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin).toFloat() + res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin).toFloat(), ) .toInt() shadowBlur = @@ -245,7 +245,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { -mapRange( 1f - progress, 0f, - if (isAnimatingPinning) 0f else stashedHandleHeight / 2f + if (isAnimatingPinning) 0f else stashedHandleHeight / 2f, ) // Draw shadow. @@ -255,7 +255,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { shadowBlur, 0f, keyShadowDistance, - setColorAlphaBound(Color.BLACK, Math.round(newShadowAlpha)) + setColorAlphaBound(Color.BLACK, Math.round(newShadowAlpha)), ) strokePaint.alpha = (paint.alpha * strokeAlpha) / 255 @@ -263,7 +263,7 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { transientBackgroundBounds.left + halfWidthDelta + hotseatOffsetLeft, bottom - newBackgroundHeight + hotseatOffsetTop, transientBackgroundBounds.right - halfWidthDelta + hotseatOffsetRight, - bottom + hotseatOffsetBottom + bottom + hotseatOffsetBottom, ) val horizontalInset = fullWidth * widthInsetPercentage lastDrawnTransientRect.inset(horizontalInset, 0f) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 34ab9f0d67..56fd2bb66d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -25,7 +25,6 @@ import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.taskbar.allapps.TaskbarAllAppsController; import com.android.launcher3.taskbar.bubbles.BubbleControllers; import com.android.launcher3.taskbar.overlay.TaskbarOverlayController; -import com.android.launcher3.util.DisplayController; import com.android.systemui.shared.rotation.RotationButtonController; import java.io.PrintWriter; @@ -194,13 +193,17 @@ public class TaskbarControllers { voiceInteractionWindowController }; - if (DisplayController.isInDesktopMode(taskbarActivityContext)) { + if (taskbarDesktopModeController.getAreDesktopTasksVisible()) { mCornerRoundness.updateValue(taskbarDesktopModeController.getTaskbarCornerRoundness( mSharedState.showCornerRadiusInDesktopMode)); } else { mCornerRoundness.updateValue(TaskbarBackgroundRenderer.MAX_ROUNDNESS); } + onPostInit(); + } + @VisibleForTesting + public void onPostInit() { mAreAllControllersInitialized = true; for (Runnable postInitCallback : mPostInitCallbacks) { postInitCallback.run(); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt index a376531b11..47a35c55ab 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDesktopModeController.kt @@ -22,18 +22,18 @@ import com.android.launcher3.taskbar.TaskbarBackgroundRenderer.Companion.MAX_ROU /** Handles Taskbar in Desktop Windowing mode. */ class TaskbarDesktopModeController( - private val desktopVisibilityControllerProvider: () -> DesktopVisibilityController? + private val desktopVisibilityController: DesktopVisibilityController ) : TaskbarDesktopModeListener { private lateinit var taskbarControllers: TaskbarControllers private lateinit var taskbarSharedState: TaskbarSharedState - private val desktopVisibilityController: DesktopVisibilityController? - get() = desktopVisibilityControllerProvider() + val areDesktopTasksVisible: Boolean + get() = desktopVisibilityController.areDesktopTasksVisible() fun init(controllers: TaskbarControllers, sharedState: TaskbarSharedState) { taskbarControllers = controllers taskbarSharedState = sharedState - desktopVisibilityController?.registerTaskbarDesktopModeListener(this) + desktopVisibilityController.registerTaskbarDesktopModeListener(this) } override fun onTaskbarCornerRoundingUpdate(doesAnyTaskRequireTaskbarRounding: Boolean) { @@ -50,5 +50,5 @@ class TaskbarDesktopModeController( } } - fun onDestroy() = desktopVisibilityController?.unregisterTaskbarDesktopModeListener(this) + fun onDestroy() = desktopVisibilityController.unregisterTaskbarDesktopModeListener(this) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index 5bbf4b2a2a..fc307b2e88 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -74,14 +74,12 @@ import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.shortcuts.DeepShortcutView; import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider; -import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.views.BubbleTextHolder; -import com.android.quickstep.LauncherActivityInterface; import com.android.quickstep.util.GroupTask; import com.android.quickstep.util.LogUtils; import com.android.quickstep.util.MultiValueUpdateListener; @@ -344,12 +342,9 @@ public class TaskbarDragController extends DragController im protected void callOnDragStart() { super.callOnDragStart(); // TODO(297921594) clean it up when taskbar to desktop drag is implemented. - DesktopVisibilityController desktopController = - LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); - // Pre-drag has ended, start the global system drag. - if (mDisallowGlobalDrag || (desktopController != null - && desktopController.areDesktopTasksVisible())) { + if (mDisallowGlobalDrag + || mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) { AbstractFloatingView.closeAllOpenViewsExcept(mActivity, TYPE_TASKBAR_ALL_APPS); return; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index 63fae8cad8..81ca940981 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -48,7 +48,6 @@ import com.android.launcher3.anim.AnimatorListeners; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.uioverrides.QuickstepLauncher; -import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.MultiPropertyFactory.MultiProperty; import com.android.quickstep.RecentsAnimationCallbacks; import com.android.quickstep.RecentsAnimationController; @@ -592,7 +591,8 @@ public class TaskbarLauncherStateController { float cornerRoundness = isInLauncher ? 0 : 1; - if (DisplayController.isInDesktopMode(mLauncher) && mControllers.getSharedState() != null) { + if (mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible() + && mControllers.getSharedState() != null) { cornerRoundness = mControllers.taskbarDesktopModeController.getTaskbarCornerRoundness( mControllers.getSharedState().showCornerRadiusInDesktopMode); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index 8c87fa65d5..5ce8788e00 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -60,6 +60,7 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; import com.android.launcher3.anim.AnimatorPlaybackController; +import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarNavButtonCallbacks; import com.android.launcher3.taskbar.unfold.NonDestroyableScopedUnfoldTransitionProgressProvider; @@ -209,12 +210,14 @@ public class TaskbarManager { } }; + @NonNull private final DesktopVisibilityController mDesktopVisibilityController; + @SuppressLint("WrongConstant") public TaskbarManager( Context context, AllAppsActionManager allAppsActionManager, - TaskbarNavButtonCallbacks navCallbacks) { - + TaskbarNavButtonCallbacks navCallbacks, + @NonNull DesktopVisibilityController desktopVisibilityController) { Display display = context.getSystemService(DisplayManager.class).getDisplay(DEFAULT_DISPLAY); mContext = context.createWindowContext(display, @@ -224,6 +227,7 @@ public class TaskbarManager { mNavigationBarPanelContext = ENABLE_TASKBAR_NAVBAR_UNIFICATION ? context.createWindowContext(display, TYPE_NAVIGATION_BAR_PANEL, null) : null; + mDesktopVisibilityController = desktopVisibilityController; if (enableTaskbarNoRecreate()) { mWindowManager = mContext.getSystemService(WindowManager.class); mTaskbarRootLayout = new FrameLayout(mContext) { @@ -470,7 +474,7 @@ public class TaskbarManager { if (enableTaskbarNoRecreate() || mTaskbarActivityContext == null) { mTaskbarActivityContext = new TaskbarActivityContext(mContext, mNavigationBarPanelContext, dp, mNavButtonController, - mUnfoldProgressProvider); + mUnfoldProgressProvider, mDesktopVisibilityController); } else { mTaskbarActivityContext.updateDeviceProfile(dp); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt index 6c9cc642be..1867cd08c0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPinningController.kt @@ -32,10 +32,8 @@ import com.android.launcher3.taskbar.TaskbarDividerPopupView.Companion.createAnd import java.io.PrintWriter /** Controls taskbar pinning through a popup view. */ -class TaskbarPinningController( - private val context: TaskbarActivityContext, - private val isInDesktopModeProvider: () -> Boolean, -) : TaskbarControllers.LoggableTaskbarController { +class TaskbarPinningController(private val context: TaskbarActivityContext) : + TaskbarControllers.LoggableTaskbarController { private lateinit var controllers: TaskbarControllers private lateinit var taskbarSharedState: TaskbarSharedState @@ -58,7 +56,7 @@ class TaskbarPinningController( return } val shouldPinTaskbar = - if (isInDesktopModeProvider()) { + if (controllers.taskbarDesktopModeController.areDesktopTasksVisible) { !launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE) } else { !launcherPrefs.get(TASKBAR_PINNING) @@ -119,7 +117,7 @@ class TaskbarPinningController( dragLayerController.taskbarBackgroundProgress.animateToValue(animateToValue), taskbarViewController.taskbarIconTranslationYForPinning.animateToValue(animateToValue), taskbarViewController.taskbarIconScaleForPinning.animateToValue(animateToValue), - taskbarViewController.taskbarIconTranslationXForPinning.animateToValue(animateToValue) + taskbarViewController.taskbarIconTranslationXForPinning.animateToValue(animateToValue), ) animatorSet.interpolator = Interpolators.EMPHASIZED @@ -134,10 +132,10 @@ class TaskbarPinningController( @VisibleForTesting fun recreateTaskbarAndUpdatePinningValue() { updateIsAnimatingTaskbarPinningAndNotifyTaskbarDragLayer(false) - if (isInDesktopModeProvider()) { + if (controllers.taskbarDesktopModeController.areDesktopTasksVisible) { launcherPrefs.put( TASKBAR_PINNING_IN_DESKTOP_MODE, - !launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE) + !launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE), ) } else { launcherPrefs.put(TASKBAR_PINNING, !launcherPrefs.get(TASKBAR_PINNING)) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java index 332eb9519e..2cee77d527 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java @@ -189,7 +189,7 @@ public class TaskbarPopupController implements TaskbarControllers.LoggableTaskba // here will reflect in the popup ArrayList shortcuts = new ArrayList<>(); shortcuts.add(APP_INFO); - if (!mControllers.taskbarRecentAppsController.isInDesktopMode()) { + if (!mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) { shortcuts.addAll(mControllers.uiController.getSplitMenuOptions().toList()); } if (com.android.wm.shell.Flags.enableBubbleAnything()) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt index 737d03198e..72bdafeacb 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentAppsController.kt @@ -21,7 +21,6 @@ import com.android.launcher3.Flags.enableRecentsInTaskbar 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.statehandlers.DesktopVisibilityController import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController import com.android.launcher3.util.CancellableTask import com.android.quickstep.RecentsModel @@ -36,13 +35,8 @@ import java.io.PrintWriter * - When in Fullscreen mode: show the N most recent Tasks * - When in Desktop Mode: show the currently running (open) Tasks */ -class TaskbarRecentAppsController( - context: Context, - private val recentsModel: RecentsModel, - // Pass a provider here instead of the actual DesktopVisibilityController instance since that - // instance might not be available when this constructor is called. - private val desktopVisibilityControllerProvider: () -> DesktopVisibilityController?, -) : LoggableTaskbarController { +class TaskbarRecentAppsController(context: Context, private val recentsModel: RecentsModel) : + LoggableTaskbarController { var canShowRunningApps = DesktopModeStatus.canEnterDesktopMode(context) && @@ -78,19 +72,16 @@ class TaskbarRecentAppsController( var shownTasks: List = emptyList() private set - private val desktopVisibilityController: DesktopVisibilityController? - get() = desktopVisibilityControllerProvider() - - val isInDesktopMode: Boolean - get() = desktopVisibilityController?.areDesktopTasksVisible() ?: false - val runningTaskIds: Set /** * Returns the task IDs of apps that should be indicated as "running" to the user. * Specifically, we return all the open tasks if we are in Desktop mode, else emptySet(). */ get() { - if (!canShowRunningApps || !isInDesktopMode) { + if ( + !canShowRunningApps || + !controllers.taskbarDesktopModeController.areDesktopTasksVisible + ) { return emptySet() } val tasks = desktopTask?.tasks ?: return emptySet() @@ -102,7 +93,10 @@ class TaskbarRecentAppsController( * Returns the task IDs for the tasks that should be indicated as "minimized" to the user. */ get() { - if (!canShowRunningApps || !isInDesktopMode) { + if ( + !canShowRunningApps || + !controllers.taskbarDesktopModeController.areDesktopTasksVisible + ) { return emptySet() } val desktopTasks = desktopTask?.tasks ?: return emptySet() @@ -124,7 +118,7 @@ class TaskbarRecentAppsController( controllers = taskbarControllers if (canShowRunningApps || canShowRecentApps) { recentsModel.registerRecentTasksChangedListener(recentTasksChangedListener) - reloadRecentTasksIfNeeded() + controllers.runAfterInit { reloadRecentTasksIfNeeded() } } } @@ -137,8 +131,10 @@ class TaskbarRecentAppsController( /** Called to update hotseatItems, in order to de-dupe them from Recent/Running tasks later. */ fun updateHotseatItemInfos(hotseatItems: Array): Array { // Ignore predicted apps - we show running or recent apps instead. + val areDesktopTasksVisible = controllers.taskbarDesktopModeController.areDesktopTasksVisible val removePredictions = - (isInDesktopMode && canShowRunningApps) || (!isInDesktopMode && canShowRecentApps) + (areDesktopTasksVisible && canShowRunningApps) || + (!areDesktopTasksVisible && canShowRecentApps) if (!removePredictions) { shownHotseatItems = hotseatItems.filterNotNull() onRecentsOrHotseatChanged() @@ -150,11 +146,11 @@ class TaskbarRecentAppsController( .filter { itemInfo -> !itemInfo.isPredictedItem } .toMutableList() - if (isInDesktopMode && canShowRunningApps) { + if (areDesktopTasksVisible && canShowRunningApps) { shownHotseatItems = updateHotseatItemsFromRunningTasks( getOrderedAndWrappedDesktopTasks(), - shownHotseatItems + shownHotseatItems, ) } @@ -199,7 +195,7 @@ class TaskbarRecentAppsController( val oldShownTasks = shownTasks orderedRunningTaskIds = updateOrderedRunningTaskIds() shownTasks = - if (isInDesktopMode) { + if (controllers.taskbarDesktopModeController.areDesktopTasksVisible) { computeShownRunningTasks() } else { computeShownRecentTasks() @@ -281,7 +277,7 @@ class TaskbarRecentAppsController( private fun dedupeHotseatTasks( groupTasks: List, - shownHotseatItems: List + shownHotseatItems: List, ): List { val hotseatPackages = shownHotseatItems.map { item -> item.targetPackage } return groupTasks.filter { groupTask -> @@ -296,7 +292,7 @@ class TaskbarRecentAppsController( */ private fun updateHotseatItemsFromRunningTasks( groupTasks: List, - shownHotseatItems: List + shownHotseatItems: List, ): List = shownHotseatItems.map { itemInfo -> if (itemInfo is TaskItemInfo) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 60e65b34a2..2da103c0df 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -63,10 +63,8 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.anim.AnimatorListeners; -import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.MultiPropertyFactory.MultiProperty; -import com.android.quickstep.LauncherActivityInterface; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.SystemUiFlagUtils; @@ -1079,10 +1077,9 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba } // Do not stash if hardware keyboard is attached, in 3 button nav and desktop windowing mode - DesktopVisibilityController visibilityController = - LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); - if (visibilityController != null && mActivity.isHardwareKeyboard() - && mActivity.isThreeButtonNav() && visibilityController.areDesktopTasksVisible()) { + if (mActivity.isHardwareKeyboard() + && mActivity.isThreeButtonNav() + && mControllers.taskbarDesktopModeController.getAreDesktopTasksVisible()) { return false; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index aa3e6bffb8..292b9ed06d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -206,7 +206,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mModelCallbacks.init(controllers); if (mActivity.isUserSetupComplete() && sEnableModelLoadingForTests) { // Only load the callbacks if user setup is completed - LauncherAppState.getInstance(mActivity).getModel().addCallbacksAndLoad(mModelCallbacks); + controllers.runAfterInit(() -> LauncherAppState.getInstance(mActivity).getModel() + .addCallbacksAndLoad(mModelCallbacks)); } mTaskbarNavButtonTranslationY = controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY(); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 0b385d9a32..0e51851255 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -64,8 +64,8 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.QUICK_SWITCH_FROM_HOME_FALLBACK; import static com.android.quickstep.util.AnimUtils.completeRunnableListCallback; import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SPLIT; -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.shared.desktopmode.DesktopModeFlags.WALLPAPER_ACTIVITY; import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50; import android.animation.Animator; @@ -202,8 +202,6 @@ 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; - import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -216,6 +214,8 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import java.util.stream.Stream; +import kotlin.Unit; + public class QuickstepLauncher extends Launcher implements RecentsViewContainer, SystemShortcut.BubbleActivityStarter { private static final boolean TRACE_LAYOUTS = @@ -229,7 +229,6 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, private FixedContainerItems mAllAppsPredictions; private HotseatPredictionController mHotseatPredictionController; private DepthController mDepthController; - private @Nullable DesktopVisibilityController mDesktopVisibilityController; private QuickstepTransitionManager mAppTransitionManager; private OverviewActionsView mActionsView; @@ -303,8 +302,6 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, mTISBindHelper = new TISBindHelper(this, this::onTISConnected); mDepthController = new DepthController(this); if (DesktopModeStatus.canEnterDesktopMode(this)) { - mDesktopVisibilityController = new DesktopVisibilityController(this); - mDesktopVisibilityController.registerSystemUiListener(); mSplitSelectStateController.initSplitFromDesktopController(this, overviewComponentObserver); } @@ -556,10 +553,6 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, mLauncherUnfoldAnimationController.onDestroy(); } - if (mDesktopVisibilityController != null) { - mDesktopVisibilityController.unregisterSystemUiListener(); - } - if (mSplitSelectStateController != null) { mSplitSelectStateController.onDestroy(); } @@ -1013,10 +1006,11 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, @Override public void setResumed() { + DesktopVisibilityController desktopVisibilityController = getDesktopVisibilityController(); if (!WALLPAPER_ACTIVITY.isEnabled(this) - && mDesktopVisibilityController != null - && mDesktopVisibilityController.areDesktopTasksVisible() - && !mDesktopVisibilityController.isRecentsGestureInProgress()) { + && desktopVisibilityController != null + && desktopVisibilityController.areDesktopTasksVisible() + && !desktopVisibilityController.isRecentsGestureInProgress()) { // Return early to skip setting activity to appear as resumed // TODO: b/333533253 - Remove after flag rollout return; @@ -1156,8 +1150,9 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, } @Nullable + @Override public DesktopVisibilityController getDesktopVisibilityController() { - return mDesktopVisibilityController; + return mTISBindHelper.getDesktopVisibilityController(); } @Nullable @@ -1347,8 +1342,9 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, @Override public boolean areDesktopTasksVisible() { - if (mDesktopVisibilityController != null) { - return mDesktopVisibilityController.areDesktopTasksVisible(); + DesktopVisibilityController desktopVisibilityController = getDesktopVisibilityController(); + if (desktopVisibilityController != null) { + return desktopVisibilityController.areDesktopTasksVisible(); } return false; } diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java index 777761b0a3..a23f90fc45 100644 --- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java +++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java @@ -131,7 +131,9 @@ public abstract class BaseContainerInterface implem public boolean isRecentsViewVisible() { return getStateManager().getState().isRecentsViewVisible(); } + + @Nullable + @Override + public DesktopVisibilityController getDesktopVisibilityController() { + return mTISBindHelper.getDesktopVisibilityController(); + } } diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index 1be60dee14..8adc11ac10 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -68,7 +68,7 @@ public class RemoteTargetGluer { */ public RemoteTargetGluer(Context context, BaseContainerInterface sizingStrategy) { DesktopVisibilityController desktopVisibilityController = - LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); + sizingStrategy.getDesktopVisibilityController(); if (desktopVisibilityController != null) { int visibleTasksCount = desktopVisibilityController.getVisibleDesktopTasksCount(); if (visibleTasksCount > 0) { diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 4587bdd0a4..b69f53a23d 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -94,6 +94,7 @@ import com.android.launcher3.LauncherPrefs; import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.provider.RestoreDbTask; +import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.statemanager.StatefulActivity; import com.android.launcher3.taskbar.TaskbarActivityContext; import com.android.launcher3.taskbar.TaskbarManager; @@ -453,6 +454,18 @@ public class TouchInteractionService extends Service { return tis.mTaskbarManager; } + /** + * Returns the {@link DesktopVisibilityController} + *

+ * Returns {@code null} if TouchInteractionService is not connected + */ + @Nullable + public DesktopVisibilityController getDesktopVisibilityController() { + TouchInteractionService tis = mTis.get(); + if (tis == null) return null; + return tis.mDesktopVisibilityController; + } + @VisibleForTesting public void injectFakeTrackpadForTesting() { TouchInteractionService tis = mTis.get(); @@ -628,6 +641,8 @@ public class TouchInteractionService extends Service { private NavigationMode mGestureStartNavMode = null; + private DesktopVisibilityController mDesktopVisibilityController; + @Override public void onCreate() { super.onCreate(); @@ -648,7 +663,9 @@ public class TouchInteractionService extends Service { mInputDeviceListener.onInputDeviceAdded(inputDeviceId); } } - mTaskbarManager = new TaskbarManager(this, mAllAppsActionManager, mNavCallbacks); + mDesktopVisibilityController = new DesktopVisibilityController(this); + mTaskbarManager = new TaskbarManager( + this, mAllAppsActionManager, mNavCallbacks, mDesktopVisibilityController); mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer(); // Call runOnUserUnlocked() before any other callbacks to ensure everything is initialized. @@ -743,8 +760,8 @@ public class TouchInteractionService extends Service { private void onOverviewTargetChange(boolean isHomeAndOverviewSame) { mAllAppsActionManager.setHomeAndOverviewSame(isHomeAndOverviewSame); - StatefulActivity newOverviewActivity = mOverviewComponentObserver.getActivityInterface() - .getCreatedContainer(); + StatefulActivity newOverviewActivity = + mOverviewComponentObserver.getActivityInterface().getCreatedContainer(); if (newOverviewActivity != null) { mTaskbarManager.setActivity(newOverviewActivity); } @@ -808,6 +825,7 @@ public class TouchInteractionService extends Service { mTrackpadsConnected.clear(); mTaskbarManager.destroy(); + mDesktopVisibilityController.onDestroy(); sConnected = false; ScreenOnTracker.INSTANCE.get(this).removeListener(mScreenOnListener); @@ -1654,6 +1672,7 @@ public class TouchInteractionService extends Service { createdOverviewActivity.getDeviceProfile().dump(this, "", pw); } mTaskbarManager.dumpLogs("", pw); + mDesktopVisibilityController.dumpLogs("", pw); pw.println("AssistStateManager:"); AssistStateManager.INSTANCE.get(this).dump("\t", pw); SystemUiProxy.INSTANCE.get(this).dump(pw); diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index f4a2738fef..e67a9bc1b6 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -253,6 +253,9 @@ public class FallbackRecentsView extends RecentsView {}); + } + + @Override + public void close() { + super.close(); + mTISBindHelper.onDestroy(); } @Override @@ -53,7 +61,7 @@ public class SystemWindowManagerProxy extends WindowManagerProxy { @Override public boolean isInDesktopMode() { DesktopVisibilityController desktopController = - LauncherActivityInterface.INSTANCE.getDesktopVisibilityController(); + mTISBindHelper.getDesktopVisibilityController(); return desktopController != null && desktopController.areDesktopTasksVisible(); } diff --git a/quickstep/src/com/android/quickstep/util/TISBindHelper.java b/quickstep/src/com/android/quickstep/util/TISBindHelper.java index 9a010429d3..b57360410e 100644 --- a/quickstep/src/com/android/quickstep/util/TISBindHelper.java +++ b/quickstep/src/com/android/quickstep/util/TISBindHelper.java @@ -25,6 +25,7 @@ import android.util.Log; import androidx.annotation.Nullable; +import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.taskbar.TaskbarManager; import com.android.quickstep.OverviewCommandHelper; import com.android.quickstep.TouchInteractionService; @@ -108,6 +109,11 @@ public class TISBindHelper implements ServiceConnection { return mBinder == null ? null : mBinder.getTaskbarManager(); } + @Nullable + public DesktopVisibilityController getDesktopVisibilityController() { + return mBinder == null ? null : mBinder.getDesktopVisibilityController(); + } + /** * Sets flag whether a predictive back-to-home animation is in progress */ diff --git a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java index 060c71e446..8f194442d0 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java +++ b/quickstep/src/com/android/quickstep/views/RecentsViewContainer.java @@ -26,8 +26,11 @@ import android.view.MotionEvent; import android.view.View; import android.view.Window; +import androidx.annotation.Nullable; + import com.android.launcher3.BaseActivity; import com.android.launcher3.logger.LauncherAtom; +import com.android.launcher3.statehandlers.DesktopVisibilityController; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.ScrimView; @@ -198,4 +201,7 @@ public interface RecentsViewContainer extends ActivityContext { .setOrientationHandler(orientationForLogging)) .build()); } + + @Nullable + DesktopVisibilityController getDesktopVisibilityController(); } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt index bbcf566e06..cb5e464dde 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarUnitTestRule.kt @@ -26,6 +26,7 @@ import android.provider.Settings.Secure.USER_SETUP_COMPLETE import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.ServiceTestRule import com.android.launcher3.LauncherAppState +import com.android.launcher3.statehandlers.DesktopVisibilityController import com.android.launcher3.taskbar.TaskbarActivityContext import com.android.launcher3.taskbar.TaskbarManager import com.android.launcher3.taskbar.TaskbarNavButtonController.TaskbarNavButtonCallbacks @@ -143,6 +144,7 @@ class TaskbarUnitTestRule( PendingIntent(IIntentSender.Default()) }, object : TaskbarNavButtonCallbacks {}, + DesktopVisibilityController(context), ) { override fun recreateTaskbar() { super.recreateTaskbar() diff --git a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt index 88ffeeaf99..b67bc5a952 100644 --- a/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt +++ b/quickstep/tests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt @@ -31,7 +31,6 @@ import com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDIC import com.android.launcher3.model.data.AppInfo import com.android.launcher3.model.data.ItemInfo import com.android.launcher3.model.data.TaskItemInfo -import com.android.launcher3.statehandlers.DesktopVisibilityController import com.android.quickstep.RecentsModel import com.android.quickstep.RecentsModel.RecentTasksChangedListener import com.android.quickstep.TaskIconCache @@ -66,9 +65,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { // Update canShowRunningAndRecentAppsAtInit before setUp() is called for each test. canShowRunningAndRecentAppsAtInit = description.methodName !in - listOf( - "canShowRunningAndRecentAppsAtInitIsFalse_getTasksNeverCalled", - ) + listOf("canShowRunningAndRecentAppsAtInitIsFalse_getTasksNeverCalled") } } @@ -76,7 +73,6 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { @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 @@ -100,13 +96,11 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { recentTasksChangedListener = null it } - recentAppsController = - TaskbarRecentAppsController(mockContext, mockRecentsModel) { - mockDesktopVisibilityController - } + recentAppsController = TaskbarRecentAppsController(mockContext, mockRecentsModel) recentAppsController.canShowRunningApps = canShowRunningAndRecentAppsAtInit recentAppsController.canShowRecentApps = canShowRunningAndRecentAppsAtInit recentAppsController.init(taskbarControllers) + taskbarControllers.onPostInit() recentTasksChangedListener = if (canShowRunningAndRecentAppsAtInit) { @@ -133,7 +127,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2), runningTasks = listOf(createTask(1, RUNNING_APP_PACKAGE_1)), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) verify(mockRecentsModel, never()).getTasks(any>>()) } @@ -147,7 +141,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2), runningTasks = listOf(createTask(1, RUNNING_APP_PACKAGE_1)), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) // Verify that getTasks() was not called again after the init(). verify(mockRecentsModel, times(1)).getTasks(any>>()) @@ -162,7 +156,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = hotseatPackages, runningTasks = emptyList(), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(newHotseatItems.map { it?.targetPackage }) .containsExactlyElementsIn(hotseatPackages) @@ -177,7 +171,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = hotseatPackages, runningTasks = emptyList(), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(newHotseatItems.map { it?.targetPackage }) .containsExactlyElementsIn(hotseatPackages) @@ -191,7 +185,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2, PREDICTED_PACKAGE_1), runningTasks = emptyList(), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val expectedPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2) assertThat(newHotseatItems.map { it?.targetPackage }) @@ -206,7 +200,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2), runningTasks = listOf(createTask(id = 1, HOTSEAT_PACKAGE_1)), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(newHotseatItems).hasLength(2) @@ -226,9 +220,9 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { runningTasks = listOf( createTask(id = 1, HOTSEAT_PACKAGE_1), - createTask(id = 2, HOTSEAT_PACKAGE_1) + createTask(id = 2, HOTSEAT_PACKAGE_1), ), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) // First task is in Hotseat Items @@ -251,7 +245,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2, PREDICTED_PACKAGE_1), runningTasks = emptyList(), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val expectedPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2) assertThat(newHotseatItems.map { it?.targetPackage }) @@ -267,9 +261,9 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { runningTasks = listOf( createTask(id = 1, RUNNING_APP_PACKAGE_1), - createTask(id = 2, RUNNING_APP_PACKAGE_2) + createTask(id = 2, RUNNING_APP_PACKAGE_2), ), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(recentAppsController.shownTasks).isEmpty() } @@ -281,7 +275,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2, PREDICTED_PACKAGE_1), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) assertThat(recentAppsController.shownTasks).isEmpty() } @@ -294,9 +288,9 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { runningTasks = listOf( createTask(id = 1, RUNNING_APP_PACKAGE_1), - createTask(id = 2, RUNNING_APP_PACKAGE_2) + createTask(id = 2, RUNNING_APP_PACKAGE_2), ), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(recentAppsController.shownTasks).isEmpty() assertThat(recentAppsController.minimizedTaskIds).isEmpty() @@ -308,7 +302,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) assertThat(recentAppsController.shownTasks).isEmpty() } @@ -321,7 +315,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val shownTasks = recentAppsController.shownTasks.map { it.task1 } assertThat(shownTasks).containsExactlyElementsIn(listOf(task1, task2)) @@ -335,7 +329,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(recentAppsController.runningTaskIds).isEmpty() assertThat(recentAppsController.minimizedTaskIds).isEmpty() @@ -349,7 +343,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(recentAppsController.runningTaskIds).containsExactlyElementsIn(listOf(1, 2)) assertThat(recentAppsController.minimizedTaskIds).isEmpty() @@ -362,12 +356,12 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { listOf( createTask(id = 1, HOTSEAT_PACKAGE_1), createTask(id = 2, RUNNING_APP_PACKAGE_1), - createTask(id = 3, RUNNING_APP_PACKAGE_2) + createTask(id = 3, RUNNING_APP_PACKAGE_2), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(HOTSEAT_PACKAGE_1, HOTSEAT_PACKAGE_2), runningTasks = runningTasks, - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) assertThat(recentAppsController.runningTaskIds).containsExactlyElementsIn(listOf(1, 2, 3)) assertThat(recentAppsController.minimizedTaskIds).isEmpty() @@ -383,7 +377,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = runningTasks, - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(recentAppsController.runningTaskIds).containsExactly(1, 2, 3) assertThat(recentAppsController.minimizedTaskIds).containsExactly(3) @@ -397,7 +391,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) assertThat(recentAppsController.runningTaskIds).containsExactlyElementsIn(listOf(1, 2)) } @@ -410,13 +404,13 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task2, task1), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val shownTasks = recentAppsController.shownTasks.map { it.task1 } @@ -431,13 +425,13 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task2, task1), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val shownTasks = recentAppsController.shownTasks.map { it.task1 } @@ -452,17 +446,17 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(RUNNING_APP_PACKAGE_1), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) updateRecentTasks( // Trigger a recent-tasks change before calling updateHotseatItems() runningTasks = listOf(task2, task1), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = listOf(RUNNING_APP_PACKAGE_1), runningTasks = listOf(task2, task1), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val newHotseatItems = recentAppsController.shownHotseatItems @@ -479,12 +473,12 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2, RECENT_PACKAGE_3) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2, RECENT_PACKAGE_3), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_2, RECENT_PACKAGE_3, RECENT_PACKAGE_1) + recentTaskPackages = listOf(RECENT_PACKAGE_2, RECENT_PACKAGE_3, RECENT_PACKAGE_1), ) val shownPackages = recentAppsController.shownTasks.flatMap { it.packageNames } // Most recent packages, minus the currently running one (RECENT_PACKAGE_1). @@ -500,12 +494,12 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task2, task1, task3), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val shownPackages = recentAppsController.shownTasks.flatMap { it.packageNames } val expectedOrder = @@ -519,12 +513,12 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_3, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_3, RECENT_PACKAGE_2), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_2, RECENT_PACKAGE_3, RECENT_PACKAGE_1) + recentTaskPackages = listOf(RECENT_PACKAGE_2, RECENT_PACKAGE_3, RECENT_PACKAGE_1), ) val shownPackages = recentAppsController.shownTasks.flatMap { it.packageNames } // Most recent packages, minus the currently running one (RECENT_PACKAGE_1). @@ -540,12 +534,12 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1, task2, task3), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task2, task1), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) val shownPackages = recentAppsController.shownTasks.flatMap { it.packageNames } assertThat(shownPackages).isEqualTo(listOf(RUNNING_APP_PACKAGE_1, RUNNING_APP_PACKAGE_2)) @@ -557,12 +551,12 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2, RECENT_PACKAGE_3) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2, RECENT_PACKAGE_3), ) prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_2, RECENT_PACKAGE_3) + recentTaskPackages = listOf(RECENT_PACKAGE_2, RECENT_PACKAGE_3), ) val shownPackages = recentAppsController.shownTasks.flatMap { it.packageNames } // Most recent packages, minus the currently running one (RECENT_PACKAGE_3). @@ -579,7 +573,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(runningTask1, runningTask2), - recentTaskPackages = recentTaskPackages + recentTaskPackages = recentTaskPackages, ) setInDesktopMode(true) @@ -597,7 +591,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(runningTask1, runningTask2), - recentTaskPackages = recentTaskPackages + recentTaskPackages = recentTaskPackages, ) setInDesktopMode(false) recentTasksChangedListener!!.onRecentTasksChanged() @@ -613,7 +607,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2, RECENT_PACKAGE_3) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2, RECENT_PACKAGE_3), ) val shownPackages = recentAppsController.shownTasks.flatMap { it.packageNames } // RECENT_PACKAGE_3 is the top task (visible to user) so should be excluded. @@ -629,7 +623,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(runningTask1, runningTask2), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) val shownPackages = recentAppsController.shownTasks.map { it.packageNames } // Only 2 recent tasks shown: Desktop Tile + 1 Recent Task @@ -645,7 +639,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_SPLIT_PACKAGES_1, RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_SPLIT_PACKAGES_1, RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) val shownPackages = recentAppsController.shownTasks.map { it.packageNames } // Only 2 recent tasks shown: Pair + 1 Recent Task @@ -661,14 +655,14 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) verify(taskbarViewController, times(1)).commitRunningAppsToUI() // Call onRecentTasksChanged() again with the same tasks, verify it's a no-op. prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = emptyList(), - recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2) + recentTaskPackages = listOf(RECENT_PACKAGE_1, RECENT_PACKAGE_2), ) verify(taskbarViewController, times(1)).commitRunningAppsToUI() } @@ -681,14 +675,14 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(runningTask1, runningTask2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) verify(taskbarViewController, times(1)).commitRunningAppsToUI() // Call onRecentTasksChanged() again with the same tasks, verify it's a no-op. prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(runningTask1, runningTask2), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) verify(taskbarViewController, times(1)).commitRunningAppsToUI() } @@ -702,7 +696,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1Minimized, task2Visible), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) verify(taskbarViewController, times(1)).commitRunningAppsToUI() @@ -710,7 +704,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = emptyList(), runningTasks = listOf(task1Minimized, task2Minimized), - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) verify(taskbarViewController, times(2)).commitRunningAppsToUI() @@ -726,7 +720,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = hotseatPackages, runningTasks = originalTasks, - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) verify(taskbarViewController, times(1)).commitRunningAppsToUI() @@ -734,7 +728,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { prepareHotseatAndRunningAndRecentApps( hotseatPackages = hotseatPackages, runningTasks = newTasks, - recentTaskPackages = emptyList() + recentTaskPackages = emptyList(), ) verify(taskbarViewController, times(2)).commitRunningAppsToUI() @@ -751,10 +745,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { return recentAppsController.shownHotseatItems.toTypedArray() } - private fun updateRecentTasks( - runningTasks: List, - recentTaskPackages: List, - ) { + private fun updateRecentTasks(runningTasks: List, recentTaskPackages: List) { val recentTasks = createRecentTasksFromPackageNames(recentTaskPackages) val allTasks = ArrayList().apply { @@ -790,7 +781,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { private fun createTestAppInfo( packageName: String = "testPackageName", - className: String = "testClassName" + className: String = "testClassName", ) = AppInfo(ComponentName(packageName, className), className /* title */, userHandle, Intent()) private fun createRecentTasksFromPackageNames(packageNames: List): List { @@ -800,7 +791,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { GroupTask( createTask(100, splitPackages[0]), createTask(101, splitPackages[1]), - /* splitBounds = */ null + /* splitBounds = */ null, ) } else { // Use the number at the end of the test packageName as the id. @@ -818,14 +809,15 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { Intent().apply { `package` = packageName }, ComponentName(packageName, "TestActivity"), userHandle.identifier, - 0 + 0, ) ) .apply { this.isVisible = isVisible } } private fun setInDesktopMode(inDesktopMode: Boolean) { - whenever(mockDesktopVisibilityController.areDesktopTasksVisible()).thenReturn(inDesktopMode) + whenever(taskbarControllers.taskbarDesktopModeController.areDesktopTasksVisible) + .thenReturn(inDesktopMode) } private val GroupTask.packageNames: List diff --git a/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt b/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt index 4d10f0f51e..cb59f7dfda 100644 --- a/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt +++ b/quickstep/tests/src/com/android/quickstep/taskbar/controllers/TaskbarPinningControllerTest.kt @@ -55,7 +55,6 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() { private val taskbarDragLayer = mock() private val taskbarSharedState = mock() private var isInDesktopMode = false - private val isInDesktopModeProvider = { isInDesktopMode } private val launcherPrefs = mock { on { get(TASKBAR_PINNING) } doReturn false @@ -71,8 +70,9 @@ class TaskbarPinningControllerTest : TaskbarBaseTestCase() { whenever(taskbarActivityContext.launcherPrefs).thenReturn(launcherPrefs) whenever(taskbarActivityContext.dragLayer).thenReturn(taskbarDragLayer) whenever(taskbarActivityContext.statsLogManager).thenReturn(statsLogManager) - pinningController = - spy(TaskbarPinningController(taskbarActivityContext, isInDesktopModeProvider)) + whenever(taskbarControllers.taskbarDesktopModeController.areDesktopTasksVisible) + .thenAnswer { _ -> isInDesktopMode } + pinningController = spy(TaskbarPinningController(taskbarActivityContext)) pinningController.init(taskbarControllers, taskbarSharedState) } diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index b1e82bbdc0..072bcdf1db 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -187,11 +187,6 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { return INSTANCE.get(context).getInfo().isTransientTaskbar(); } - /** Returns whether we are currently in Desktop mode. */ - public static boolean isInDesktopMode(Context context) { - return INSTANCE.get(context).getInfo().isInDesktopMode(); - } - /** * Handles info change for desktop mode. */ @@ -496,10 +491,6 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { return navigationMode == NavigationMode.NO_BUTTON && !isTransientTaskbar(); } - public boolean isInDesktopMode() { - return mIsInDesktopMode; - } - /** * Returns {@code true} if the bounds represent a tablet. */