Revert "Refactor all uses of DisplayController singleton INSTANCE"
Revert submission 31490053-DisplayControllRefactorForCD
Reason for revert: Leak is displayProvider
Reverted changes: /q/submissionid:31490053-DisplayControllRefactorForCD
Change-Id: Ib65150cdde765be009b5c4ce960f9fe025de9e60
diff --git a/quickstep/src/com/android/launcher3/dagger/Modules.kt b/quickstep/src/com/android/launcher3/dagger/Modules.kt
index 99631bf..52be413 100644
--- a/quickstep/src/com/android/launcher3/dagger/Modules.kt
+++ b/quickstep/src/com/android/launcher3/dagger/Modules.kt
@@ -19,10 +19,8 @@
import com.android.launcher3.uioverrides.SystemApiWrapper
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapperImpl
import com.android.launcher3.util.ApiWrapper
-import com.android.launcher3.util.PerDisplayObjectProvider
import com.android.launcher3.util.PluginManagerWrapper
import com.android.launcher3.util.window.WindowManagerProxy
-import com.android.quickstep.fallback.window.RecentsDisplayModel
import com.android.quickstep.util.GestureExclusionManager
import com.android.quickstep.util.SystemWindowManagerProxy
import dagger.Binds
@@ -54,9 +52,3 @@
@JvmStatic
fun provideGestureExclusionManager(): GestureExclusionManager = GestureExclusionManager.INSTANCE
}
-
-@Module
-abstract class PerDisplayObjectProviderModule {
- @Binds
- abstract fun bindPerDisplayObjectProvider(impl: RecentsDisplayModel): PerDisplayObjectProvider
-}
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index 3f1bf3c..4143157 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -202,7 +202,7 @@
@Override
public void onLauncherVisibilityChanged(boolean isVisible) {
if (DesktopModeStatus.enterDesktopByDefaultOnFreeformDisplay(mLauncher)) {
- DisplayController.get(mLauncher).notifyConfigChange();
+ DisplayController.INSTANCE.get(mLauncher).notifyConfigChange();
}
onLauncherVisibilityChanged(isVisible, false /* fromInit */);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 126888c..a6d3cde 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -324,9 +324,9 @@
new BubbleDragController(this),
new BubbleDismissController(this, mDragLayer),
new BubbleBarPinController(this, mDragLayer,
- () -> DisplayController.get(this).getInfo().currentSize),
+ () -> DisplayController.INSTANCE.get(this).getInfo().currentSize),
new BubblePinController(this, mDragLayer,
- () -> DisplayController.get(this).getInfo().currentSize),
+ () -> DisplayController.INSTANCE.get(this).getInfo().currentSize),
bubbleBarSwipeController,
new BubbleCreator(this)
));
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
index eccccdf..f704254 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java
@@ -425,7 +425,7 @@
*/
public void onUserUnlocked() {
mUserUnlocked = true;
- DisplayController.get(mPrimaryWindowContext).addChangeListener(
+ DisplayController.INSTANCE.get(mPrimaryWindowContext).addChangeListener(
mRecreationListener);
recreateTaskbar();
addTaskbarRootViewToWindow(getDefaultDisplayId());
@@ -797,7 +797,7 @@
mTaskbarBroadcastReceiver.unregisterReceiverSafely(mPrimaryWindowContext);
if (mUserUnlocked) {
- DisplayController.get(mPrimaryWindowContext).removeChangeListener(
+ DisplayController.INSTANCE.get(mPrimaryWindowContext).removeChangeListener(
mRecreationListener);
}
SettingsCache.INSTANCE.get(mPrimaryWindowContext)
diff --git a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
index 5025afc..c001123 100644
--- a/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/bubbles/BubbleBarView.java
@@ -623,7 +623,7 @@
* Get bubble bar top coordinate on screen when bar is resting
*/
public int getRestingTopPositionOnScreen() {
- int displayHeight = DisplayController.get(getContext()).getInfo().currentSize.y;
+ int displayHeight = DisplayController.INSTANCE.get(getContext()).getInfo().currentSize.y;
int bubbleBarHeight = getBubbleBarBounds().height();
return displayHeight - bubbleBarHeight + (int) mController.getBubbleBarTranslationY();
}
diff --git a/quickstep/src/com/android/quickstep/BaseContainerInterface.java b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
index 4ab104e..6d588d9 100644
--- a/quickstep/src/com/android/quickstep/BaseContainerInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseContainerInterface.java
@@ -290,7 +290,7 @@
insets = dp.getInsets();
} else {
Rect portraitInsets = dp.getInsets();
- DisplayController displayController = DisplayController.get(context);
+ DisplayController displayController = DisplayController.INSTANCE.get(context);
@Nullable List<WindowBounds> windowBounds =
displayController.getInfo().getCurrentBounds();
Rect deviceRotationInsets = windowBounds != null
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
index 93f31ff..9b0e75c 100644
--- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
+++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -28,7 +28,6 @@
import java.util.function.Consumer;
import java.util.function.Function;
-@SuppressWarnings("VisibleForTests")
public class QuickstepTestInformationHandler extends TestInformationHandler {
protected final Context mContext;
@@ -230,7 +229,7 @@
}
private void enableTransientTaskbar(boolean enable) {
- DisplayController.get(mContext).enableTransientTaskbarForTests(enable);
+ DisplayController.INSTANCE.get(mContext).enableTransientTaskbarForTests(enable);
}
/**
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 3742d5a..090ccdc 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -73,7 +73,6 @@
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.NavigationMode;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.launcher3.util.SettingsCache;
import com.android.quickstep.TopTaskTracker.CachedTaskInfo;
import com.android.quickstep.util.ActiveGestureLog;
@@ -142,13 +141,13 @@
RecentsAnimationDeviceState(
@ApplicationContext Context context,
GestureExclusionManager exclusionManager,
- PerDisplayObjectProvider displayControllerProvider,
+ DisplayController displayController,
ContextualSearchStateManager contextualSearchStateManager,
RotationTouchHelper rotationTouchHelper,
SettingsCache settingsCache,
DaggerSingletonTracker lifeCycle) {
mContext = context;
- mDisplayController = displayControllerProvider.getDisplayController(DEFAULT_DISPLAY);
+ mDisplayController = displayController;
mExclusionManager = exclusionManager;
mContextualSearchStateManager = contextualSearchStateManager;
mRotationTouchHelper = rotationTouchHelper;
@@ -157,7 +156,7 @@
// Register for exclusion updates
lifeCycle.addCloseable(this::unregisterExclusionListener);
- // Register for display changes
+ // Register for display changes changes
mDisplayController.addChangeListener(this);
onDisplayInfoChanged(context, mDisplayController.getInfo(), CHANGE_ALL);
lifeCycle.addCloseable(() -> mDisplayController.removeChangeListener(this));
diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java
index f53a8b6..1d83d42 100644
--- a/quickstep/src/com/android/quickstep/RecentsModel.java
+++ b/quickstep/src/com/android/quickstep/RecentsModel.java
@@ -48,13 +48,11 @@
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors.SimpleThreadFactory;
import com.android.launcher3.util.LockedUserState;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.launcher3.util.SafeCloseable;
import com.android.quickstep.dagger.QuickstepBaseAppComponent;
import com.android.quickstep.recents.data.RecentTasksDataSource;
import com.android.quickstep.recents.data.TaskVisualsChangeNotifier;
import com.android.quickstep.util.DesktopTask;
-import com.android.quickstep.util.ExternalDisplaysKt;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.TaskVisualsChangeListener;
import com.android.systemui.shared.recents.model.Task;
@@ -63,8 +61,6 @@
import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
-import dagger.Lazy;
-
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
@@ -76,6 +72,8 @@
import javax.inject.Inject;
+import dagger.Lazy;
+
/**
* Singleton class to load and manage recents model.
*/
@@ -103,17 +101,15 @@
public RecentsModel(@ApplicationContext Context context,
SystemUiProxy systemUiProxy,
TopTaskTracker topTaskTracker,
+ DisplayController displayController,
LockedUserState lockedUserState,
- PerDisplayObjectProvider perDisplayObjectProvider,
Lazy<ThemeManager> themeManagerLazy,
DaggerSingletonTracker tracker
) {
// Lazily inject the ThemeManager and access themeManager once the device is
// unlocked. See b/393248495 for details.
this(context, new IconProvider(context), systemUiProxy, topTaskTracker,
- perDisplayObjectProvider.getDisplayController(
- ExternalDisplaysKt.getValidDisplayId(context)),
- lockedUserState, themeManagerLazy, tracker);
+ displayController, lockedUserState,themeManagerLazy, tracker);
}
@SuppressLint("VisibleForTests")
diff --git a/quickstep/src/com/android/quickstep/RotationTouchHelper.java b/quickstep/src/com/android/quickstep/RotationTouchHelper.java
index 387adfd..a614327 100644
--- a/quickstep/src/com/android/quickstep/RotationTouchHelper.java
+++ b/quickstep/src/com/android/quickstep/RotationTouchHelper.java
@@ -43,7 +43,6 @@
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.NavigationMode;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.quickstep.util.RecentsOrientedState;
import com.android.systemui.shared.Flags;
import com.android.systemui.shared.system.QuickStepContract;
@@ -137,11 +136,11 @@
@Inject
RotationTouchHelper(@ApplicationContext Context context,
- PerDisplayObjectProvider displayControllerProvider,
+ DisplayController displayController,
SystemUiProxy systemUiProxy,
DaggerSingletonTracker lifeCycle) {
mContext = context;
- mDisplayController = displayControllerProvider.getDisplayController(DEFAULT_DISPLAY);
+ mDisplayController = displayController;
mSystemUiProxy = systemUiProxy;
mDisplayId = DEFAULT_DISPLAY;
diff --git a/quickstep/src/com/android/quickstep/SimpleOrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/SimpleOrientationTouchTransformer.java
index 9ebaffa..d2a491d 100644
--- a/quickstep/src/com/android/quickstep/SimpleOrientationTouchTransformer.java
+++ b/quickstep/src/com/android/quickstep/SimpleOrientationTouchTransformer.java
@@ -15,8 +15,6 @@
*/
package com.android.quickstep;
-import static android.view.Display.DEFAULT_DISPLAY;
-
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
import static com.android.launcher3.util.DisplayController.CHANGE_ALL;
import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION;
@@ -29,7 +27,6 @@
import com.android.launcher3.util.DaggerSingletonObject;
import com.android.launcher3.util.DaggerSingletonTracker;
import com.android.launcher3.util.DisplayController;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.quickstep.dagger.QuickstepBaseAppComponent;
import javax.inject.Inject;
@@ -48,10 +45,8 @@
@Inject
public SimpleOrientationTouchTransformer(@ApplicationContext Context context,
- PerDisplayObjectProvider displayControllerProvider,
+ DisplayController displayController,
DaggerSingletonTracker tracker) {
- DisplayController displayController = displayControllerProvider.getDisplayController(
- DEFAULT_DISPLAY);
displayController.addChangeListener(this);
tracker.addCloseable(() -> displayController.removeChangeListener(this));
diff --git a/quickstep/src/com/android/quickstep/TaskIconCache.kt b/quickstep/src/com/android/quickstep/TaskIconCache.kt
index 3fbf59a..6a7f1af 100644
--- a/quickstep/src/com/android/quickstep/TaskIconCache.kt
+++ b/quickstep/src/com/android/quickstep/TaskIconCache.kt
@@ -153,7 +153,7 @@
private fun createIconFactory() =
BaseIconFactory(
context,
- DisplayController.get(context).info.densityDpi,
+ DisplayController.INSTANCE.get(context).info.densityDpi,
context.resources.getDimensionPixelSize(R.dimen.task_icon_cache_default_icon_size),
)
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 7902ad5..e47223b 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -230,7 +230,7 @@
// RecentsView never updates the display rotation until swipe-up so the value may
// be stale. Use the display value instead.
- int displayRotation = DisplayController.get(context).getInfo().rotation;
+ int displayRotation = DisplayController.INSTANCE.get(context).getInfo().rotation;
tvsLocal.getOrientationState().update(displayRotation, displayRotation);
tvsLocal.fullScreenProgress.value = 0;
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index 7a4c06b..ba4c65a 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -1112,7 +1112,7 @@
pw.println("Input state:");
pw.println("\tmInputMonitorCompat=" + mInputMonitorCompat);
pw.println("\tmInputEventReceiver=" + mInputEventReceiver);
- DisplayController.get(this).dump(pw);
+ DisplayController.INSTANCE.get(this).dump(pw);
pw.println("TouchState:");
RecentsViewContainer createdOverviewContainer = mOverviewComponentObserver == null ? null
: mOverviewComponentObserver.getContainerInterface().getCreatedContainer();
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java b/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java
index a61c1a0..ec531d8 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackNavBarTouchController.java
@@ -44,7 +44,7 @@
DisplayController.getNavigationMode(mContainer.asContext());
if (sysUINavigationMode == NavigationMode.NO_BUTTON) {
NavBarPosition navBarPosition = new NavBarPosition(sysUINavigationMode,
- DisplayController.get(mContainer.asContext()).getInfo());
+ DisplayController.INSTANCE.get(mContainer.asContext()).getInfo());
mTriggerSwipeUpTracker = new TriggerSwipeUpTouchTracker(mContainer.asContext(),
true /* disableHorizontalSwipe */, navBarPosition, this);
} else {
diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt
index c7e77b2..95a3ec2 100644
--- a/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt
+++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsDisplayModel.kt
@@ -18,23 +18,18 @@
import android.content.Context
import android.util.Log
-import android.view.Display.INVALID_DISPLAY
+import android.view.Display
import com.android.launcher3.Flags
-import com.android.launcher3.LauncherPrefs
import com.android.launcher3.dagger.ApplicationContext
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.util.DaggerSingletonObject
import com.android.launcher3.util.DaggerSingletonTracker
-import com.android.launcher3.util.DisplayController
import com.android.launcher3.util.Executors
-import com.android.launcher3.util.PerDisplayObjectProvider
import com.android.launcher3.util.WallpaperColorHints
-import com.android.launcher3.util.window.WindowManagerProxy
import com.android.quickstep.DisplayModel
import com.android.quickstep.FallbackWindowInterface
import com.android.quickstep.dagger.QuickstepBaseAppComponent
import com.android.quickstep.fallback.window.RecentsDisplayModel.RecentsDisplayResource
-import com.android.quickstep.util.validDisplayId
import javax.inject.Inject
@LauncherAppSingleton
@@ -42,11 +37,9 @@
@Inject
constructor(
@ApplicationContext context: Context,
- private val windowManagerProxy: WindowManagerProxy,
- private val launcherPrefs: LauncherPrefs,
private val wallpaperColorHints: WallpaperColorHints,
tracker: DaggerSingletonTracker,
-) : DisplayModel<RecentsDisplayResource>(context), PerDisplayObjectProvider {
+) : DisplayModel<RecentsDisplayResource>(context) {
companion object {
private const val TAG = "RecentsDisplayModel"
@@ -64,17 +57,16 @@
}
init {
- // Add the display for the context with which we are initialized.
- storeRecentsDisplayResource(context.validDisplayId)
-
- displayManager.registerDisplayListener(displayListener, Executors.MAIN_EXECUTOR.handler)
- // In the scenario where displays were added before this display listener was
- // registered, we should store the RecentsDisplayResources for those displays
- // directly.
- displayManager.displays
- .filter { getDisplayResource(it.displayId) == null }
- .forEach { storeRecentsDisplayResource(it.displayId) }
- tracker.addCloseable { destroy() }
+ if (enableOverviewInWindow()) {
+ displayManager.registerDisplayListener(displayListener, Executors.MAIN_EXECUTOR.handler)
+ // In the scenario where displays were added before this display listener was
+ // registered, we should store the RecentsDisplayResources for those displays
+ // directly.
+ displayManager.displays
+ .filter { getDisplayResource(it.displayId) == null }
+ .forEach { storeRecentsDisplayResource(it.displayId, it) }
+ tracker.addCloseable { destroy() }
+ }
}
override fun createDisplayResource(displayId: Int) {
@@ -82,34 +74,26 @@
getDisplayResource(displayId)?.let {
return
}
- if (displayId == INVALID_DISPLAY) {
- Log.e(TAG, "createDisplayResource: INVALID_DISPLAY")
- return
- }
- storeRecentsDisplayResource(displayId)
- }
-
- private fun storeRecentsDisplayResource(displayId: Int): RecentsDisplayResource {
val display = displayManager.getDisplay(displayId)
if (display == null) {
if (DEBUG)
Log.w(
TAG,
- "storeRecentsDisplayResource: could not create display for displayId=$displayId",
+ "createDisplayResource: could not create display for displayId=$displayId",
+ Exception(),
)
+ return
}
- return displayResourceArray[displayId]
- ?: RecentsDisplayResource(
- displayId,
- context,
- windowManagerProxy,
- launcherPrefs,
- if (enableOverviewInWindow() && display != null)
- context.createDisplayContext(display)
- else null,
- wallpaperColorHints.hints,
- )
- .also { displayResourceArray[displayId] = it }
+ storeRecentsDisplayResource(displayId, display)
+ }
+
+ private fun storeRecentsDisplayResource(displayId: Int, display: Display) {
+ displayResourceArray[displayId] =
+ RecentsDisplayResource(
+ displayId,
+ context.createDisplayContext(display),
+ wallpaperColorHints.hints,
+ )
}
fun getRecentsWindowManager(displayId: Int): RecentsWindowManager? {
@@ -120,36 +104,17 @@
return getDisplayResource(displayId)?.fallbackWindowInterface
}
- override fun getDisplayController(displayId: Int): DisplayController {
- if (DEBUG) Log.d(TAG, "getDisplayController $displayId")
- return (getDisplayResource(displayId)
- ?: storeRecentsDisplayResource(displayId).also {
- // We shouldn't get here because the display should already have been
- // initialized.
- Log.e(TAG, "getDisplayController no such display: $displayId")
- })
- .displayController
- }
-
data class RecentsDisplayResource(
var displayId: Int,
- val appContext: Context,
- val windowManagerProxy: WindowManagerProxy,
- val launcherPrefs: LauncherPrefs,
- var displayContext: Context?, // null when OverviewInWindow not enabled
+ var displayContext: Context,
val wallpaperColorHints: Int,
) : DisplayResource() {
- val recentsWindowManager =
- displayContext?.let { RecentsWindowManager(it, wallpaperColorHints) }
- val fallbackWindowInterface: FallbackWindowInterface? =
- recentsWindowManager?.let { FallbackWindowInterface(recentsWindowManager) }
- val lifecycle = DaggerSingletonTracker()
- val displayController =
- DisplayController(appContext, windowManagerProxy, launcherPrefs, lifecycle, displayId)
+ val recentsWindowManager = RecentsWindowManager(displayContext, wallpaperColorHints)
+ val fallbackWindowInterface: FallbackWindowInterface =
+ FallbackWindowInterface(recentsWindowManager)
override fun cleanup() {
- recentsWindowManager?.destroy()
- lifecycle.close()
+ recentsWindowManager.destroy()
}
}
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
index 6be1098..503b900 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
@@ -122,7 +122,7 @@
mRotationTouchHelper = RotationTouchHelper.INSTANCE.get(mContext);
// Do not use DeviceProfile as the user data might be locked
- mDisplaySize = DisplayController.get(context).getInfo().currentSize;
+ mDisplaySize = DisplayController.INSTANCE.get(context).getInfo().currentSize;
// Init states
mStateCallback = new MultiStateCallback(STATE_NAMES);
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index 9a572b9..afe988d 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -73,7 +73,7 @@
InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState,
NavHandle navHandle, GestureState gestureState) {
super(delegate, inputMonitor);
- mScreenWidth = DisplayController.get(context).getInfo().currentSize.x;
+ mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
mDeepPressEnabled = DeviceConfigWrapper.get().getEnableLpnhDeepPress();
ContextualSearchStateManager contextualSearchStateManager =
ContextualSearchStateManager.INSTANCE.get(context);
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
index fa9744d..83b556d 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/OneHandedModeInputConsumer.java
@@ -69,7 +69,7 @@
mDragDistThreshold = context.getResources().getDimensionPixelSize(
R.dimen.gestures_onehanded_drag_threshold);
mSquaredSlop = mDeviceState.getSquaredTouchSlop();
- mDisplaySize = DisplayController.get(mContext).getInfo().currentSize;
+ mDisplaySize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
mNavBarSize = ResourceUtils.getNavbarSize(NAVBAR_BOTTOM_GESTURE_SIZE,
mContext.getResources());
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
index ca62657..c91bebe 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
@@ -99,7 +99,7 @@
mProgress = progress;
// Do not use DeviceProfile as the user data might be locked
- mDisplaySize = DisplayController.get(context).getInfo().currentSize;
+ mDisplaySize = DisplayController.INSTANCE.get(context).getInfo().currentSize;
// Init states
mStateCallback = new MultiStateCallback(STATE_NAMES);
diff --git a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java
index bf6c3c3..fdbd509 100644
--- a/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java
+++ b/quickstep/src/com/android/quickstep/interaction/NavBarGestureHandler.java
@@ -66,7 +66,7 @@
/* disableHorizontalSwipe= */ true,
new NavBarPosition(
NavigationMode.NO_BUTTON,
- DisplayController.get(mContext).getInfo()),
+ DisplayController.INSTANCE.get(mContext).getInfo()),
/* onSwipeUp= */ this);
mMotionPauseDetector = new MotionPauseDetector(context);
diff --git a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java
index c27fb60..0cc349d 100644
--- a/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java
+++ b/quickstep/src/com/android/quickstep/logging/SettingsChangeLogger.java
@@ -16,8 +16,6 @@
package com.android.quickstep.logging;
-import static android.view.Display.DEFAULT_DISPLAY;
-
import static com.android.launcher3.LauncherPrefs.getDevicePrefs;
import static com.android.launcher3.LauncherPrefs.getPrefs;
import static com.android.launcher3.graphics.ThemeManager.KEY_THEMED_ICONS;
@@ -56,7 +54,6 @@
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.NavigationMode;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.launcher3.util.SettingsCache;
import com.android.quickstep.dagger.QuickstepBaseAppComponent;
@@ -97,10 +94,9 @@
@Inject
SettingsChangeLogger(@ApplicationContext Context context,
DaggerSingletonTracker tracker,
- PerDisplayObjectProvider displayControllerProvider,
+ DisplayController displayController,
SettingsCache settingsCache) {
- this(context, StatsLogManager.newInstance(context), tracker,
- displayControllerProvider.getDisplayController(DEFAULT_DISPLAY),
+ this(context, StatsLogManager.newInstance(context), tracker, displayController,
settingsCache);
}
diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
index fb521ab..594c99a 100644
--- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
+++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java
@@ -247,7 +247,7 @@
StatsCompatLogger(Context context, ActivityContext activityContext) {
mContext = context;
mActivityContext = Optional.ofNullable(activityContext);
- mDisplayRotation = DisplayController.get(mContext).getInfo().rotation;
+ mDisplayRotation = DisplayController.INSTANCE.get(mContext).getInfo().rotation;
}
@Override
diff --git a/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt b/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt
index 9df1fe8..455b312 100644
--- a/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt
+++ b/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt
@@ -16,8 +16,6 @@
package com.android.quickstep.util
-import android.content.Context
-import android.util.Log
import android.view.Display.DEFAULT_DISPLAY
import android.view.Display.INVALID_DISPLAY
import com.android.systemui.shared.recents.model.Task
@@ -26,30 +24,17 @@
val Int.isExternalDisplay
get() = this != DEFAULT_DISPLAY
-val Int?.validDisplayId: Int
- get() =
- when (this) {
- null -> DEFAULT_DISPLAY
- INVALID_DISPLAY -> DEFAULT_DISPLAY
- else -> this
- }
-
/** Returns displayId of this [Task], default to [DEFAULT_DISPLAY] */
-val Task?.validDisplayId
- get() = this?.key?.displayId?.validDisplayId ?: DEFAULT_DISPLAY
+val Task?.displayId
+ get() =
+ this?.key?.displayId.let { displayId ->
+ when (displayId) {
+ null -> DEFAULT_DISPLAY
+ INVALID_DISPLAY -> DEFAULT_DISPLAY
+ else -> displayId
+ }
+ }
/** Returns if this task belongs tto [DEFAULT_DISPLAY] */
val Task?.isExternalDisplay
- get(): Boolean = this.validDisplayId.isExternalDisplay ?: false
-
-val Context?.validDisplayId
- get() =
- try {
- this?.display?.displayId?.validDisplayId ?: DEFAULT_DISPLAY
- } catch (ignored: UnsupportedOperationException) {
- Log.w(
- "ExternalDisplays",
- "Tried to get a Display from a Context not associated with one",
- )
- DEFAULT_DISPLAY
- }
+ get() = displayId.isExternalDisplay
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index 8fb16d7..a5be89a 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -573,7 +573,7 @@
*/
public DeviceProfile getLauncherDeviceProfile() {
InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(mContext);
- Point currentSize = DisplayController.get(mContext).getInfo().currentSize;
+ Point currentSize = DisplayController.INSTANCE.get(mContext).getInfo().currentSize;
int width, height;
if ((mRecentsActivityRotation == ROTATION_90 || mRecentsActivityRotation == ROTATION_270)) {
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt
index e86d657..609262f 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskView.kt
@@ -91,8 +91,8 @@
import com.android.quickstep.util.RecentsOrientedState
import com.android.quickstep.util.TaskCornerRadius
import com.android.quickstep.util.TaskRemovedDuringLaunchListener
+import com.android.quickstep.util.displayId
import com.android.quickstep.util.isExternalDisplay
-import com.android.quickstep.util.validDisplayId
import com.android.quickstep.views.RecentsView.UNBOUND_TASK_VIEW_ID
import com.android.systemui.shared.recents.model.Task
import com.android.systemui.shared.recents.model.ThumbnailData
@@ -144,7 +144,7 @@
get() = this === recentsView?.runningTaskView
val displayId: Int
- get() = taskContainers.firstOrNull()?.task.validDisplayId
+ get() = taskContainers.firstOrNull()?.task.displayId
val isExternalDisplay: Boolean
get() = displayId.isExternalDisplay
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 2bdc22a..bfd53ef 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt
@@ -31,6 +31,7 @@
import com.android.launcher3.taskbar.TaskbarViewTestUtil.createHotseatItems
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
import com.android.launcher3.taskbar.bubbles.stashing.BubbleStashController
+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
@@ -422,7 +423,9 @@
/** TaskbarOverflowComponent used to bind the RecentsModel. */
@LauncherAppSingleton
-@Component(modules = [AllModulesForTest::class, FakePrefsModule::class])
+@Component(
+ modules = [AllModulesForTest::class, FakePrefsModule::class, DisplayControllerModule::class]
+)
interface TaskbarOverflowComponent : TaskbarSandboxComponent {
@Component.Builder
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRule.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRule.kt
index 482d735..3cf912c 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRule.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarModeRule.kt
@@ -61,7 +61,7 @@
val mode = taskbarMode.mode
getInstrumentation().runOnMainSync {
- DisplayController.get(context).let {
+ DisplayController.INSTANCE[context].let {
if (it is DisplayControllerSpy) {
it.infoModifier = { info ->
spy(info) {
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarWindowSandboxContext.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarWindowSandboxContext.kt
index 62d6fdc..95e8980 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarWindowSandboxContext.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/rules/TaskbarWindowSandboxContext.kt
@@ -26,12 +26,11 @@
import com.android.launcher3.dagger.ApplicationContext
import com.android.launcher3.dagger.LauncherAppComponent
import com.android.launcher3.dagger.LauncherAppSingleton
-import com.android.launcher3.util.AllModulesMinusPerDisplayObjectProvider
+import com.android.launcher3.util.AllModulesForTest
import com.android.launcher3.util.DaggerSingletonTracker
import com.android.launcher3.util.DisplayController
import com.android.launcher3.util.FakePrefsModule
import com.android.launcher3.util.MainThreadInitializedObject.ObjectSandbox
-import com.android.launcher3.util.PerDisplayObjectProvider
import com.android.launcher3.util.SandboxApplication
import com.android.launcher3.util.SettingsCache
import com.android.launcher3.util.SettingsCacheSandbox
@@ -132,31 +131,14 @@
override fun getInfo(): Info = infoModifier?.invoke(super.getInfo()) ?: super.getInfo()
}
-@LauncherAppSingleton
-class PerDisplayObjectProviderImpl
-@Inject
-constructor(private val displayController: DisplayControllerSpy) : PerDisplayObjectProvider {
- override fun getDisplayController(displayId: Int): DisplayController {
- return displayController
- }
-}
-
@Module
-abstract class PerDisplayObjectProviderModule {
- @Binds
- abstract fun bindPerDisplayObjectProvider(
- impl: PerDisplayObjectProviderImpl
- ): PerDisplayObjectProvider
+abstract class DisplayControllerModule {
+ @Binds abstract fun bindDisplayController(controller: DisplayControllerSpy): DisplayController
}
@LauncherAppSingleton
@Component(
- modules =
- [
- AllModulesMinusPerDisplayObjectProvider::class,
- FakePrefsModule::class,
- PerDisplayObjectProviderModule::class,
- ]
+ modules = [AllModulesForTest::class, FakePrefsModule::class, DisplayControllerModule::class]
)
interface TaskbarSandboxComponent : LauncherAppComponent {
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt
index f5de2b0..b652ee8 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsAnimationDeviceStateTest.kt
@@ -60,7 +60,7 @@
RecentsAnimationDeviceState(
context,
exclusionManager,
- component.perDisplayObjectProvider,
+ component.displayController,
component.contextualSearchStateManager,
component.rotationTouchHelper,
component.settingsCache,
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java
index e875e4d..c1be1ce 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsWindowSwipeHandlerTestCase.java
@@ -25,12 +25,15 @@
import com.android.launcher3.util.LauncherMultivalentJUnit;
import com.android.quickstep.fallback.FallbackRecentsView;
import com.android.quickstep.fallback.RecentsState;
+import com.android.quickstep.fallback.window.RecentsDisplayModel;
import com.android.quickstep.fallback.window.RecentsWindowManager;
import com.android.quickstep.fallback.window.RecentsWindowSwipeHandler;
import com.android.quickstep.views.RecentsViewContainer;
+import dagger.BindsInstance;
import dagger.Component;
+import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -43,9 +46,16 @@
RecentsWindowSwipeHandler,
FallbackWindowInterface> {
+ @Mock private RecentsDisplayModel mRecentsDisplayModel;
@Mock private FallbackRecentsView<RecentsWindowManager> mRecentsView;
@Mock private RecentsWindowManager mRecentsWindowManager;
+ @Before
+ public void setRecentsDisplayModel() {
+ mContext.initDaggerComponent(DaggerRecentsWindowSwipeHandlerTestCase_TestComponent.builder()
+ .bindRecentsDisplayModel(mRecentsDisplayModel));
+ }
+
@NonNull
@Override
protected RecentsWindowSwipeHandler createSwipeHandler(long touchTimeMs,
@@ -77,6 +87,7 @@
interface TestComponent extends LauncherAppComponent {
@Component.Builder
interface Builder extends LauncherAppComponent.Builder {
+ @BindsInstance Builder bindRecentsDisplayModel(RecentsDisplayModel model);
@Override LauncherAppComponent build();
}
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
index 71d377b..7776351 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
@@ -433,7 +433,7 @@
DaggerNavHandleLongPressInputConsumerTest_TopTaskTrackerComponent
.builder()
.bindTopTaskTracker(mTopTaskTracker));
- mScreenWidth = DisplayController.get(mContext).getInfo().currentSize.x;
+ mScreenWidth = DisplayController.INSTANCE.get(mContext).getInfo().currentSize.x;
mUnderTest = new NavHandleLongPressInputConsumer(mContext, mDelegate, mInputMonitor,
mDeviceState, mNavHandle, mGestureState);
mUnderTest.setNavHandleLongPressHandler(mNavHandleLongPressHandler);
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 2671b80..14570b5 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/logging/SettingsChangeLoggerTest.kt
@@ -64,7 +64,7 @@
@Mock private lateinit var mMockLogger: StatsLogManager.StatsLogger
@Mock private lateinit var mTracker: DaggerSingletonTracker
- private var displayController: DisplayController = DisplayController.get(mContext)
+ private var displayController: DisplayController = DisplayController.INSTANCE.get(mContext)
private var settingsCache: SettingsCache = SettingsCache.INSTANCE.get(mContext)
@Captor private lateinit var mEventCaptor: ArgumentCaptor<StatsLogManager.EventEnum>
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/TaskViewSimulatorTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/TaskViewSimulatorTest.java
index ab48065..be76f9e 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/TaskViewSimulatorTest.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/TaskViewSimulatorTest.java
@@ -16,7 +16,6 @@
package com.android.quickstep.util;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -38,12 +37,11 @@
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.dagger.LauncherAppComponent;
import com.android.launcher3.dagger.LauncherAppSingleton;
-import com.android.launcher3.util.AllModulesMinusWMProxyAndPerDisplayObjectProvider;
+import com.android.launcher3.util.AllModulesMinusWMProxy;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.Info;
import com.android.launcher3.util.LauncherModelHelper;
import com.android.launcher3.util.NavigationMode;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.launcher3.util.RotationUtils;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.util.window.CachedDisplayInfo;
@@ -168,11 +166,10 @@
LauncherModelHelper helper = new LauncherModelHelper();
try {
DisplayController mockController = mock(DisplayController.class);
- PerDisplayObjectProvider objectProvider = mock(PerDisplayObjectProvider.class);
helper.sandboxContext.initDaggerComponent(
DaggerTaskViewSimulatorTest_TaskViewSimulatorTestComponent.builder()
- .bindPerDisplayObjectProvider(objectProvider));
+ .bindDisplayController(mockController));
int rotation = mDisplaySize.x > mDisplaySize.y
? Surface.ROTATION_90 : Surface.ROTATION_0;
CachedDisplayInfo cdi = new CachedDisplayInfo(mDisplaySize, rotation);
@@ -204,8 +201,6 @@
Context configurationContext = helper.sandboxContext.createConfigurationContext(
configuration);
- when(objectProvider.getDisplayController(anyInt())).thenReturn(
- mockController);
DisplayController.Info info = new Info(
configurationContext, wmProxy, perDisplayBoundsCache);
when(mockController.getInfo()).thenReturn(info);
@@ -286,14 +281,14 @@
}
@LauncherAppSingleton
- @Component(modules = {AllModulesMinusWMProxyAndPerDisplayObjectProvider.class})
+ @Component(modules = {AllModulesMinusWMProxy.class})
interface TaskViewSimulatorTestComponent extends LauncherAppComponent {
@Component.Builder
interface Builder extends LauncherAppComponent.Builder {
@BindsInstance
- Builder bindPerDisplayObjectProvider(PerDisplayObjectProvider provider);
+ Builder bindDisplayController(DisplayController controller);
TaskViewSimulatorTestComponent build();
}
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index 06c8745..c713c3d 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -71,6 +71,9 @@
private final LauncherInstrumentation mLauncher;
+ static final DisplayController DISPLAY_CONTROLLER =
+ DisplayController.INSTANCE.get(getInstrumentation().getTargetContext());
+
public NavigationModeSwitchRule(LauncherInstrumentation launcher) {
mLauncher = launcher;
}
@@ -165,13 +168,11 @@
latch.countDown();
}
};
- DisplayController displayController =
- DisplayController.get(getInstrumentation().getTargetContext());
targetContext.getMainExecutor().execute(() ->
- displayController.addChangeListener(listener));
+ DISPLAY_CONTROLLER.addChangeListener(listener));
latch.await(60, TimeUnit.SECONDS);
targetContext.getMainExecutor().execute(() ->
- displayController.removeChangeListener(listener));
+ DISPLAY_CONTROLLER.removeChangeListener(listener));
assertTrue(launcher, "Navigation mode didn't change to " + expectedMode,
currentSysUiNavigationMode() == expectedMode, description);
diff --git a/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java b/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
index 649b222..a0ec635 100644
--- a/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
+++ b/quickstep/tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
@@ -17,8 +17,6 @@
package com.android.quickstep;
-import static android.view.Display.DEFAULT_DISPLAY;
-
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
@@ -47,7 +45,6 @@
import com.android.launcher3.testing.shared.ResourceUtils;
import com.android.launcher3.util.DaggerSingletonTracker;
import com.android.launcher3.util.DisplayController;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.launcher3.util.RotationUtils;
import com.android.launcher3.util.WindowBounds;
import com.android.launcher3.util.window.CachedDisplayInfo;
@@ -303,14 +300,9 @@
@Test
public void testSimpleOrientationTouchTransformer() {
final DisplayController displayController = mock(DisplayController.class);
- final PerDisplayObjectProvider displayControllerProvider = mock(
- PerDisplayObjectProvider.class);
- doReturn(displayController).when(displayControllerProvider).getDisplayController(
- DEFAULT_DISPLAY);
doReturn(mInfo).when(displayController).getInfo();
final SimpleOrientationTouchTransformer transformer =
- new SimpleOrientationTouchTransformer(getApplicationContext(),
- displayControllerProvider,
+ new SimpleOrientationTouchTransformer(getApplicationContext(), displayController,
mock(DaggerSingletonTracker.class));
final MotionEvent move1 = generateMotionEvent(MotionEvent.ACTION_MOVE, 100, 10);
transformer.transform(move1, Surface.ROTATION_90);
diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java
index db4480a..6277e41 100644
--- a/src/com/android/launcher3/BaseActivity.java
+++ b/src/com/android/launcher3/BaseActivity.java
@@ -178,8 +178,6 @@
private ActionMode mCurrentActionMode;
- private DisplayController mDisplayController;
-
@Override
public ViewCache getViewCache() {
return mViewCache;
@@ -226,8 +224,7 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerBackDispatcher();
- mDisplayController = DisplayController.get(this);
- mDisplayController.addChangeListener(this);
+ DisplayController.INSTANCE.get(this).addChangeListener(this);
}
@Override
@@ -275,9 +272,7 @@
protected void onDestroy() {
super.onDestroy();
mEventCallbacks[EVENT_DESTROYED].executeAllAndClear();
- if (mDisplayController != null) {
- mDisplayController.removeChangeListener(this);
- }
+ DisplayController.INSTANCE.get(this).removeChangeListener(this);
}
@Override
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 472cac4..900f74d 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -16,8 +16,6 @@
package com.android.launcher3;
-import static android.view.Display.DEFAULT_DISPLAY;
-
import static com.android.launcher3.LauncherPrefs.DB_FILE;
import static com.android.launcher3.LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE;
import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
@@ -258,7 +256,7 @@
String gridName = getCurrentGridName(context);
initGrid(context, gridName);
- DisplayController dc = DisplayController.get(context, DEFAULT_DISPLAY);
+ DisplayController dc = DisplayController.INSTANCE.get(context);
dc.setPriorityListener(
(displayContext, info, flags) -> {
if ((flags & (CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS
@@ -317,7 +315,7 @@
String gridName = getCurrentGridName(context);
// Get the display info based on default display and interpolate it to existing display
- Info defaultInfo = DisplayController.get(context, display.getDisplayId()).getInfo();
+ Info defaultInfo = DisplayController.INSTANCE.get(context).getInfo();
@DeviceType int defaultDeviceType = defaultInfo.getDeviceType();
DisplayOption defaultDisplayOption = invDistWeightedInterpolate(
defaultInfo,
@@ -376,7 +374,7 @@
+ ", dbFile:" + dbFile
+ ", LauncherPrefs GRID_NAME:" + LauncherPrefs.get(context).get(GRID_NAME)
+ ", LauncherPrefs DB_FILE:" + LauncherPrefs.get(context).get(DB_FILE));
- Info displayInfo = DisplayController.get(context).getInfo();
+ Info displayInfo = DisplayController.INSTANCE.get(context).getInfo();
List<DisplayOption> allOptions = getPredefinedDeviceProfiles(
context,
gridName,
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index fba94fd..2a5cd63 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -299,7 +299,7 @@
@JvmField
val ALLOW_ROTATION =
backedUpItem(RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY, Boolean::class.java) {
- RotationHelper.getAllowRotationDefaultValue(DisplayController.get(it).info)
+ RotationHelper.getAllowRotationDefaultValue(DisplayController.INSTANCE.get(it).info)
}
@JvmField
diff --git a/src/com/android/launcher3/dagger/LauncherAppModule.java b/src/com/android/launcher3/dagger/LauncherAppModule.java
index ece0ff0..c58a414 100644
--- a/src/com/android/launcher3/dagger/LauncherAppModule.java
+++ b/src/com/android/launcher3/dagger/LauncherAppModule.java
@@ -23,7 +23,6 @@
ApiWrapperModule.class,
PluginManagerWrapperModule.class,
StaticObjectModule.class,
- PerDisplayObjectProviderModule.class,
AppModule.class
})
public class LauncherAppModule {
diff --git a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
index fe23093..7bd7c3e 100644
--- a/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
+++ b/src/com/android/launcher3/dagger/LauncherBaseAppComponent.java
@@ -26,11 +26,11 @@
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.util.DynamicResource;
import com.android.launcher3.util.LockedUserState;
import com.android.launcher3.util.MSDLPlayerWrapper;
import com.android.launcher3.util.PackageManagerHelper;
-import com.android.launcher3.util.PerDisplayObjectProvider;
import com.android.launcher3.util.PluginManagerWrapper;
import com.android.launcher3.util.ScreenOnTracker;
import com.android.launcher3.util.SettingsCache;
@@ -69,7 +69,7 @@
LauncherPrefs getLauncherPrefs();
ThemeManager getThemeManager();
UserCache getUserCache();
- PerDisplayObjectProvider getPerDisplayObjectProvider();
+ DisplayController getDisplayController();
WallpaperColorHints getWallpaperColorHints();
LockedUserState getLockedUserState();
diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
index 4c39aa0..911064c 100644
--- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
+++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
@@ -284,7 +284,7 @@
* Returns the insets of the screen closest to the display given by the context
*/
private Rect getInsets(Context context) {
- DisplayController.Info info = DisplayController.get(context).getInfo();
+ DisplayController.Info info = DisplayController.INSTANCE.get(context).getInfo();
float maxDiff = Float.MAX_VALUE;
Display display = context.getDisplay();
Rect insets = new Rect();
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java
index 1771627..6008287 100644
--- a/src/com/android/launcher3/settings/SettingsActivity.java
+++ b/src/com/android/launcher3/settings/SettingsActivity.java
@@ -292,7 +292,7 @@
* will remove that preference from the list.
*/
protected boolean initPreference(Preference preference) {
- DisplayController.Info info = DisplayController.get(getContext()).getInfo();
+ DisplayController.Info info = DisplayController.INSTANCE.get(getContext()).getInfo();
switch (preference.getKey()) {
case NOTIFICATION_DOTS_PREFERENCE_KEY:
return BuildConfig.NOTIFICATION_DOTS_ENABLED;
diff --git a/src/com/android/launcher3/states/RotationHelper.java b/src/com/android/launcher3/states/RotationHelper.java
index f6017c1..9376518 100644
--- a/src/com/android/launcher3/states/RotationHelper.java
+++ b/src/com/android/launcher3/states/RotationHelper.java
@@ -189,7 +189,7 @@
public void initialize() {
if (mInitialized) return;
mInitialized = true;
- DisplayController displayController = DisplayController.get(mActivity);
+ DisplayController displayController = DisplayController.INSTANCE.get(mActivity);
DisplayController.Info info = displayController.getInfo();
setIgnoreAutoRotateSettings(info.isTablet(info.realBounds));
displayController.addChangeListener(this);
@@ -201,7 +201,7 @@
if (mDestroyed) return;
mDestroyed = true;
mActivity.removeOnDeviceProfileChangeListener(this);
- DisplayController.get(mActivity).removeChangeListener(this);
+ DisplayController.INSTANCE.get(mActivity).removeChangeListener(this);
LauncherPrefs.get(mActivity).removeListener(this, ALLOW_ROTATION);
}
diff --git a/src/com/android/launcher3/util/DaggerSingletonTracker.java b/src/com/android/launcher3/util/DaggerSingletonTracker.java
index 1de32e0..b7a88db 100644
--- a/src/com/android/launcher3/util/DaggerSingletonTracker.java
+++ b/src/com/android/launcher3/util/DaggerSingletonTracker.java
@@ -38,7 +38,7 @@
private boolean mClosed = false;
@Inject
- public DaggerSingletonTracker() {
+ DaggerSingletonTracker() {
}
/**
diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java
index 5ad22bf..ee1af81 100644
--- a/src/com/android/launcher3/util/DisplayController.java
+++ b/src/com/android/launcher3/util/DisplayController.java
@@ -16,7 +16,6 @@
package com.android.launcher3.util;
import static android.view.Display.DEFAULT_DISPLAY;
-import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY;
@@ -56,6 +55,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.dagger.ApplicationContext;
import com.android.launcher3.dagger.LauncherAppComponent;
+import com.android.launcher3.dagger.LauncherAppSingleton;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.util.window.CachedDisplayInfo;
import com.android.launcher3.util.window.WindowManagerProxy;
@@ -71,10 +71,13 @@
import java.util.StringJoiner;
import java.util.concurrent.CopyOnWriteArrayList;
+import javax.inject.Inject;
+
/**
* Utility class to cache properties of default display to avoid a system RPC on every call.
*/
@SuppressLint("NewApi")
+@LauncherAppSingleton
public class DisplayController implements ComponentCallbacks,
DesktopVisibilityListener {
@@ -86,8 +89,8 @@
// TODO(b/254119092) remove all logs with this tag
public static final String TASKBAR_NOT_DESTROYED_TAG = "b/254119092";
- public static final DaggerSingletonObject<PerDisplayObjectProvider> PROVIDER =
- new DaggerSingletonObject<>(LauncherAppComponent::getPerDisplayObjectProvider);
+ public static final DaggerSingletonObject<DisplayController> INSTANCE =
+ new DaggerSingletonObject<>(LauncherAppComponent::getDisplayController);
public static final int CHANGE_ACTIVE_SCREEN = 1 << 0;
public static final int CHANGE_ROTATION = 1 << 1;
@@ -122,54 +125,14 @@
private Info mInfo;
private boolean mDestroyed = false;
- private final int mDisplayId;
- /**
- * Get a DisplayController associated with the given Context.
- * @param context the context (must return a valid display id)
- * @return the DisplayController instance associated with the display id of the context
- */
- public static DisplayController get(Context context) {
- int displayId = DEFAULT_DISPLAY;
- if (context != null) {
- try {
- displayId = context.getDisplay().getDisplayId();
- } catch (UnsupportedOperationException ignored) {
- Log.w(TAG, "DisplayController access from non-display context");
- }
- }
- if (displayId == INVALID_DISPLAY) {
- displayId = DEFAULT_DISPLAY;
- }
- return PROVIDER.get(context).getDisplayController(displayId);
- }
-
- /**
- * Get a DisplayController associated with the given display id.
- * @param context a context
- * @param displayId a display id
- * @return the DisplayController instance associated with the given display id
- */
- public static DisplayController get(Context context, int displayId) {
- return PROVIDER.get(context).getDisplayController(displayId);
- }
-
- @VisibleForTesting
- public DisplayController(@ApplicationContext Context context,
+ @Inject
+ protected DisplayController(@ApplicationContext Context context,
WindowManagerProxy wmProxy,
LauncherPrefs prefs,
DaggerSingletonTracker lifecycle) {
- this(context, wmProxy, prefs, lifecycle, DEFAULT_DISPLAY);
- }
-
- public DisplayController(@ApplicationContext Context context,
- WindowManagerProxy wmProxy,
- LauncherPrefs prefs,
- DaggerSingletonTracker lifecycle,
- int displayId) {
mContext = context;
mWMProxy = wmProxy;
- mDisplayId = displayId;
if (enableTaskbarPinning()) {
LauncherPrefChangeListener prefListener = key -> {
@@ -187,17 +150,11 @@
prefs.addListener(prefListener, TASKBAR_PINNING);
prefs.addListener(prefListener, TASKBAR_PINNING_IN_DESKTOP_MODE);
lifecycle.addCloseable(() -> prefs.removeListener(
- prefListener, TASKBAR_PINNING, TASKBAR_PINNING_IN_DESKTOP_MODE));
+ prefListener, TASKBAR_PINNING, TASKBAR_PINNING_IN_DESKTOP_MODE));
}
Display display = context.getSystemService(DisplayManager.class)
- .getDisplay(displayId);
- if (display == null) {
- // Race when a display is rapidly added then removed.
- mWindowContext = null;
- mInfo = null;
- return;
- }
+ .getDisplay(DEFAULT_DISPLAY);
mWindowContext = mContext.createWindowContext(display, TYPE_APPLICATION, null);
mWindowContext.registerComponentCallbacks(this);
@@ -217,25 +174,20 @@
});
}
- public int getDisplayId() {
- return mDisplayId;
- }
-
/**
- * Returns the current navigation mode for the display associated with the given Context.
+ * Returns the current navigation mode
*/
public static NavigationMode getNavigationMode(Context context) {
- return get(context).getInfo().getNavigationMode();
+ return INSTANCE.get(context).getInfo().getNavigationMode();
}
/**
- * Returns whether taskbar is transient or persistent for the display associated with the given
- * Context.
+ * Returns whether taskbar is transient or persistent.
*
* @return {@code true} if transient, {@code false} if persistent.
*/
public static boolean isTransientTaskbar(Context context) {
- return get(context).getInfo().isTransientTaskbar();
+ return INSTANCE.get(context).getInfo().isTransientTaskbar();
}
/**
@@ -255,27 +207,25 @@
}
/**
- * Returns whether the taskbar is pinned in gesture navigation mode for the display associated
- * with the given Context.
+ * Returns whether the taskbar is pinned in gesture navigation mode.
*/
public static boolean isPinnedTaskbar(Context context) {
- return get(context).getInfo().isPinnedTaskbar();
+ return INSTANCE.get(context).getInfo().isPinnedTaskbar();
}
/**
- * Returns whether the taskbar is forced to be pinned when home is visible for the display
- * associated with the given Context.
+ * Returns whether the taskbar is forced to be pinned when home is visible.
*/
public static boolean showLockedTaskbarOnHome(Context context) {
- return get(context).getInfo().showLockedTaskbarOnHome();
+ return INSTANCE.get(context).getInfo().showLockedTaskbarOnHome();
}
/**
* Returns whether desktop taskbar (pinned taskbar that shows desktop tasks) is to be used
- * on the display associated with the given Context because the display is a freeform display.
+ * on the display because the display is a freeform display.
*/
public static boolean showDesktopTaskbarForFreeformDisplay(Context context) {
- return get(context).getInfo().showDesktopTaskbarForFreeformDisplay();
+ return INSTANCE.get(context).getInfo().showDesktopTaskbarForFreeformDisplay();
}
@Override
@@ -311,7 +261,6 @@
@Override
public final void onConfigurationChanged(Configuration config) {
Log.d(TASKBAR_NOT_DESTROYED_TAG, "DisplayController#onConfigurationChanged: " + config);
- if (mWindowContext == null || mInfo == null) return;
if (config.densityDpi != mInfo.densityDpi
|| config.fontScale != mInfo.fontScale
|| !mInfo.mScreenSizeDp.equals(
@@ -346,7 +295,6 @@
@AnyThread
public void notifyConfigChange() {
- if (mWindowContext == null || mInfo == null) return;
Info oldInfo = mInfo;
Context displayInfoContext = mWindowContext;
@@ -400,7 +348,6 @@
}
private void notifyChange(Context context, int flags) {
- if (mInfo == null) return;
if (mPriorityListener != null) {
mPriorityListener.onDisplayInfoChanged(context, mInfo, flags);
}
@@ -635,7 +582,6 @@
* Dumps the current state information
*/
public void dump(PrintWriter pw) {
- if (mInfo == null) return;
Info info = mInfo;
pw.println("DisplayController.Info:");
pw.println(" normalizedDisplayInfo=" + info.normalizedDisplayInfo);
diff --git a/src/com/android/launcher3/util/PerDisplayObjectProvider.java b/src/com/android/launcher3/util/PerDisplayObjectProvider.java
deleted file mode 100644
index 8cb4e20..0000000
--- a/src/com/android/launcher3/util/PerDisplayObjectProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.util;
-
-/**
- * Interface for providers of objects for which there is one per display. The lifecycle of the
- * object is for the time the display is connected or is that of the app, whichever is shorter.
- */
-public interface PerDisplayObjectProvider {
- /**
- * Get the DisplayController the given display id.
- *
- * @param displayId The display id
- * @return Returns the display controller if the display id is valid and otherwise throws an
- * IllegalArgumentException.
- */
- DisplayController getDisplayController(int displayId);
-}
diff --git a/src_no_quickstep/com/android/launcher3/dagger/Modules.kt b/src_no_quickstep/com/android/launcher3/dagger/Modules.kt
index 8872b79..c3bf7c5 100644
--- a/src_no_quickstep/com/android/launcher3/dagger/Modules.kt
+++ b/src_no_quickstep/com/android/launcher3/dagger/Modules.kt
@@ -16,16 +16,7 @@
package com.android.launcher3.dagger
-import android.content.Context
-import android.view.Display.DEFAULT_DISPLAY
-import com.android.launcher3.LauncherPrefs
-import com.android.launcher3.util.DaggerSingletonTracker
-import com.android.launcher3.util.DisplayController
-import com.android.launcher3.util.PerDisplayObjectProvider
-import com.android.launcher3.util.window.WindowManagerProxy
-import dagger.Binds
import dagger.Module
-import javax.inject.Inject
private object Modules {}
@@ -37,30 +28,5 @@
@Module object StaticObjectModule {}
-@LauncherAppSingleton
-class DefaultPerDisplayObjectProvider
-@Inject
-constructor(
- @ApplicationContext context: Context,
- wmProxy: WindowManagerProxy,
- launcherPrefs: LauncherPrefs,
- lifecycleTracker: DaggerSingletonTracker,
-) : PerDisplayObjectProvider {
- val displayController =
- DisplayController(context, wmProxy, launcherPrefs, lifecycleTracker, DEFAULT_DISPLAY)
-
- override fun getDisplayController(displayId: Int): DisplayController {
- return displayController
- }
-}
-
-@Module
-abstract class PerDisplayObjectProviderModule {
- @Binds
- abstract fun bindPerDisplayObjectProvider(
- impl: DefaultPerDisplayObjectProvider
- ): PerDisplayObjectProvider
-}
-
// Module containing bindings for the final derivative app
@Module abstract class AppModule {}
diff --git a/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt b/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
index 56a0543..9c64ec9 100644
--- a/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/AbstractDeviceProfileTest.kt
@@ -25,18 +25,16 @@
import android.platform.test.rule.IgnoreLimit
import android.platform.test.rule.LimitDevicesRule
import android.util.DisplayMetrics
-import android.view.Display.DEFAULT_DISPLAY
import android.view.Surface
import androidx.test.core.app.ApplicationProvider.getApplicationContext
import androidx.test.platform.app.InstrumentationRegistry
import com.android.launcher3.dagger.LauncherAppComponent
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.testing.shared.ResourceUtils
-import com.android.launcher3.util.AllModulesMinusWMProxyAndPerDisplayObjectProvider
+import com.android.launcher3.util.AllModulesMinusWMProxy
import com.android.launcher3.util.DisplayController
import com.android.launcher3.util.MainThreadInitializedObject.SandboxContext
import com.android.launcher3.util.NavigationMode
-import com.android.launcher3.util.PerDisplayObjectProvider
import com.android.launcher3.util.WindowBounds
import com.android.launcher3.util.rule.TestStabilityRule
import com.android.launcher3.util.rule.setFlags
@@ -70,7 +68,6 @@
protected val testContext: Context = InstrumentationRegistry.getInstrumentation().context
protected lateinit var context: SandboxContext
protected open val runningContext: Context = getApplicationContext()
- private val displayControllerProvider: PerDisplayObjectProvider = mock()
private val displayController: DisplayController = mock()
private val windowManagerProxy: WindowManagerProxy = mock()
private val launcherPrefs: LauncherPrefs = mock()
@@ -315,7 +312,7 @@
DaggerAbsDPTestSandboxComponent.builder()
.bindWMProxy(windowManagerProxy)
.bindLauncherPrefs(launcherPrefs)
- .bindDisplayControllerProvider(displayControllerProvider)
+ .bindDisplayController(displayController)
)
whenever(launcherPrefs.get(LauncherPrefs.TASKBAR_PINNING)).thenReturn(false)
@@ -326,8 +323,6 @@
whenever(launcherPrefs.get(LauncherPrefs.WORKSPACE_SIZE)).thenReturn("")
whenever(launcherPrefs.get(LauncherPrefs.DB_FILE)).thenReturn("")
whenever(launcherPrefs.get(LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE)).thenReturn(true)
- whenever(displayControllerProvider.getDisplayController(DEFAULT_DISPLAY))
- .thenReturn(displayController)
val info = spy(DisplayController.Info(context, windowManagerProxy, perDisplayBoundsCache))
whenever(displayController.info).thenReturn(info)
whenever(info.isTransientTaskbar).thenReturn(isGestureMode)
@@ -370,7 +365,7 @@
}
@LauncherAppSingleton
-@Component(modules = [AllModulesMinusWMProxyAndPerDisplayObjectProvider::class])
+@Component(modules = [AllModulesMinusWMProxy::class])
interface AbsDPTestSandboxComponent : LauncherAppComponent {
@Component.Builder
@@ -379,7 +374,7 @@
@BindsInstance fun bindLauncherPrefs(prefs: LauncherPrefs): Builder
- @BindsInstance fun bindDisplayControllerProvider(dc: PerDisplayObjectProvider): Builder
+ @BindsInstance fun bindDisplayController(displayController: DisplayController): Builder
override fun build(): AbsDPTestSandboxComponent
}
diff --git a/tests/multivalentTests/src/com/android/launcher3/util/DaggerGraphs.kt b/tests/multivalentTests/src/com/android/launcher3/util/DaggerGraphs.kt
index 8152552..b66a9d3 100644
--- a/tests/multivalentTests/src/com/android/launcher3/util/DaggerGraphs.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/util/DaggerGraphs.kt
@@ -20,7 +20,6 @@
import com.android.launcher3.LauncherPrefs
import com.android.launcher3.dagger.ApiWrapperModule
import com.android.launcher3.dagger.AppModule
-import com.android.launcher3.dagger.PerDisplayObjectProviderModule
import com.android.launcher3.dagger.StaticObjectModule
import com.android.launcher3.dagger.WindowManagerProxyModule
import dagger.Binds
@@ -40,47 +39,15 @@
ApiWrapperModule::class,
WindowManagerProxyModule::class,
StaticObjectModule::class,
- PerDisplayObjectProviderModule::class,
AppModule::class,
]
)
class AllModulesForTest
/** All modules except the WMProxy */
-@Module(
- includes =
- [
- ApiWrapperModule::class,
- StaticObjectModule::class,
- PerDisplayObjectProviderModule::class,
- AppModule::class,
- ]
-)
+@Module(includes = [ApiWrapperModule::class, StaticObjectModule::class, AppModule::class])
class AllModulesMinusWMProxy
/** All modules except the ApiWrapper */
-@Module(
- includes =
- [
- WindowManagerProxyModule::class,
- StaticObjectModule::class,
- PerDisplayObjectProviderModule::class,
- AppModule::class,
- ]
-)
+@Module(includes = [WindowManagerProxyModule::class, StaticObjectModule::class, AppModule::class])
class AllModulesMinusApiWrapper
-
-@Module(includes = [ApiWrapperModule::class, StaticObjectModule::class, AppModule::class])
-class AllModulesMinusWMProxyAndPerDisplayObjectProvider
-
-/** All modules except PerDisplayObjectProvider */
-@Module(
- includes =
- [
- ApiWrapperModule::class,
- WindowManagerProxyModule::class,
- StaticObjectModule::class,
- AppModule::class,
- ]
-)
-class AllModulesMinusPerDisplayObjectProvider
diff --git a/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt b/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt
index acf5908..588a668 100644
--- a/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt
+++ b/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt
@@ -139,7 +139,7 @@
whenever(context.resources).thenReturn(resources)
// Initialize DisplayController
- displayController = DisplayController.get(context)
+ displayController = DisplayController.INSTANCE.get(context)
displayController.addChangeListener(displayInfoChangeListener)
}