Start using some dagger 2
Early days as we start migration, so lots of duplication between
Dependency and dagger2, but can be removed when migration is done.
Test: existing tests.
Change-Id: I00c3da6ebbd46a26e512d8a7aa1e2b828e08f33f
diff --git a/packages/SystemUI/src/com/android/systemui/Dependency.java b/packages/SystemUI/src/com/android/systemui/Dependency.java
index 327ffcd..4e5af15 100644
--- a/packages/SystemUI/src/com/android/systemui/Dependency.java
+++ b/packages/SystemUI/src/com/android/systemui/Dependency.java
@@ -14,20 +14,15 @@
package com.android.systemui;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Configuration;
-import android.hardware.SensorManager;
import android.hardware.SensorPrivacyManager;
import android.os.Handler;
-import android.os.HandlerThread;
import android.os.Looper;
-import android.os.Process;
-import android.os.ServiceManager;
-import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.view.IWindowManager;
-import android.view.WindowManagerGlobal;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.ColorDisplayController;
@@ -36,92 +31,86 @@
import com.android.internal.util.Preconditions;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.appops.AppOpsController;
-import com.android.systemui.appops.AppOpsControllerImpl;
import com.android.systemui.assist.AssistManager;
+import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.PluginDependencyProvider;
-import com.android.systemui.plugins.PluginInitializerImpl;
import com.android.systemui.plugins.VolumeDialogController;
import com.android.systemui.power.EnhancedEstimates;
-import com.android.systemui.power.EnhancedEstimatesImpl;
-import com.android.systemui.power.PowerNotificationWarnings;
import com.android.systemui.power.PowerUI;
import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.shared.plugins.PluginManager;
-import com.android.systemui.shared.plugins.PluginManagerImpl;
+import com.android.systemui.statusbar.AmbientPulseManager;
import com.android.systemui.statusbar.DisplayNavigationBarController;
+import com.android.systemui.statusbar.NotificationListener;
+import com.android.systemui.statusbar.NotificationLockscreenUserManager;
+import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
+import com.android.systemui.statusbar.NotificationViewHierarchyManager;
+import com.android.systemui.statusbar.SmartReplyController;
+import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.notification.NotificationData.KeyguardEnvironment;
-import com.android.systemui.statusbar.phone.ConfigurationControllerImpl;
-import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl;
-import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
+import com.android.systemui.statusbar.notification.NotificationEntryManager;
+import com.android.systemui.statusbar.notification.VisualStabilityManager;
+import com.android.systemui.statusbar.notification.logging.NotificationLogger;
+import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
+import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
+import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.statusbar.phone.LightBarController;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger;
import com.android.systemui.statusbar.phone.ManagedProfileController;
-import com.android.systemui.statusbar.phone.ManagedProfileControllerImpl;
+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.StatusBarIconControllerImpl;
-import com.android.systemui.statusbar.phone.StatusBarRemoteInputCallback;
import com.android.systemui.statusbar.phone.StatusBarWindowController;
import com.android.systemui.statusbar.policy.AccessibilityController;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.BatteryController;
-import com.android.systemui.statusbar.policy.BatteryControllerImpl;
import com.android.systemui.statusbar.policy.BluetoothController;
-import com.android.systemui.statusbar.policy.BluetoothControllerImpl;
import com.android.systemui.statusbar.policy.CastController;
-import com.android.systemui.statusbar.policy.CastControllerImpl;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DarkIconDispatcher;
import com.android.systemui.statusbar.policy.DataSaverController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
-import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl;
import com.android.systemui.statusbar.policy.ExtensionController;
-import com.android.systemui.statusbar.policy.ExtensionControllerImpl;
import com.android.systemui.statusbar.policy.FlashlightController;
-import com.android.systemui.statusbar.policy.FlashlightControllerImpl;
import com.android.systemui.statusbar.policy.HotspotController;
-import com.android.systemui.statusbar.policy.HotspotControllerImpl;
import com.android.systemui.statusbar.policy.IconLogger;
-import com.android.systemui.statusbar.policy.IconLoggerImpl;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
-import com.android.systemui.statusbar.policy.KeyguardMonitorImpl;
import com.android.systemui.statusbar.policy.LocationController;
-import com.android.systemui.statusbar.policy.LocationControllerImpl;
import com.android.systemui.statusbar.policy.NetworkController;
-import com.android.systemui.statusbar.policy.NetworkControllerImpl;
import com.android.systemui.statusbar.policy.NextAlarmController;
-import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
+import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler;
import com.android.systemui.statusbar.policy.RotationLockController;
-import com.android.systemui.statusbar.policy.RotationLockControllerImpl;
import com.android.systemui.statusbar.policy.SecurityController;
-import com.android.systemui.statusbar.policy.SecurityControllerImpl;
+import com.android.systemui.statusbar.policy.SmartReplyConstants;
import com.android.systemui.statusbar.policy.UserInfoController;
-import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
import com.android.systemui.tuner.TunablePadding.TunablePaddingService;
import com.android.systemui.tuner.TunerService;
-import com.android.systemui.tuner.TunerServiceImpl;
import com.android.systemui.util.AsyncSensorManager;
import com.android.systemui.util.leak.GarbageMonitor;
import com.android.systemui.util.leak.LeakDetector;
import com.android.systemui.util.leak.LeakReporter;
-import com.android.systemui.volume.VolumeDialogControllerImpl;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.function.Consumer;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import dagger.Lazy;
+import dagger.Subcomponent;
+
/**
* Class to handle ugly dependencies throughout sysui until we determine the
* long-term dependency injection solution.
@@ -143,235 +132,302 @@
/**
* Key for getting a background Looper for background work.
*/
- public static final DependencyKey<Looper> BG_LOOPER = new DependencyKey<>("background_looper");
+ public static final String BG_LOOPER_NAME = "background_looper";
/**
* Key for getting a background Handler for background work.
*/
- public static final DependencyKey<Handler> BG_HANDLER = new DependencyKey<>("background_handler");
+ public static final String BG_HANDLER_NAME = "background_handler";
/**
* Key for getting a Handler for receiving time tick broadcasts on.
*/
- public static final DependencyKey<Handler> TIME_TICK_HANDLER =
- new DependencyKey<>("time_tick_handler");
+ public static final String TIME_TICK_HANDLER_NAME = "time_tick_handler";
/**
* Generic handler on the main thread.
*/
- public static final DependencyKey<Handler> MAIN_HANDLER = new DependencyKey<>("main_handler");
+ public static final String MAIN_HANDLER_NAME = "main_handler";
/**
* An email address to send memory leak reports to by default.
*/
- public static final DependencyKey<String> LEAK_REPORT_EMAIL
- = new DependencyKey<>("leak_report_email");
+ public static final String LEAK_REPORT_EMAIL_NAME = "leak_report_email";
+
+ /**
+ * Key for getting a background Looper for background work.
+ */
+ public static final DependencyKey<Looper> BG_LOOPER = new DependencyKey<>(BG_LOOPER_NAME);
+ /**
+ * Key for getting a background Handler for background work.
+ */
+ public static final DependencyKey<Handler> BG_HANDLER = new DependencyKey<>(BG_HANDLER_NAME);
+ /**
+ * Key for getting a Handler for receiving time tick broadcasts on.
+ */
+ public static final DependencyKey<Handler> TIME_TICK_HANDLER =
+ new DependencyKey<>(TIME_TICK_HANDLER_NAME);
+ /**
+ * Generic handler on the main thread.
+ */
+ public static final DependencyKey<Handler> MAIN_HANDLER =
+ new DependencyKey<>(MAIN_HANDLER_NAME);
+
+ /**
+ * An email address to send memory leak reports to by default.
+ */
+ public static final DependencyKey<String> LEAK_REPORT_EMAIL =
+ new DependencyKey<>(LEAK_REPORT_EMAIL_NAME);
private final ArrayMap<Object, Object> mDependencies = new ArrayMap<>();
private final ArrayMap<Object, DependencyProvider> mProviders = new ArrayMap<>();
+ @Inject Lazy<ActivityStarter> mActivityStarter;
+ @Inject Lazy<ActivityStarterDelegate> mActivityStarterDelegate;
+ @Inject Lazy<AsyncSensorManager> mAsyncSensorManager;
+ @Inject Lazy<BluetoothController> mBluetoothController;
+ @Inject Lazy<LocationController> mLocationController;
+ @Inject Lazy<RotationLockController> mRotationLockController;
+ @Inject Lazy<NetworkController> mNetworkController;
+ @Inject Lazy<ZenModeController> mZenModeController;
+ @Inject Lazy<HotspotController> mHotspotController;
+ @Inject Lazy<CastController> mCastController;
+ @Inject Lazy<FlashlightController> mFlashlightController;
+ @Inject Lazy<UserSwitcherController> mUserSwitcherController;
+ @Inject Lazy<UserInfoController> mUserInfoController;
+ @Inject Lazy<KeyguardMonitor> mKeyguardMonitor;
+ @Inject Lazy<BatteryController> mBatteryController;
+ @Inject Lazy<ColorDisplayController> mColorDisplayController;
+ @Inject Lazy<ManagedProfileController> mManagedProfileController;
+ @Inject Lazy<NextAlarmController> mNextAlarmController;
+ @Inject Lazy<DataSaverController> mDataSaverController;
+ @Inject Lazy<AccessibilityController> mAccessibilityController;
+ @Inject Lazy<DeviceProvisionedController> mDeviceProvisionedController;
+ @Inject Lazy<PluginManager> mPluginManager;
+ @Inject Lazy<AssistManager> mAssistManager;
+ @Inject Lazy<SecurityController> mSecurityController;
+ @Inject Lazy<LeakDetector> mLeakDetector;
+ @Inject Lazy<LeakReporter> mLeakReporter;
+ @Inject Lazy<GarbageMonitor> mGarbageMonitor;
+ @Inject Lazy<IconLogger> mIconLogger;
+ @Inject Lazy<TunerService> mTunerService;
+ @Inject Lazy<StatusBarWindowController> mStatusBarWindowController;
+ @Inject Lazy<DarkIconDispatcher> mDarkIconDispatcher;
+ @Inject Lazy<ConfigurationController> mConfigurationController;
+ @Inject Lazy<StatusBarIconController> mStatusBarIconController;
+ @Inject Lazy<ScreenLifecycle> mScreenLifecycle;
+ @Inject Lazy<WakefulnessLifecycle> mWakefulnessLifecycle;
+ @Inject Lazy<FragmentService> mFragmentService;
+ @Inject Lazy<ExtensionController> mExtensionController;
+ @Inject Lazy<PluginDependencyProvider> mPluginDependencyProvider;
+ @Inject Lazy<LocalBluetoothManager> mLocalBluetoothManager;
+ @Inject Lazy<VolumeDialogController> mVolumeDialogController;
+ @Inject Lazy<MetricsLogger> mMetricsLogger;
+ @Inject Lazy<AccessibilityManagerWrapper> mAccessibilityManagerWrapper;
+ @Inject Lazy<SysuiColorExtractor> mSysuiColorExtractor;
+ @Inject Lazy<TunablePaddingService> mTunablePaddingService;
+ @Inject Lazy<ForegroundServiceController> mForegroundServiceController;
+ @Inject Lazy<UiOffloadThread> mUiOffloadThread;
+ @Inject Lazy<PowerUI.WarningsUI> mWarningsUI;
+ @Inject Lazy<LightBarController> mLightBarController;
+ @Inject Lazy<IWindowManager> mIWindowManager;
+ @Inject Lazy<OverviewProxyService> mOverviewProxyService;
+ @Inject Lazy<EnhancedEstimates> mEnhancedEstimates;
+ @Inject Lazy<VibratorHelper> mVibratorHelper;
+ @Inject Lazy<IStatusBarService> mIStatusBarService;
+ @Inject Lazy<DisplayMetrics> mDisplayMetrics;
+ @Inject Lazy<LockscreenGestureLogger> mLockscreenGestureLogger;
+ @Inject Lazy<KeyguardEnvironment> mKeyguardEnvironment;
+ @Inject Lazy<ShadeController> mShadeController;
+ @Inject Lazy<NotificationRemoteInputManager.Callback> mNotificationRemoteInputManagerCallback;
+ @Inject Lazy<InitController> mInitController;
+ @Inject Lazy<AppOpsController> mAppOpsController;
+ @Inject Lazy<DisplayNavigationBarController> mDisplayNavigationBarController;
+ @Inject Lazy<StatusBarStateController> mStatusBarStateController;
+ @Inject Lazy<NotificationLockscreenUserManager> mNotificationLockscreenUserManager;
+ @Inject Lazy<NotificationGroupAlertTransferHelper> mNotificationGroupAlertTransferHelper;
+ @Inject Lazy<NotificationGroupManager> mNotificationGroupManager;
+ @Inject Lazy<VisualStabilityManager> mVisualStabilityManager;
+ @Inject Lazy<NotificationGutsManager> mNotificationGutsManager;
+ @Inject Lazy<NotificationMediaManager> mNotificationMediaManager;
+ @Inject Lazy<AmbientPulseManager> mAmbientPulseManager;
+ @Inject Lazy<NotificationBlockingHelperManager> mNotificationBlockingHelperManager;
+ @Inject Lazy<NotificationRemoteInputManager> mNotificationRemoteInputManager;
+ @Inject Lazy<SmartReplyConstants> mSmartReplyConstants;
+ @Inject Lazy<NotificationListener> mNotificationListener;
+ @Inject Lazy<NotificationLogger> mNotificationLogger;
+ @Inject Lazy<NotificationViewHierarchyManager> mNotificationViewHierarchyManager;
+ @Inject Lazy<KeyguardDismissUtil> mKeyguardDismissUtil;
+ @Inject Lazy<SmartReplyController> mSmartReplyController;
+ @Inject Lazy<RemoteInputQuickSettingsDisabler> mRemoteInputQuickSettingsDisabler;
+ @Inject Lazy<BubbleController> mBubbleController;
+ @Inject Lazy<NotificationEntryManager> mNotificationEntryManager;
+ @Inject Lazy<SensorPrivacyManager> mSensorPrivacyManager;
+ @Inject @Named(BG_LOOPER_NAME) Lazy<Looper> mBgLooper;
+ @Inject @Named(BG_HANDLER_NAME) Lazy<Handler> mBgHandler;
+ @Inject @Named(MAIN_HANDLER_NAME) Lazy<Handler> mMainHandler;
+ @Inject @Named(TIME_TICK_HANDLER_NAME) Lazy<Handler> mTimeTickHandler;
+ @Nullable
+ @Inject @Named(LEAK_REPORT_EMAIL_NAME) Lazy<String> mLeakReportEmail;
+
+ @Inject
+ public Dependency() {
+ }
+
@Override
public void start() {
// TODO: Think about ways to push these creation rules out of Dependency to cut down
// on imports.
- mProviders.put(TIME_TICK_HANDLER, () -> {
- HandlerThread thread = new HandlerThread("TimeTick");
- thread.start();
- return new Handler(thread.getLooper());
- });
- mProviders.put(BG_LOOPER, () -> {
- HandlerThread thread = new HandlerThread("SysUiBg",
- Process.THREAD_PRIORITY_BACKGROUND);
- thread.start();
- return thread.getLooper();
- });
- mProviders.put(BG_HANDLER, () -> new Handler(getDependency(BG_LOOPER)));
- mProviders.put(MAIN_HANDLER, () -> new Handler(Looper.getMainLooper()));
- mProviders.put(ActivityStarter.class, () -> new ActivityStarterDelegate());
- mProviders.put(ActivityStarterDelegate.class, () ->
- getDependency(ActivityStarter.class));
+ mProviders.put(TIME_TICK_HANDLER, mTimeTickHandler::get);
+ mProviders.put(BG_LOOPER, mBgLooper::get);
+ mProviders.put(BG_HANDLER, mBgHandler::get);
+ mProviders.put(MAIN_HANDLER, mMainHandler::get);
+ mProviders.put(ActivityStarter.class, mActivityStarter::get);
+ mProviders.put(ActivityStarterDelegate.class, mActivityStarterDelegate::get);
- mProviders.put(AsyncSensorManager.class, () ->
- new AsyncSensorManager(mContext.getSystemService(SensorManager.class),
- getDependency(PluginManager.class)));
+ mProviders.put(AsyncSensorManager.class, mAsyncSensorManager::get);
- mProviders.put(SensorPrivacyManager.class, () ->
- mContext.getSystemService(SensorPrivacyManager.class));
+ mProviders.put(BluetoothController.class, mBluetoothController::get);
+ mProviders.put(SensorPrivacyManager.class, mSensorPrivacyManager::get);
- mProviders.put(BluetoothController.class, () ->
- new BluetoothControllerImpl(mContext, getDependency(BG_LOOPER)));
+ mProviders.put(LocationController.class, mLocationController::get);
- mProviders.put(LocationController.class, () ->
- new LocationControllerImpl(mContext, getDependency(BG_LOOPER)));
+ mProviders.put(RotationLockController.class, mRotationLockController::get);
- mProviders.put(RotationLockController.class, () ->
- new RotationLockControllerImpl(mContext));
+ mProviders.put(NetworkController.class, mNetworkController::get);
- mProviders.put(NetworkController.class, () ->
- new NetworkControllerImpl(mContext, getDependency(BG_LOOPER),
- getDependency(DeviceProvisionedController.class)));
+ mProviders.put(ZenModeController.class, mZenModeController::get);
- mProviders.put(ZenModeController.class, () ->
- new ZenModeControllerImpl(mContext, getDependency(MAIN_HANDLER)));
+ mProviders.put(HotspotController.class, mHotspotController::get);
- mProviders.put(HotspotController.class, () ->
- new HotspotControllerImpl(mContext));
+ mProviders.put(CastController.class, mCastController::get);
- mProviders.put(CastController.class, () ->
- new CastControllerImpl(mContext));
+ mProviders.put(FlashlightController.class, mFlashlightController::get);
- mProviders.put(FlashlightController.class, () ->
- new FlashlightControllerImpl(mContext));
+ mProviders.put(KeyguardMonitor.class, mKeyguardMonitor::get);
- mProviders.put(KeyguardMonitor.class, () ->
- new KeyguardMonitorImpl(mContext));
+ mProviders.put(UserSwitcherController.class, mUserSwitcherController::get);
- mProviders.put(UserSwitcherController.class, () ->
- new UserSwitcherController(mContext, getDependency(KeyguardMonitor.class),
- getDependency(MAIN_HANDLER), getDependency(ActivityStarter.class)));
+ mProviders.put(UserInfoController.class, mUserInfoController::get);
- mProviders.put(UserInfoController.class, () ->
- new UserInfoControllerImpl(mContext));
+ mProviders.put(BatteryController.class, mBatteryController::get);
- mProviders.put(BatteryController.class, () ->
- new BatteryControllerImpl(mContext));
+ mProviders.put(ColorDisplayController.class, mColorDisplayController::get);
- mProviders.put(ColorDisplayController.class, () ->
- new ColorDisplayController(mContext));
+ mProviders.put(ManagedProfileController.class, mManagedProfileController::get);
- mProviders.put(ManagedProfileController.class, () ->
- new ManagedProfileControllerImpl(mContext));
+ mProviders.put(NextAlarmController.class, mNextAlarmController::get);
- mProviders.put(NextAlarmController.class, () ->
- new NextAlarmControllerImpl(mContext));
+ mProviders.put(DataSaverController.class, mDataSaverController::get);
- mProviders.put(DataSaverController.class, () ->
- get(NetworkController.class).getDataSaverController());
+ mProviders.put(AccessibilityController.class, mAccessibilityController::get);
- mProviders.put(AccessibilityController.class, () ->
- new AccessibilityController(mContext));
+ mProviders.put(DeviceProvisionedController.class, mDeviceProvisionedController::get);
- mProviders.put(DeviceProvisionedController.class, () ->
- new DeviceProvisionedControllerImpl(mContext));
+ mProviders.put(PluginManager.class, mPluginManager::get);
- mProviders.put(PluginManager.class, () ->
- new PluginManagerImpl(mContext, new PluginInitializerImpl()));
+ mProviders.put(AssistManager.class, mAssistManager::get);
- mProviders.put(AssistManager.class, () ->
- new AssistManager(getDependency(DeviceProvisionedController.class), mContext));
+ mProviders.put(SecurityController.class, mSecurityController::get);
- mProviders.put(SecurityController.class, () ->
- new SecurityControllerImpl(mContext));
+ mProviders.put(LeakDetector.class, mLeakDetector::get);
- mProviders.put(LeakDetector.class, LeakDetector::create);
+ mProviders.put(LEAK_REPORT_EMAIL, mLeakReportEmail::get);
- mProviders.put(LEAK_REPORT_EMAIL, () -> null);
+ mProviders.put(LeakReporter.class, mLeakReporter::get);
- mProviders.put(LeakReporter.class, () -> new LeakReporter(
- mContext,
- getDependency(LeakDetector.class),
- getDependency(LEAK_REPORT_EMAIL)));
+ mProviders.put(GarbageMonitor.class, mGarbageMonitor::get);
- mProviders.put(
- GarbageMonitor.class,
- () ->
- new GarbageMonitor(
- mContext,
- getDependency(BG_LOOPER),
- getDependency(LeakDetector.class),
- getDependency(LeakReporter.class)));
+ mProviders.put(TunerService.class, mTunerService::get);
- mProviders.put(TunerService.class, () ->
- new TunerServiceImpl(mContext));
+ mProviders.put(StatusBarWindowController.class, mStatusBarWindowController::get);
- mProviders.put(StatusBarWindowController.class, () ->
- new StatusBarWindowController(mContext));
+ mProviders.put(DarkIconDispatcher.class, mDarkIconDispatcher::get);
- mProviders.put(DarkIconDispatcher.class, () ->
- new DarkIconDispatcherImpl(mContext));
+ mProviders.put(ConfigurationController.class, mConfigurationController::get);
- mProviders.put(ConfigurationController.class, () ->
- new ConfigurationControllerImpl(mContext));
+ mProviders.put(StatusBarIconController.class, mStatusBarIconController::get);
- mProviders.put(StatusBarIconController.class, () ->
- new StatusBarIconControllerImpl(mContext));
+ mProviders.put(ScreenLifecycle.class, mScreenLifecycle::get);
- mProviders.put(ScreenLifecycle.class, () ->
- new ScreenLifecycle());
+ mProviders.put(WakefulnessLifecycle.class, mWakefulnessLifecycle::get);
- mProviders.put(WakefulnessLifecycle.class, () ->
- new WakefulnessLifecycle());
+ mProviders.put(FragmentService.class, mFragmentService::get);
- mProviders.put(FragmentService.class, () ->
- new FragmentService());
+ mProviders.put(ExtensionController.class, mExtensionController::get);
- mProviders.put(ExtensionController.class, () ->
- new ExtensionControllerImpl(mContext));
+ mProviders.put(PluginDependencyProvider.class, mPluginDependencyProvider::get);
- mProviders.put(PluginDependencyProvider.class, () ->
- new PluginDependencyProvider(get(PluginManager.class)));
+ mProviders.put(LocalBluetoothManager.class, mLocalBluetoothManager::get);
- mProviders.put(LocalBluetoothManager.class, () ->
- LocalBluetoothManager.create(mContext, getDependency(BG_HANDLER),
- UserHandle.ALL));
+ mProviders.put(VolumeDialogController.class, mVolumeDialogController::get);
- mProviders.put(VolumeDialogController.class, () ->
- new VolumeDialogControllerImpl(mContext));
+ mProviders.put(MetricsLogger.class, mMetricsLogger::get);
- mProviders.put(MetricsLogger.class, () -> new MetricsLogger());
+ mProviders.put(AccessibilityManagerWrapper.class, mAccessibilityManagerWrapper::get);
- mProviders.put(AccessibilityManagerWrapper.class,
- () -> new AccessibilityManagerWrapper(mContext));
+ mProviders.put(SysuiColorExtractor.class, mSysuiColorExtractor::get);
- // Creating a new instance will trigger color extraction.
- // Thankfully this only happens once - during boot - and WallpaperManagerService
- // loads colors from cache.
- mProviders.put(SysuiColorExtractor.class, () -> new SysuiColorExtractor(mContext));
+ mProviders.put(TunablePaddingService.class, mTunablePaddingService::get);
- mProviders.put(TunablePaddingService.class, () -> new TunablePaddingService());
+ mProviders.put(ForegroundServiceController.class, mForegroundServiceController::get);
- mProviders.put(ForegroundServiceController.class,
- () -> new ForegroundServiceControllerImpl(mContext));
+ mProviders.put(UiOffloadThread.class, mUiOffloadThread::get);
- mProviders.put(UiOffloadThread.class, UiOffloadThread::new);
+ mProviders.put(PowerUI.WarningsUI.class, mWarningsUI::get);
- mProviders.put(PowerUI.WarningsUI.class, () -> new PowerNotificationWarnings(mContext));
+ mProviders.put(IconLogger.class, mIconLogger::get);
- mProviders.put(IconLogger.class, () -> new IconLoggerImpl(mContext,
- getDependency(BG_LOOPER), getDependency(MetricsLogger.class)));
+ mProviders.put(LightBarController.class, mLightBarController::get);
- mProviders.put(LightBarController.class, () -> new LightBarController(mContext));
+ mProviders.put(IWindowManager.class, mIWindowManager::get);
- mProviders.put(IWindowManager.class, () -> WindowManagerGlobal.getWindowManagerService());
+ mProviders.put(OverviewProxyService.class, mOverviewProxyService::get);
- mProviders.put(OverviewProxyService.class, () -> new OverviewProxyService(mContext));
+ mProviders.put(EnhancedEstimates.class, mEnhancedEstimates::get);
- mProviders.put(EnhancedEstimates.class, () -> new EnhancedEstimatesImpl());
+ mProviders.put(VibratorHelper.class, mVibratorHelper::get);
- mProviders.put(VibratorHelper.class, () -> new VibratorHelper(mContext));
+ mProviders.put(IStatusBarService.class, mIStatusBarService::get);
- mProviders.put(IStatusBarService.class, () -> IStatusBarService.Stub.asInterface(
- ServiceManager.getService(Context.STATUS_BAR_SERVICE)));
+ mProviders.put(DisplayMetrics.class, mDisplayMetrics::get);
- // Single instance of DisplayMetrics, gets updated by StatusBar, but can be used
- // anywhere it is needed.
- mProviders.put(DisplayMetrics.class, () -> new DisplayMetrics());
+ mProviders.put(LockscreenGestureLogger.class, mLockscreenGestureLogger::get);
- mProviders.put(LockscreenGestureLogger.class, () -> new LockscreenGestureLogger());
-
- mProviders.put(KeyguardEnvironment.class, () -> new KeyguardEnvironmentImpl());
- mProviders.put(ShadeController.class, () ->
- SysUiServiceProvider.getComponent(mContext, StatusBar.class));
+ mProviders.put(KeyguardEnvironment.class, mKeyguardEnvironment::get);
+ mProviders.put(ShadeController.class, mShadeController::get);
mProviders.put(NotificationRemoteInputManager.Callback.class,
- () -> new StatusBarRemoteInputCallback(mContext));
+ mNotificationRemoteInputManagerCallback::get);
- mProviders.put(InitController.class, InitController::new);
+ mProviders.put(InitController.class, mInitController::get);
- mProviders.put(AppOpsController.class, () ->
- new AppOpsControllerImpl(mContext, getDependency(BG_LOOPER)));
+ mProviders.put(AppOpsController.class, mAppOpsController::get);
- mProviders.put(DisplayNavigationBarController.class, () ->
- new DisplayNavigationBarController(mContext, getDependency(MAIN_HANDLER)));
+ mProviders.put(DisplayNavigationBarController.class,
+ mDisplayNavigationBarController::get);
- // Put all dependencies above here so the factory can override them if it wants.
- SystemUIFactory.getInstance().injectDependencies(mProviders, mContext);
+ mProviders.put(StatusBarStateController.class, mStatusBarStateController::get);
+ mProviders.put(NotificationLockscreenUserManager.class,
+ mNotificationLockscreenUserManager::get);
+ mProviders.put(VisualStabilityManager.class, mVisualStabilityManager::get);
+ mProviders.put(NotificationGroupManager.class, mNotificationGroupManager::get);
+ mProviders.put(NotificationGroupAlertTransferHelper.class,
+ mNotificationGroupAlertTransferHelper::get);
+ mProviders.put(NotificationMediaManager.class, mNotificationMediaManager::get);
+ mProviders.put(NotificationGutsManager.class, mNotificationGutsManager::get);
+ mProviders.put(AmbientPulseManager.class, mAmbientPulseManager::get);
+ mProviders.put(NotificationBlockingHelperManager.class,
+ mNotificationBlockingHelperManager::get);
+ mProviders.put(NotificationRemoteInputManager.class,
+ mNotificationRemoteInputManager::get);
+ mProviders.put(SmartReplyConstants.class, mSmartReplyConstants::get);
+ mProviders.put(NotificationListener.class, mNotificationListener::get);
+ mProviders.put(NotificationLogger.class, mNotificationLogger::get);
+ mProviders.put(NotificationViewHierarchyManager.class,
+ mNotificationViewHierarchyManager::get);
+ mProviders.put(KeyguardDismissUtil.class, mKeyguardDismissUtil::get);
+ mProviders.put(SmartReplyController.class, mSmartReplyController::get);
+ mProviders.put(RemoteInputQuickSettingsDisabler.class,
+ mRemoteInputQuickSettingsDisabler::get);
+ mProviders.put(BubbleController.class, mBubbleController::get);
+ mProviders.put(NotificationEntryManager.class, mNotificationEntryManager::get);
sDependency = this;
}
@@ -484,4 +540,20 @@
return mDisplayName;
}
}
+
+ @Subcomponent
+ public interface DependencyInjector {
+ void createSystemUI(Dependency dependency);
+ }
+
+ public static class DependencyCreator implements Injector {
+ @Override
+ public SystemUI apply(Context context) {
+ Dependency dependency = new Dependency();
+ SystemUIFactory.getInstance().getRootComponent()
+ .createDependency()
+ .createSystemUI(dependency);
+ return dependency;
+ }
+ }
}