Remove all calls to getComponent(StatusBar.class)
Bug: 143224715
Test: atest SystemUITests && manual
Change-Id: I349836eed9c1e988205681b93f86e967156f90a9
diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
index 3b63e79..2c17f22 100644
--- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
+++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java
@@ -101,11 +101,8 @@
abstract NotificationData.KeyguardEnvironment bindKeyguardEnvironment(
KeyguardEnvironmentImpl keyguardEnvironment);
- @Singleton
- @Provides
- static ShadeController provideShadeController(Context context) {
- return SysUiServiceProvider.getComponent(context, StatusBar.class);
- }
+ @Binds
+ abstract ShadeController provideShadeController(CarStatusBar statusBar);
@Provides
@Singleton
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 1d14c34..9af172f 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -79,6 +79,7 @@
import com.android.systemui.plugins.FalsingManager;
import com.android.systemui.plugins.qs.QS;
import com.android.systemui.qs.car.CarQSFragment;
+import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
@@ -283,7 +284,7 @@
VisualStabilityManager visualStabilityManager,
DeviceProvisionedController deviceProvisionedController,
NavigationBarController navigationBarController,
- AssistManager assistManager,
+ Lazy<AssistManager> assistManagerLazy,
NotificationListener notificationListener,
ConfigurationController configurationController,
StatusBarWindowController statusBarWindowController,
@@ -294,6 +295,7 @@
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
DozeServiceHost dozeServiceHost,
PowerManager powerManager,
+ ScreenPinningRequest screenPinningRequest,
DozeScrimController dozeScrimController,
CommandQueue commandQueue,
PluginManager pluginManager,
@@ -352,7 +354,7 @@
visualStabilityManager,
deviceProvisionedController,
navigationBarController,
- assistManager,
+ assistManagerLazy,
notificationListener,
configurationController,
statusBarWindowController,
@@ -364,6 +366,7 @@
biometricUnlockControllerLazy,
dozeServiceHost,
powerManager,
+ screenPinningRequest,
dozeScrimController,
commandQueue,
pluginManager,
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
index 542fa44..b40cbe8b 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBarModule.java
@@ -36,6 +36,7 @@
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.navigationbar.car.CarNavigationBarController;
import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
@@ -152,7 +153,7 @@
VisualStabilityManager visualStabilityManager,
DeviceProvisionedController deviceProvisionedController,
NavigationBarController navigationBarController,
- AssistManager assistManager,
+ Lazy<AssistManager> assistManagerLazy,
NotificationListener notificationListener,
ConfigurationController configurationController,
StatusBarWindowController statusBarWindowController,
@@ -163,6 +164,7 @@
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
DozeServiceHost dozeServiceHost,
PowerManager powerManager,
+ ScreenPinningRequest screenPinningRequest,
DozeScrimController dozeScrimController,
CommandQueue commandQueue,
PluginManager pluginManager,
@@ -220,7 +222,7 @@
visualStabilityManager,
deviceProvisionedController,
navigationBarController,
- assistManager,
+ assistManagerLazy,
notificationListener,
configurationController,
statusBarWindowController,
@@ -231,6 +233,7 @@
biometricUnlockControllerLazy,
dozeServiceHost,
powerManager,
+ screenPinningRequest,
dozeScrimController,
commandQueue,
pluginManager,
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index b3f32af..b14f7a9e 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -92,6 +92,7 @@
import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper;
import com.android.systemui.statusbar.phone.NotificationGroupManager;
import com.android.systemui.statusbar.phone.ShadeController;
+import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.AccessibilityController;
@@ -328,6 +329,7 @@
@Inject Lazy<DozeParameters> mDozeParameters;
@Inject Lazy<IWallpaperManager> mWallpaperManager;
@Inject Lazy<CommandQueue> mCommandQueue;
+ @Inject Lazy<StatusBar> mStatusBar;
@Inject
public Dependency() {
@@ -517,6 +519,7 @@
mProviders.put(DozeParameters.class, mDozeParameters::get);
mProviders.put(IWallpaperManager.class, mWallpaperManager::get);
mProviders.put(CommandQueue.class, mCommandQueue::get);
+ mProviders.put(StatusBar.class, mStatusBar::get);
// TODO(b/118592525): to support multi-display , we start to add something which is
// per-display, while others may be global. I think it's time to add
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
index 398826c..dd00eee 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java
@@ -42,10 +42,8 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.settingslib.applications.InterestingConfigChanges;
import com.android.systemui.ConfigurationChangedReceiver;
-import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.assist.ui.DefaultUiController;
-import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
@@ -163,14 +161,15 @@
AssistUtils assistUtils,
AssistHandleBehaviorController handleController,
CommandQueue commandQueue,
- BroadcastDispatcher broadcastDispatcher) {
+ PhoneStateMonitor phoneStateMonitor,
+ OverviewProxyService overviewProxyService) {
mContext = context;
mDeviceProvisionedController = controller;
mCommandQueue = commandQueue;
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mAssistUtils = assistUtils;
mAssistDisclosure = new AssistDisclosure(context, new Handler());
- mPhoneStateMonitor = new PhoneStateMonitor(context, broadcastDispatcher);
+ mPhoneStateMonitor = phoneStateMonitor;
mHandleController = handleController;
registerVoiceInteractionSessionListener();
@@ -182,8 +181,7 @@
mUiController = new DefaultUiController(mContext);
- OverviewProxyService overviewProxy = Dependency.get(OverviewProxyService.class);
- overviewProxy.addCallback(new OverviewProxyService.OverviewProxyListener() {
+ overviewProxyService.addCallback(new OverviewProxyService.OverviewProxyListener() {
@Override
public void onAssistantProgress(float progress) {
// Progress goes from 0 to 1 to indicate how close the assist gesture is to
diff --git a/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java b/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java
index 95d611a..8cccffa 100644
--- a/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java
+++ b/packages/SystemUI/src/com/android/systemui/assist/PhoneStateMonitor.java
@@ -28,7 +28,6 @@
import androidx.annotation.Nullable;
import com.android.systemui.Dependency;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -39,9 +38,16 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import dagger.Lazy;
/** Class to monitor and report the state of the phone. */
-final class PhoneStateMonitor {
+@Singleton
+public final class PhoneStateMonitor {
private static final int PHONE_STATE_AOD1 = 1;
private static final int PHONE_STATE_AOD2 = 2;
@@ -63,13 +69,17 @@
};
private final Context mContext;
+ private final Optional<Lazy<StatusBar>> mStatusBarOptionalLazy;
private final StatusBarStateController mStatusBarStateController;
private boolean mLauncherShowing;
@Nullable private ComponentName mDefaultHome;
- PhoneStateMonitor(Context context, BroadcastDispatcher broadcastDispatcher) {
+ @Inject
+ PhoneStateMonitor(Context context, BroadcastDispatcher broadcastDispatcher,
+ Optional<Lazy<StatusBar>> statusBarOptionalLazy) {
mContext = context;
+ mStatusBarOptionalLazy = statusBarOptionalLazy;
mStatusBarStateController = Dependency.get(StatusBarStateController.class);
ActivityManagerWrapper activityManagerWrapper = ActivityManagerWrapper.getInstance();
@@ -178,16 +188,16 @@
}
private boolean isAppImmersive() {
- return SysUiServiceProvider.getComponent(mContext, StatusBar.class).inImmersiveMode();
+ return mStatusBarOptionalLazy.get().get().inImmersiveMode();
}
private boolean isAppFullscreen() {
- return SysUiServiceProvider.getComponent(mContext, StatusBar.class).inFullscreenMode();
+ return mStatusBarOptionalLazy.get().get().inFullscreenMode();
}
private boolean isBouncerShowing() {
- StatusBar statusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- return statusBar != null && statusBar.isBouncerShowing();
+ return mStatusBarOptionalLazy.map(
+ statusBarLazy -> statusBarLazy.get().isBouncerShowing()).orElse(false);
}
private boolean isKeyguardLocked() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
index 6d434b1..c01bc8fe 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileHost.java
@@ -33,7 +33,6 @@
import com.android.systemui.DumpController;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.BgLooper;
import com.android.systemui.dagger.qualifiers.MainHandler;
@@ -60,6 +59,7 @@
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Optional;
import java.util.function.Predicate;
import javax.inject.Inject;
@@ -88,7 +88,7 @@
private final StatusBarIconController mIconController;
private final ArrayList<QSFactory> mQsFactories = new ArrayList<>();
private int mCurrentUser;
- private StatusBar mStatusBar;
+ private final Optional<StatusBar> mStatusBarOptional;
private QSColorController mQSColorController = QSColorController.Companion.getInstance();
@@ -102,7 +102,8 @@
TunerService tunerService,
Provider<AutoTileManager> autoTiles,
DumpController dumpController,
- BroadcastDispatcher broadcastDispatcher) {
+ BroadcastDispatcher broadcastDispatcher,
+ Optional<StatusBar> statusBarOptional) {
mIconController = iconController;
mContext = context;
mTunerService = tunerService;
@@ -111,6 +112,7 @@
mBroadcastDispatcher = broadcastDispatcher;
mServices = new TileServices(this, bgLooper, mBroadcastDispatcher);
+ mStatusBarOptional = statusBarOptional;
defaultFactory.setHost(this);
mQsFactories.add(defaultFactory);
@@ -185,26 +187,17 @@
@Override
public void collapsePanels() {
- if (mStatusBar == null) {
- mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- }
- mStatusBar.postAnimateCollapsePanels();
+ mStatusBarOptional.ifPresent(StatusBar::postAnimateCollapsePanels);
}
@Override
public void forceCollapsePanels() {
- if (mStatusBar == null) {
- mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- }
- mStatusBar.postAnimateForceCollapsePanels();
+ mStatusBarOptional.ifPresent(StatusBar::postAnimateForceCollapsePanels);
}
@Override
public void openPanels() {
- if (mStatusBar == null) {
- mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- }
- mStatusBar.postAnimateOpenPanels();
+ mStatusBarOptional.ifPresent(StatusBar::postAnimateOpenPanels);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
index ba9fc3d..ae48db2 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
@@ -56,7 +56,6 @@
import com.android.internal.policy.ScreenDecorationsUtils;
import com.android.systemui.Dumpable;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.model.SysUiState;
import com.android.systemui.pip.PipUI;
import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
@@ -85,6 +84,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;
+import dagger.Lazy;
+
/**
* Class to send information from overview to launcher with a binder.
*/
@@ -103,6 +104,7 @@
private final Context mContext;
private final PipUI mPipUI;
+ private final Optional<Lazy<StatusBar>> mStatusBarOptionalLazy;
private final Optional<Divider> mDividerOptional;
private SysUiState mSysUiState;
private final Handler mHandler;
@@ -139,11 +141,9 @@
long token = Binder.clearCallingIdentity();
try {
mHandler.post(() -> {
- StatusBar statusBar = SysUiServiceProvider.getComponent(mContext,
- StatusBar.class);
- if (statusBar != null) {
- statusBar.showScreenPinningRequest(taskId, false /* allowCancel */);
- }
+ mStatusBarOptionalLazy.ifPresent(
+ statusBarLazy -> statusBarLazy.get().showScreenPinningRequest(taskId,
+ false /* allowCancel */));
});
} finally {
Binder.restoreCallingIdentity(token);
@@ -178,25 +178,25 @@
long token = Binder.clearCallingIdentity();
try {
// TODO move this logic to message queue
- mHandler.post(()->{
- StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- if (bar != null) {
-
+ mStatusBarOptionalLazy.ifPresent(statusBarLazy -> {
+ mHandler.post(()-> {
+ StatusBar statusBar = statusBarLazy.get();
int action = event.getActionMasked();
if (action == ACTION_DOWN) {
mInputFocusTransferStarted = true;
mInputFocusTransferStartY = event.getY();
mInputFocusTransferStartMillis = event.getEventTime();
- bar.onInputFocusTransfer(mInputFocusTransferStarted, 0 /* velocity */);
+ statusBar.onInputFocusTransfer(
+ mInputFocusTransferStarted, 0 /* velocity */);
}
if (action == ACTION_UP || action == ACTION_CANCEL) {
mInputFocusTransferStarted = false;
- bar.onInputFocusTransfer(mInputFocusTransferStarted,
+ statusBar.onInputFocusTransfer(mInputFocusTransferStarted,
(event.getY() - mInputFocusTransferStartY)
/ (event.getEventTime() - mInputFocusTransferStartMillis));
}
event.recycle();
- }
+ });
});
} finally {
Binder.restoreCallingIdentity(token);
@@ -477,9 +477,10 @@
public OverviewProxyService(Context context, DeviceProvisionedController provisionController,
NavigationBarController navBarController, NavigationModeController navModeController,
StatusBarWindowController statusBarWinController, SysUiState sysUiState, PipUI pipUI,
- Optional<Divider> dividerOptional) {
+ Optional<Divider> dividerOptional, Optional<Lazy<StatusBar>> statusBarOptionalLazy) {
mContext = context;
mPipUI = pipUI;
+ mStatusBarOptionalLazy = statusBarOptionalLazy;
mHandler = new Handler();
mNavBarController = navBarController;
mStatusBarWinController = statusBarWinController;
@@ -594,11 +595,10 @@
public void cleanupAfterDeath() {
if (mInputFocusTransferStarted) {
mHandler.post(()-> {
- StatusBar bar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- if (bar != null) {
+ mStatusBarOptionalLazy.ifPresent(statusBarLazy -> {
mInputFocusTransferStarted = false;
- bar.onInputFocusTransfer(false, 0 /* velocity */);
- }
+ statusBarLazy.get().onInputFocusTransfer(false, 0 /* velocity */);
+ });
});
}
startConnectionToCurrentUser();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
index 2d1c087..d819b8e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
@@ -46,7 +46,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.R;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.WindowManagerWrapper;
@@ -56,11 +55,17 @@
import com.android.systemui.util.leak.RotationUtils;
import java.util.ArrayList;
+import java.util.Optional;
+
+import javax.inject.Inject;
+
+import dagger.Lazy;
public class ScreenPinningRequest implements View.OnClickListener,
NavigationModeController.ModeChangedListener {
private final Context mContext;
+ private final Optional<Lazy<StatusBar>> mStatusBarOptionalLazy;
private final AccessibilityManager mAccessibilityService;
private final WindowManager mWindowManager;
@@ -72,8 +77,10 @@
// Id of task to be pinned or locked.
private int taskId;
- public ScreenPinningRequest(Context context) {
+ @Inject
+ public ScreenPinningRequest(Context context, Optional<Lazy<StatusBar>> statusBarOptionalLazy) {
mContext = context;
+ mStatusBarOptionalLazy = statusBarOptionalLazy;
mAccessibilityService = (AccessibilityManager)
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
mWindowManager = (WindowManager)
@@ -254,9 +261,8 @@
.setVisibility(View.INVISIBLE);
}
- StatusBar statusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- NavigationBarView navigationBarView =
- statusBar != null ? statusBar.getNavigationBarView() : null;
+ NavigationBarView navigationBarView = mStatusBarOptionalLazy.map(
+ statusBarLazy -> statusBarLazy.get().getNavigationBarView()).orElse(null);
final boolean recentsVisible = navigationBarView != null
&& navigationBarView.isRecentsButtonVisible();
boolean touchExplorationEnabled = mAccessibilityService.isTouchExplorationEnabled();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
index 1de2cbb..f90e561 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationGutsManager.java
@@ -41,7 +41,6 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationLifetimeExtender;
@@ -63,6 +62,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;
+import dagger.Lazy;
+
/**
* Handles various NotificationGuts related tasks, such as binding guts to a row, opening and
* closing guts, and keeping track of the currently exposed notification guts.
@@ -99,15 +100,15 @@
@VisibleForTesting
protected String mKeyToRemoveOnGutsClosed;
- private StatusBar mStatusBar;
+ private final Lazy<StatusBar> mStatusBarLazy;
private Runnable mOpenRunnable;
@Inject
- public NotificationGutsManager(
- Context context,
- VisualStabilityManager visualStabilityManager) {
+ public NotificationGutsManager(Context context, VisualStabilityManager visualStabilityManager,
+ Lazy<StatusBar> statusBarLazy) {
mContext = context;
mVisualStabilityManager = visualStabilityManager;
+ mStatusBarLazy = statusBarLazy;
mAccessibilityManager = (AccessibilityManager)
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
@@ -119,7 +120,6 @@
mListContainer = listContainer;
mCheckSaveListener = checkSave;
mOnSettingsClickListener = onSettingsClick;
- mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
}
public void setNotificationActivityStarter(
@@ -392,7 +392,7 @@
Runnable r = () -> Dependency.get(Dependency.MAIN_HANDLER).post(
() -> openGutsInternal(view, x, y, menuItem));
- mStatusBar.executeRunnableDismissingKeyguard(
+ mStatusBarLazy.get().executeRunnableDismissingKeyguard(
r,
null /* cancelAction */,
false /* dismissShade */,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
index 0092cc9..8b31da4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragment.java
@@ -32,7 +32,6 @@
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.StatusBarState;
@@ -82,7 +81,7 @@
mKeyguardStateController = Dependency.get(KeyguardStateController.class);
mNetworkController = Dependency.get(NetworkController.class);
mStatusBarStateController = Dependency.get(StatusBarStateController.class);
- mStatusBarComponent = SysUiServiceProvider.getComponent(getContext(), StatusBar.class);
+ mStatusBarComponent = Dependency.get(StatusBar.class);
mCommandQueue = Dependency.get(CommandQueue.class);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
index 2854355..a1af5e8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java
@@ -81,7 +81,7 @@
private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
private BiometricUnlockController mBiometricUnlockController;
private final KeyguardViewMediator mKeyguardViewMediator;
- private final AssistManager mAssistManager;
+ private final Lazy<AssistManager> mAssistManagerLazy;
private final DozeScrimController mDozeScrimController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final VisualStabilityManager mVisualStabilityManager;
@@ -105,7 +105,7 @@
ScrimController scrimController,
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
KeyguardViewMediator keyguardViewMediator,
- AssistManager assistManager,
+ Lazy<AssistManager> assistManagerLazy,
DozeScrimController dozeScrimController, KeyguardUpdateMonitor keyguardUpdateMonitor,
VisualStabilityManager visualStabilityManager,
PulseExpansionHandler pulseExpansionHandler,
@@ -122,7 +122,7 @@
mScrimController = scrimController;
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
mKeyguardViewMediator = keyguardViewMediator;
- mAssistManager = assistManager;
+ mAssistManagerLazy = assistManagerLazy;
mDozeScrimController = dozeScrimController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mVisualStabilityManager = visualStabilityManager;
@@ -225,7 +225,7 @@
if (reason == DozeEvent.PULSE_REASON_SENSOR_LONG_PRESS) {
mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE,
"com.android.systemui:LONG_PRESS");
- mAssistManager.startAssist(new Bundle());
+ mAssistManagerLazy.get().startAssist(new Bundle());
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index 1c46cf8..2674db4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -91,7 +91,6 @@
import com.android.internal.view.AppearanceRegion;
import com.android.systemui.Dependency;
import com.android.systemui.R;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.assist.AssistHandleViewController;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -123,6 +122,8 @@
import javax.inject.Inject;
+import dagger.Lazy;
+
/**
* Fragment containing the NavigationBarFragment. Contains logic for what happens
* on clicks and view states of the nav bar.
@@ -162,6 +163,8 @@
private int mDisabledFlags1;
private int mDisabledFlags2;
+ private final Lazy<StatusBar> mStatusBarLazy;
+ private Recents mRecents;
private StatusBar mStatusBar;
private final Divider mDivider;
private final Optional<Recents> mRecentsOptional;
@@ -213,7 +216,7 @@
mNavigationBarView.getRotationButtonController().setRotateSuggestionButtonState(false);
// Hide the notifications panel when quick step starts
- mStatusBar.collapsePanel(true /* animate */);
+ mStatusBarLazy.get().collapsePanel(true /* animate */);
}
@Override
@@ -267,15 +270,15 @@
StatusBarStateController statusBarStateController,
SysUiState sysUiFlagsContainer,
BroadcastDispatcher broadcastDispatcher,
- CommandQueue commandQueue,
- Divider divider,
- Optional<Recents> recentsOptional) {
+ CommandQueue commandQueue, Divider divider,
+ Optional<Recents> recentsOptional, Lazy<StatusBar> statusBarLazy) {
mAccessibilityManagerWrapper = accessibilityManagerWrapper;
mDeviceProvisionedController = deviceProvisionedController;
mStatusBarStateController = statusBarStateController;
mMetricsLogger = metricsLogger;
mAssistManager = assistManager;
mSysUiFlagsContainer = sysUiFlagsContainer;
+ mStatusBarLazy = statusBarLazy;
mAssistantAvailable = mAssistManager.getAssistInfoForUser(UserHandle.USER_CURRENT) != null;
mOverviewProxyService = overviewProxyService;
mNavigationModeController = navigationModeController;
@@ -292,7 +295,6 @@
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCommandQueue.observe(getLifecycle(), this);
- mStatusBar = SysUiServiceProvider.getComponent(getContext(), StatusBar.class);
mWindowManager = getContext().getSystemService(WindowManager.class);
mAccessibilityManager = getContext().getSystemService(AccessibilityManager.class);
mContentResolver = getContext().getContentResolver();
@@ -343,7 +345,7 @@
mIsOnDefaultDisplay = mDisplayId == Display.DEFAULT_DISPLAY;
}
- mNavigationBarView.setComponents(mStatusBar.getPanel(), mAssistManager);
+ mNavigationBarView.setComponents(mStatusBarLazy.get().getPanel(), mAssistManager);
mNavigationBarView.setDisabledFlags(mDisabledFlags1);
mNavigationBarView.setOnVerticalChangedListener(this::onVerticalChanged);
mNavigationBarView.setOnTouchListener(this::onNavigationTouch);
@@ -750,7 +752,7 @@
TelecomManager telecomManager =
getContext().getSystemService(TelecomManager.class);
if (telecomManager != null && telecomManager.isRinging()) {
- if (mStatusBar.isKeyguardShowing()) {
+ if (mStatusBarLazy.get().isKeyguardShowing()) {
Log.i(TAG, "Ignoring HOME; there's a ringing incoming call. " +
"No heads up");
mHomeBlockedThisTouch = true;
@@ -760,14 +762,14 @@
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- mStatusBar.awakenDreams();
+ mStatusBarLazy.get().awakenDreams();
break;
}
return false;
}
private void onVerticalChanged(boolean isVertical) {
- mStatusBar.setQsScrimEnabled(!isVertical);
+ mStatusBarLazy.get().setQsScrimEnabled(!isVertical);
}
private boolean onNavigationTouch(View v, MotionEvent event) {
@@ -789,7 +791,7 @@
args.putInt(
AssistManager.INVOCATION_TYPE_KEY, AssistManager.INVOCATION_HOME_BUTTON_LONG_PRESS);
mAssistManager.startAssist(args);
- mStatusBar.awakenDreams();
+ mStatusBarLazy.get().awakenDreams();
if (mNavigationBarView != null) {
mNavigationBarView.abortCurrentGesture();
@@ -818,7 +820,7 @@
LatencyTracker.getInstance(getContext()).onActionStart(
LatencyTracker.ACTION_TOGGLE_RECENTS);
}
- mStatusBar.awakenDreams();
+ mStatusBarLazy.get().awakenDreams();
mCommandQueue.toggleRecentApps();
}
@@ -916,7 +918,7 @@
return false;
}
- return mStatusBar.toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS,
+ return mStatusBarLazy.get().toggleSplitScreenMode(MetricsEvent.ACTION_WINDOW_DOCK_LONGPRESS,
MetricsEvent.ACTION_WINDOW_UNDOCK_LONGPRESS);
}
@@ -1039,7 +1041,7 @@
private void checkBarModes() {
// We only have status bar on default display now.
if (mIsOnDefaultDisplay) {
- mStatusBar.checkBarModes();
+ mStatusBarLazy.get().checkBarModes();
} else {
checkNavBarModes();
}
@@ -1053,7 +1055,7 @@
* Checks current navigation bar mode and make transitions.
*/
public void checkNavBarModes() {
- final boolean anim = mStatusBar.isDeviceInteractive()
+ final boolean anim = mStatusBarLazy.get().isDeviceInteractive()
&& mNavigationBarWindowState != WINDOW_STATE_HIDDEN;
mNavigationBarView.getBarTransitions().transitionTo(mNavigationBarMode, anim);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 910300c..d7bd067 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -440,7 +440,7 @@
? new GestureRecorder("/sdcard/statusbar_gestures.dat")
: null;
- private ScreenPinningRequest mScreenPinningRequest;
+ private final ScreenPinningRequest mScreenPinningRequest;
private final MetricsLogger mMetricsLogger;
@@ -658,7 +658,7 @@
VisualStabilityManager visualStabilityManager,
DeviceProvisionedController deviceProvisionedController,
NavigationBarController navigationBarController,
- AssistManager assistManager,
+ Lazy<AssistManager> assistManagerLazy,
NotificationListener notificationListener,
ConfigurationController configurationController,
StatusBarWindowController statusBarWindowController,
@@ -670,6 +670,7 @@
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
DozeServiceHost dozeServiceHost,
PowerManager powerManager,
+ ScreenPinningRequest screenPinningRequest,
DozeScrimController dozeScrimController,
CommandQueue commandQueue,
PluginManager pluginManager,
@@ -725,7 +726,7 @@
mVisualStabilityManager = visualStabilityManager;
mDeviceProvisionedController = deviceProvisionedController;
mNavigationBarController = navigationBarController;
- mAssistManager = assistManager;
+ mAssistManagerLazy = assistManagerLazy;
mNotificationListener = notificationListener;
mConfigurationController = configurationController;
mStatusBarWindowController = statusBarWindowController;
@@ -736,6 +737,7 @@
mScrimController = scrimController;
mKeyguardLiftController = keyguardLiftController;
mLockscreenWallpaperLazy = lockscreenWallpaperLazy;
+ mScreenPinningRequest = screenPinningRequest;
mDozeScrimController = dozeScrimController;
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
mCommandQueue = commandQueue;
@@ -895,8 +897,6 @@
mNotificationPanel, mAmbientIndicationContainer);
putComponent(DozeHost.class, mDozeServiceHost);
- mScreenPinningRequest = new ScreenPinningRequest(mContext);
-
Dependency.get(ActivityStarterDelegate.class).setActivityStarterImpl(this);
mConfigurationController.addCallback(this);
@@ -1251,8 +1251,8 @@
final ActivityStarter activityStarter = Dependency.get(ActivityStarter.class);
mNotificationActivityStarter = new StatusBarNotificationActivityStarter(mContext,
- mCommandQueue, mAssistManager, mNotificationPanel, mPresenter, mEntryManager,
- mHeadsUpManager, activityStarter, mActivityLaunchAnimator,
+ mCommandQueue, mAssistManagerLazy.get(), mNotificationPanel, mPresenter,
+ mEntryManager, mHeadsUpManager, activityStarter, mActivityLaunchAnimator,
mBarService, mStatusBarStateController, mKeyguardManager, mDreamManager,
mRemoteInputManager, mStatusBarRemoteInputCallback, mGroupManager,
mLockscreenUserManager, this, mKeyguardStateController,
@@ -2600,7 +2600,7 @@
final boolean afterKeyguardGone = mActivityIntentHelper.wouldLaunchResolverActivity(
intent, mLockscreenUserManager.getCurrentUserId());
Runnable runnable = () -> {
- mAssistManager.hideAssist();
+ mAssistManagerLazy.get().hideAssist();
intent.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(flags);
@@ -3082,7 +3082,7 @@
mStatusBarStateController.setLeaveOpenOnKeyguardHide(false);
mPendingRemoteInputView = null;
updateIsKeyguard();
- mAssistManager.onLockscreenShown();
+ mAssistManagerLazy.get().onLockscreenShown();
}
public boolean hideKeyguard() {
@@ -3477,7 +3477,7 @@
mCommandQueue.animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */);
visibilityChanged(false);
- mAssistManager.hideAssist();
+ mAssistManagerLazy.get().hideAssist();
}
return false;
}
@@ -4073,7 +4073,7 @@
protected NotificationShelf mNotificationShelf;
protected EmptyShadeView mEmptyShadeView;
- private final AssistManager mAssistManager;
+ private final Lazy<AssistManager> mAssistManagerLazy;
public boolean isDeviceInteractive() {
return mDeviceInteractive;
@@ -4277,7 +4277,7 @@
// TODO: Dismiss Keyguard.
}
if (intent.isActivity()) {
- mAssistManager.hideAssist();
+ mAssistManagerLazy.get().hideAssist();
}
if (intentSentUiThreadCallback != null) {
postOnUiThread(intentSentUiThreadCallback);
@@ -4395,9 +4395,7 @@
@Override
public void showAssistDisclosure() {
- if (mAssistManager != null) {
- mAssistManager.showDisclosure();
- }
+ mAssistManagerLazy.get().showDisclosure();
}
public NotificationPanelView getPanel() {
@@ -4406,9 +4404,7 @@
@Override
public void startAssist(Bundle args) {
- if (mAssistManager != null) {
- mAssistManager.startAssist(args);
- }
+ mAssistManagerLazy.get().startAssist(args);
}
// End Extra BaseStatusBarMethods.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java
index 9811f96..8c04e2b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarModule.java
@@ -37,6 +37,7 @@
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.FalsingManager;
+import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
@@ -136,7 +137,7 @@
VisualStabilityManager visualStabilityManager,
DeviceProvisionedController deviceProvisionedController,
NavigationBarController navigationBarController,
- AssistManager assistManager,
+ Lazy<AssistManager> assistManagerLazy,
NotificationListener notificationListener,
ConfigurationController configurationController,
StatusBarWindowController statusBarWindowController,
@@ -148,6 +149,7 @@
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
DozeServiceHost dozeServiceHost,
PowerManager powerManager,
+ ScreenPinningRequest screenPinningRequest,
DozeScrimController dozeScrimController,
CommandQueue commandQueue,
PluginManager pluginManager,
@@ -204,7 +206,7 @@
visualStabilityManager,
deviceProvisionedController,
navigationBarController,
- assistManager,
+ assistManagerLazy,
notificationListener,
configurationController,
statusBarWindowController,
@@ -216,6 +218,7 @@
biometricUnlockControllerLazy,
dozeServiceHost,
powerManager,
+ screenPinningRequest,
dozeScrimController,
commandQueue,
pluginManager,
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
index 2c70fb4..fc57981 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
@@ -58,7 +58,6 @@
import com.android.settingslib.volume.MediaSessions;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
-import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.VolumeDialogController;
@@ -70,6 +69,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -115,7 +115,7 @@
private final Context mContext;
private AudioManager mAudio;
private IAudioService mAudioService;
- protected StatusBar mStatusBar;
+ private final Optional<StatusBar> mStatusBarOptional;
private final NotificationManager mNoMan;
private final SettingObserver mObserver;
private final Receiver mReceiver = new Receiver();
@@ -141,8 +141,10 @@
protected final BroadcastDispatcher mBroadcastDispatcher;
@Inject
- public VolumeDialogControllerImpl(Context context, BroadcastDispatcher broadcastDispatcher) {
+ public VolumeDialogControllerImpl(Context context, BroadcastDispatcher broadcastDispatcher,
+ Optional<StatusBar> statusBarOptional) {
mContext = context.getApplicationContext();
+ mStatusBarOptional = statusBarOptional;
mNotificationManager = (NotificationManager) mContext.getSystemService(
Context.NOTIFICATION_SERVICE);
Events.writeEvent(mContext, Events.EVENT_COLLECTION_STARTED);
@@ -161,7 +163,6 @@
mHasVibrator = mVibrator != null && mVibrator.hasVibrator();
mAudioService = IAudioService.Stub.asInterface(
ServiceManager.getService(Context.AUDIO_SERVICE));
- updateStatusBar();
boolean accessibilityVolumeStreamActive = context.getSystemService(
AccessibilityManager.class).isAccessibilityVolumeStreamActive();
@@ -444,23 +445,16 @@
return changed;
}
- private void updateStatusBar() {
- if (mStatusBar == null) {
- mStatusBar = SysUiServiceProvider.getComponent(mContext, StatusBar.class);
- }
- }
-
private boolean shouldShowUI(int flags) {
- updateStatusBar();
// if status bar isn't null, check if phone is in AOD, else check flags
// since we could be using a different status bar
- return mStatusBar != null ?
- mStatusBar.getWakefulnessState() != WakefulnessLifecycle.WAKEFULNESS_ASLEEP
- && mStatusBar.getWakefulnessState() !=
- WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP
- && mStatusBar.isDeviceInteractive()
- && (flags & AudioManager.FLAG_SHOW_UI) != 0 && mShowVolumeDialog
- : mShowVolumeDialog && (flags & AudioManager.FLAG_SHOW_UI) != 0;
+ return mStatusBarOptional.map(statusBar ->
+ statusBar.getWakefulnessState() != WakefulnessLifecycle.WAKEFULNESS_ASLEEP
+ && statusBar.getWakefulnessState()
+ != WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP
+ && statusBar.isDeviceInteractive()
+ && (flags & AudioManager.FLAG_SHOW_UI) != 0 && mShowVolumeDialog).orElse(
+ mShowVolumeDialog && (flags & AudioManager.FLAG_SHOW_UI) != 0);
}
boolean onVolumeChangedW(int stream, int flags) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
index a31fc3a..6cebb12 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
@@ -45,6 +45,7 @@
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.AutoTileManager;
+import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -58,6 +59,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.Optional;
+
@RunWith(AndroidTestingRunner.class)
@RunWithLooper
@SmallTest
@@ -100,7 +103,7 @@
mock(QSFactoryImpl.class), new Handler(), Looper.myLooper(),
mock(PluginManager.class), mock(TunerService.class),
() -> mock(AutoTileManager.class), mock(DumpController.class),
- mock(BroadcastDispatcher.class));
+ mock(BroadcastDispatcher.class), Optional.of(mock(StatusBar.class)));
qs.setHost(host);
qs.setListening(true);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
index 0247c2f..fad7cbd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSTileHostTest.java
@@ -48,6 +48,7 @@
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.phone.AutoTileManager;
+import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.tuner.TunerService;
@@ -62,6 +63,7 @@
import java.io.StringWriter;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import javax.inject.Provider;
@@ -88,6 +90,9 @@
private BroadcastDispatcher mBroadcastDispatcher;
@Mock
private QSTile.State mMockState;
+ @Mock
+ private StatusBar mStatusBar;
+
private Handler mHandler;
private TestableLooper mLooper;
private QSTileHost mQSTileHost;
@@ -99,7 +104,8 @@
mHandler = new Handler(mLooper.getLooper());
mQSTileHost = new TestQSTileHost(mContext, mIconController, mDefaultFactory, mHandler,
mLooper.getLooper(),
- mPluginManager, mTunerService, mAutoTiles, mDumpController, mBroadcastDispatcher);
+ mPluginManager, mTunerService, mAutoTiles, mDumpController, mBroadcastDispatcher,
+ mStatusBar);
setUpTileFactory();
Settings.Secure.putStringForUser(mContext.getContentResolver(), QSTileHost.TILES_SETTING,
"", ActivityManager.getCurrentUser());
@@ -172,9 +178,10 @@
QSFactoryImpl defaultFactory, Handler mainHandler, Looper bgLooper,
PluginManager pluginManager, TunerService tunerService,
Provider<AutoTileManager> autoTiles, DumpController dumpController,
- BroadcastDispatcher broadcastDispatcher) {
+ BroadcastDispatcher broadcastDispatcher, StatusBar statusBar) {
super(context, iconController, defaultFactory, mainHandler, bgLooper, pluginManager,
- tunerService, autoTiles, dumpController, broadcastDispatcher);
+ tunerService, autoTiles, dumpController, broadcastDispatcher,
+ Optional.of(statusBar));
}
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java
index 824c50d..2737b19 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileServicesTest.java
@@ -37,6 +37,7 @@
import com.android.systemui.qs.tileimpl.QSFactoryImpl;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.statusbar.phone.AutoTileManager;
+import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.tuner.TunerService;
@@ -51,6 +52,7 @@
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
+import java.util.Optional;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@@ -74,6 +76,8 @@
private AutoTileManager mAutoTileManager;
@Mock
private DumpController mDumpController;
+ @Mock
+ private StatusBar mStatusBar;
@Before
public void setUp() throws Exception {
@@ -89,7 +93,8 @@
mTunerService,
() -> mAutoTileManager,
mDumpController,
- mBroadcastDispatcher);
+ mBroadcastDispatcher,
+ Optional.of(mStatusBar));
mTileService = new TestTileServices(host, Looper.getMainLooper(), mBroadcastDispatcher);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
index c7877bb..bc616c5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationGutsManagerTest.java
@@ -121,10 +121,10 @@
mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager);
mDependency.injectMockDependency(NotificationLockscreenUserManager.class);
mHandler = Handler.createAsync(mTestableLooper.getLooper());
- mContext.putComponent(StatusBar.class, mStatusBar);
mHelper = new NotificationTestHelper(mContext, mDependency);
- mGutsManager = new NotificationGutsManager(mContext, mVisualStabilityManager);
+ mGutsManager = new NotificationGutsManager(mContext, mVisualStabilityManager,
+ () -> mStatusBar);
mGutsManager.setUpWithPresenter(mPresenter, mStackScroller,
mCheckSaveListener, mOnSettingsClickListener);
mGutsManager.setNotificationActivityStarter(mNotificationActivityStarter);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java
index 88ed80a..bc4e401 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java
@@ -60,7 +60,7 @@
public void setup() {
mSysuiContext.putComponent(CommandQueue.class, mock(CommandQueue.class));
StatusBar statusBar = mock(StatusBar.class);
- mSysuiContext.putComponent(StatusBar.class, statusBar);
+ mDependency.injectTestDependency(StatusBar.class, statusBar);
mSysuiContext.putComponent(TunerService.class, mock(TunerService.class));
mStatusBarStateController = mDependency
.injectMockDependency(StatusBarStateController.class);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
index b05172c..5af1e14 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java
@@ -60,8 +60,6 @@
import java.util.Collections;
import java.util.HashSet;
-import dagger.Lazy;
-
@SmallTest
@RunWith(AndroidTestingRunner.class)
public class DozeServiceHostTest extends SysuiTestCase {
@@ -71,7 +69,6 @@
@Mock private HeadsUpManagerPhone mHeadsUpManager;
@Mock private ScrimController mScrimController;
@Mock private DozeScrimController mDozeScrimController;
- @Mock private Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
@Mock private VisualStabilityManager mVisualStabilityManager;
@Mock private KeyguardViewMediator mKeyguardViewMediator;
@Mock private StatusBarStateControllerImpl mStatusBarStateController;
@@ -97,13 +94,12 @@
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
- when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController);
mDozeServiceHost = new DozeServiceHost(mDozeLog, mPowerManager, mWakefullnessLifecycle,
mStatusBarStateController, mDeviceProvisionedController, mHeadsUpManager,
- mBatteryController, mScrimController, mBiometricUnlockControllerLazy,
- mKeyguardViewMediator, mAssistManager, mDozeScrimController, mKeyguardUpdateMonitor,
- mVisualStabilityManager, mPulseExpansionHandler, mStatusBarWindowController,
- mNotificationWakeUpCoordinator);
+ mBatteryController, mScrimController, () -> mBiometricUnlockController,
+ mKeyguardViewMediator, () -> mAssistManager, mDozeScrimController,
+ mKeyguardUpdateMonitor, mVisualStabilityManager, mPulseExpansionHandler,
+ mStatusBarWindowController, mNotificationWakeUpCoordinator);
mDozeServiceHost.initialize(mStatusBar, mNotificationIconAreaController,
mStatusBarWindowViewController, mStatusBarWindow, mStatusBarKeyguardViewManager,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
index 9763675..4e5ec1d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
@@ -157,13 +157,10 @@
}
private void setupSysuiDependency() {
- mSysuiContext.putComponent(StatusBar.class, mock(StatusBar.class));
-
Display display = new Display(DisplayManagerGlobal.getInstance(), EXTERNAL_DISPLAY_ID,
new DisplayInfo(), DEFAULT_DISPLAY_ADJUSTMENTS);
mSysuiTestableContextExternal = (SysuiTestableContext) mSysuiContext.createDisplayContext(
display);
- mSysuiTestableContextExternal.putComponent(StatusBar.class, mock(StatusBar.class));
injectLeakCheckedDependencies(ALL_SUPPORTED_CLASSES);
WindowManager windowManager = mock(WindowManager.class);
@@ -255,7 +252,8 @@
mBroadcastDispatcher,
mCommandQueue,
mDivider,
- Optional.of(mRecents));
+ Optional.of(mRecents),
+ () -> mock(StatusBar.class));
}
private class HostCallbacksForExternalDisplay extends
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index 62fd0c5..b2eb7d4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -89,6 +89,7 @@
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
+import com.android.systemui.recents.ScreenPinningRequest;
import com.android.systemui.shared.plugins.PluginManager;
import com.android.systemui.stackdivider.Divider;
import com.android.systemui.statusbar.CommandQueue;
@@ -235,6 +236,7 @@
@Mock private LightsOutNotifController mLightsOutNotifController;
@Mock private ViewMediatorCallback mViewMediatorCallback;
@Mock private DismissCallbackRegistry mDismissCallbackRegistry;
+ @Mock private ScreenPinningRequest mScreenPinningRequest;
@Before
public void setup() throws Exception {
@@ -352,7 +354,7 @@
mVisualStabilityManager,
mDeviceProvisionedController,
mNavigationBarController,
- mAssistManager,
+ () -> mAssistManager,
mNotificationListener,
configurationController,
mStatusBarWindowController,
@@ -363,7 +365,7 @@
mLockscreenWallpaperLazy,
mBiometricUnlockControllerLazy,
mDozeServiceHost,
- mPowerManager,
+ mPowerManager, mScreenPinningRequest,
mDozeScrimController,
mCommandQueue,
mPluginManager,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java
index 2e945f2..fe71926 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/volume/VolumeDialogControllerImplTest.java
@@ -44,6 +44,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.Optional;
+
@RunWith(AndroidTestingRunner.class)
@SmallTest
public class VolumeDialogControllerImplTest extends SysuiTestCase {
@@ -125,9 +127,8 @@
static class TestableVolumeDialogControllerImpl extends VolumeDialogControllerImpl {
TestableVolumeDialogControllerImpl(Context context, C callback, StatusBar s,
BroadcastDispatcher broadcastDispatcher) {
- super(context, broadcastDispatcher);
+ super(context, broadcastDispatcher, s == null ? Optional.empty() : Optional.of(s));
mCallbacks = callback;
- mStatusBar = s;
}
}