Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui; |
| 16 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 17 | import android.annotation.Nullable; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 18 | import android.content.Context; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 19 | import android.content.res.Configuration; |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 20 | import android.hardware.SensorPrivacyManager; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 21 | import android.os.Handler; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 22 | import android.os.Looper; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 23 | import android.util.ArrayMap; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 24 | import android.util.DisplayMetrics; |
Jason Monk | 2044e6e | 2017-10-13 10:34:40 -0400 | [diff] [blame] | 25 | import android.view.IWindowManager; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 26 | |
| 27 | import com.android.internal.annotations.VisibleForTesting; |
Christine Franks | 5397f03 | 2017-11-01 18:35:16 -0700 | [diff] [blame] | 28 | import com.android.internal.app.ColorDisplayController; |
Jason Monk | 8c09ac7 | 2017-03-16 11:53:40 -0400 | [diff] [blame] | 29 | import com.android.internal.logging.MetricsLogger; |
Kenny Guy | a0f6de8 | 2018-04-06 16:20:16 +0100 | [diff] [blame] | 30 | import com.android.internal.statusbar.IStatusBarService; |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 31 | import com.android.internal.util.Preconditions; |
Jason Monk | 6a73e63 | 2017-03-17 11:08:30 -0400 | [diff] [blame] | 32 | import com.android.settingslib.bluetooth.LocalBluetoothManager; |
Fabian Kozynski | 1f32cf0 | 2018-10-23 12:23:31 -0400 | [diff] [blame] | 33 | import com.android.systemui.appops.AppOpsController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 34 | import com.android.systemui.assist.AssistManager; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 35 | import com.android.systemui.bubbles.BubbleController; |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 36 | import com.android.systemui.colorextraction.SysuiColorExtractor; |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 37 | import com.android.systemui.fragments.FragmentService; |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 38 | import com.android.systemui.keyguard.ScreenLifecycle; |
| 39 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
Jason Monk | ec34da8 | 2017-02-24 15:57:05 -0500 | [diff] [blame] | 40 | import com.android.systemui.plugins.ActivityStarter; |
| 41 | import com.android.systemui.plugins.PluginDependencyProvider; |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 42 | import com.android.systemui.plugins.VolumeDialogController; |
Salvador Martinez | f9e4750 | 2018-01-04 13:45:48 -0800 | [diff] [blame] | 43 | import com.android.systemui.power.EnhancedEstimates; |
Jason Monk | d819c31 | 2017-08-11 12:53:36 -0400 | [diff] [blame] | 44 | import com.android.systemui.power.PowerUI; |
Charles Chen | 61325fb | 2018-11-07 20:04:17 +0800 | [diff] [blame] | 45 | import com.android.systemui.recents.OverviewProxyService; |
| 46 | import com.android.systemui.shared.plugins.PluginManager; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 47 | import com.android.systemui.statusbar.AmbientPulseManager; |
Charles Chen | 61325fb | 2018-11-07 20:04:17 +0800 | [diff] [blame] | 48 | import com.android.systemui.statusbar.DisplayNavigationBarController; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 49 | import com.android.systemui.statusbar.NotificationListener; |
| 50 | import com.android.systemui.statusbar.NotificationLockscreenUserManager; |
| 51 | import com.android.systemui.statusbar.NotificationMediaManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 52 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 53 | import com.android.systemui.statusbar.NotificationViewHierarchyManager; |
| 54 | import com.android.systemui.statusbar.SmartReplyController; |
| 55 | import com.android.systemui.statusbar.StatusBarStateController; |
Matthew Ng | e2b4d79 | 2018-03-09 13:42:18 -0800 | [diff] [blame] | 56 | import com.android.systemui.statusbar.VibratorHelper; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 57 | import com.android.systemui.statusbar.notification.NotificationData.KeyguardEnvironment; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 58 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 59 | import com.android.systemui.statusbar.notification.NotificationFilter; |
| 60 | import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider; |
Gus Prevas | 8ba88a8 | 2018-12-18 11:13:44 -0500 | [diff] [blame] | 61 | import com.android.systemui.statusbar.notification.NotificationRowBinder; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 62 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
| 63 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
| 64 | import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; |
| 65 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
| 66 | import com.android.systemui.statusbar.phone.KeyguardDismissUtil; |
Jason Monk | 73112d3 | 2017-09-06 16:53:53 -0400 | [diff] [blame] | 67 | import com.android.systemui.statusbar.phone.LightBarController; |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 68 | import com.android.systemui.statusbar.phone.LockscreenGestureLogger; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 69 | import com.android.systemui.statusbar.phone.ManagedProfileController; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 70 | import com.android.systemui.statusbar.phone.NotificationGroupAlertTransferHelper; |
| 71 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 72 | import com.android.systemui.statusbar.phone.ShadeController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 73 | import com.android.systemui.statusbar.phone.StatusBarIconController; |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 74 | import com.android.systemui.statusbar.phone.StatusBarWindowController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 75 | import com.android.systemui.statusbar.policy.AccessibilityController; |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 76 | import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 77 | import com.android.systemui.statusbar.policy.BatteryController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 78 | import com.android.systemui.statusbar.policy.BluetoothController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 79 | import com.android.systemui.statusbar.policy.CastController; |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 80 | import com.android.systemui.statusbar.policy.ConfigurationController; |
| 81 | import com.android.systemui.statusbar.policy.DarkIconDispatcher; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 82 | import com.android.systemui.statusbar.policy.DataSaverController; |
| 83 | import com.android.systemui.statusbar.policy.DeviceProvisionedController; |
Jason Monk | 1d9632d | 2017-02-09 13:20:04 -0800 | [diff] [blame] | 84 | import com.android.systemui.statusbar.policy.ExtensionController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 85 | import com.android.systemui.statusbar.policy.FlashlightController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 86 | import com.android.systemui.statusbar.policy.HotspotController; |
Jason Monk | f8c2f7b | 2017-09-06 09:22:29 -0400 | [diff] [blame] | 87 | import com.android.systemui.statusbar.policy.IconLogger; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 88 | import com.android.systemui.statusbar.policy.KeyguardMonitor; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 89 | import com.android.systemui.statusbar.policy.LocationController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 90 | import com.android.systemui.statusbar.policy.NetworkController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 91 | import com.android.systemui.statusbar.policy.NextAlarmController; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 92 | import com.android.systemui.statusbar.policy.RemoteInputQuickSettingsDisabler; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 93 | import com.android.systemui.statusbar.policy.RotationLockController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 94 | import com.android.systemui.statusbar.policy.SecurityController; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 95 | import com.android.systemui.statusbar.policy.SmartReplyConstants; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 96 | import com.android.systemui.statusbar.policy.UserInfoController; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 97 | import com.android.systemui.statusbar.policy.UserSwitcherController; |
| 98 | import com.android.systemui.statusbar.policy.ZenModeController; |
Jason Monk | d4afe15 | 2017-05-01 15:37:43 -0400 | [diff] [blame] | 99 | import com.android.systemui.tuner.TunablePadding.TunablePaddingService; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 100 | import com.android.systemui.tuner.TunerService; |
Adrian Roos | 7a8ae8a | 2017-08-02 16:26:50 +0200 | [diff] [blame] | 101 | import com.android.systemui.util.AsyncSensorManager; |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 102 | import com.android.systemui.util.leak.GarbageMonitor; |
Adrian Roos | e1e0b48 | 2017-02-02 16:00:59 -0800 | [diff] [blame] | 103 | import com.android.systemui.util.leak.LeakDetector; |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 104 | import com.android.systemui.util.leak.LeakReporter; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 105 | |
| 106 | import java.io.FileDescriptor; |
| 107 | import java.io.PrintWriter; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 108 | import java.util.HashMap; |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 109 | import java.util.function.Consumer; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 110 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 111 | import javax.inject.Inject; |
| 112 | import javax.inject.Named; |
| 113 | |
| 114 | import dagger.Lazy; |
| 115 | import dagger.Subcomponent; |
| 116 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 117 | /** |
| 118 | * Class to handle ugly dependencies throughout sysui until we determine the |
| 119 | * long-term dependency injection solution. |
| 120 | * |
| 121 | * Classes added here should be things that are expected to live the lifetime of sysui, |
| 122 | * and are generally applicable to many parts of sysui. They will be lazily |
| 123 | * initialized to ensure they aren't created on form factors that don't need them |
| 124 | * (e.g. HotspotController on TV). Despite being lazily initialized, it is expected |
| 125 | * that all dependencies will be gotten during sysui startup, and not during runtime |
| 126 | * to avoid jank. |
| 127 | * |
| 128 | * All classes used here are expected to manage their own lifecycle, meaning if |
| 129 | * they have no clients they should not have any registered resources like bound |
| 130 | * services, registered receivers, etc. |
| 131 | */ |
| 132 | public class Dependency extends SystemUI { |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 133 | private static final String TAG = "Dependency"; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 134 | |
| 135 | /** |
| 136 | * Key for getting a background Looper for background work. |
| 137 | */ |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 138 | public static final String BG_LOOPER_NAME = "background_looper"; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 139 | /** |
Amin Shaikh | 947f76d | 2018-08-27 15:55:57 -0400 | [diff] [blame] | 140 | * Key for getting a background Handler for background work. |
| 141 | */ |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 142 | public static final String BG_HANDLER_NAME = "background_handler"; |
Amin Shaikh | 947f76d | 2018-08-27 15:55:57 -0400 | [diff] [blame] | 143 | /** |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 144 | * Key for getting a Handler for receiving time tick broadcasts on. |
| 145 | */ |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 146 | public static final String TIME_TICK_HANDLER_NAME = "time_tick_handler"; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 147 | /** |
| 148 | * Generic handler on the main thread. |
| 149 | */ |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 150 | public static final String MAIN_HANDLER_NAME = "main_handler"; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 151 | |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 152 | /** |
| 153 | * An email address to send memory leak reports to by default. |
| 154 | */ |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 155 | public static final String LEAK_REPORT_EMAIL_NAME = "leak_report_email"; |
| 156 | |
| 157 | /** |
| 158 | * Key for getting a background Looper for background work. |
| 159 | */ |
| 160 | public static final DependencyKey<Looper> BG_LOOPER = new DependencyKey<>(BG_LOOPER_NAME); |
| 161 | /** |
| 162 | * Key for getting a background Handler for background work. |
| 163 | */ |
| 164 | public static final DependencyKey<Handler> BG_HANDLER = new DependencyKey<>(BG_HANDLER_NAME); |
| 165 | /** |
| 166 | * Key for getting a Handler for receiving time tick broadcasts on. |
| 167 | */ |
| 168 | public static final DependencyKey<Handler> TIME_TICK_HANDLER = |
| 169 | new DependencyKey<>(TIME_TICK_HANDLER_NAME); |
| 170 | /** |
| 171 | * Generic handler on the main thread. |
| 172 | */ |
| 173 | public static final DependencyKey<Handler> MAIN_HANDLER = |
| 174 | new DependencyKey<>(MAIN_HANDLER_NAME); |
| 175 | |
| 176 | /** |
| 177 | * An email address to send memory leak reports to by default. |
| 178 | */ |
| 179 | public static final DependencyKey<String> LEAK_REPORT_EMAIL = |
| 180 | new DependencyKey<>(LEAK_REPORT_EMAIL_NAME); |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 181 | |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 182 | private final ArrayMap<Object, Object> mDependencies = new ArrayMap<>(); |
| 183 | private final ArrayMap<Object, DependencyProvider> mProviders = new ArrayMap<>(); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 184 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 185 | @Inject Lazy<ActivityStarter> mActivityStarter; |
| 186 | @Inject Lazy<ActivityStarterDelegate> mActivityStarterDelegate; |
| 187 | @Inject Lazy<AsyncSensorManager> mAsyncSensorManager; |
| 188 | @Inject Lazy<BluetoothController> mBluetoothController; |
| 189 | @Inject Lazy<LocationController> mLocationController; |
| 190 | @Inject Lazy<RotationLockController> mRotationLockController; |
| 191 | @Inject Lazy<NetworkController> mNetworkController; |
| 192 | @Inject Lazy<ZenModeController> mZenModeController; |
| 193 | @Inject Lazy<HotspotController> mHotspotController; |
| 194 | @Inject Lazy<CastController> mCastController; |
| 195 | @Inject Lazy<FlashlightController> mFlashlightController; |
| 196 | @Inject Lazy<UserSwitcherController> mUserSwitcherController; |
| 197 | @Inject Lazy<UserInfoController> mUserInfoController; |
| 198 | @Inject Lazy<KeyguardMonitor> mKeyguardMonitor; |
| 199 | @Inject Lazy<BatteryController> mBatteryController; |
| 200 | @Inject Lazy<ColorDisplayController> mColorDisplayController; |
| 201 | @Inject Lazy<ManagedProfileController> mManagedProfileController; |
| 202 | @Inject Lazy<NextAlarmController> mNextAlarmController; |
| 203 | @Inject Lazy<DataSaverController> mDataSaverController; |
| 204 | @Inject Lazy<AccessibilityController> mAccessibilityController; |
| 205 | @Inject Lazy<DeviceProvisionedController> mDeviceProvisionedController; |
| 206 | @Inject Lazy<PluginManager> mPluginManager; |
| 207 | @Inject Lazy<AssistManager> mAssistManager; |
| 208 | @Inject Lazy<SecurityController> mSecurityController; |
| 209 | @Inject Lazy<LeakDetector> mLeakDetector; |
| 210 | @Inject Lazy<LeakReporter> mLeakReporter; |
| 211 | @Inject Lazy<GarbageMonitor> mGarbageMonitor; |
| 212 | @Inject Lazy<IconLogger> mIconLogger; |
| 213 | @Inject Lazy<TunerService> mTunerService; |
| 214 | @Inject Lazy<StatusBarWindowController> mStatusBarWindowController; |
| 215 | @Inject Lazy<DarkIconDispatcher> mDarkIconDispatcher; |
| 216 | @Inject Lazy<ConfigurationController> mConfigurationController; |
| 217 | @Inject Lazy<StatusBarIconController> mStatusBarIconController; |
| 218 | @Inject Lazy<ScreenLifecycle> mScreenLifecycle; |
| 219 | @Inject Lazy<WakefulnessLifecycle> mWakefulnessLifecycle; |
| 220 | @Inject Lazy<FragmentService> mFragmentService; |
| 221 | @Inject Lazy<ExtensionController> mExtensionController; |
| 222 | @Inject Lazy<PluginDependencyProvider> mPluginDependencyProvider; |
Brad Stenning | 32cedc1 | 2018-12-20 11:25:06 -0800 | [diff] [blame] | 223 | @Nullable |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 224 | @Inject Lazy<LocalBluetoothManager> mLocalBluetoothManager; |
| 225 | @Inject Lazy<VolumeDialogController> mVolumeDialogController; |
| 226 | @Inject Lazy<MetricsLogger> mMetricsLogger; |
| 227 | @Inject Lazy<AccessibilityManagerWrapper> mAccessibilityManagerWrapper; |
| 228 | @Inject Lazy<SysuiColorExtractor> mSysuiColorExtractor; |
| 229 | @Inject Lazy<TunablePaddingService> mTunablePaddingService; |
| 230 | @Inject Lazy<ForegroundServiceController> mForegroundServiceController; |
| 231 | @Inject Lazy<UiOffloadThread> mUiOffloadThread; |
| 232 | @Inject Lazy<PowerUI.WarningsUI> mWarningsUI; |
| 233 | @Inject Lazy<LightBarController> mLightBarController; |
| 234 | @Inject Lazy<IWindowManager> mIWindowManager; |
| 235 | @Inject Lazy<OverviewProxyService> mOverviewProxyService; |
| 236 | @Inject Lazy<EnhancedEstimates> mEnhancedEstimates; |
| 237 | @Inject Lazy<VibratorHelper> mVibratorHelper; |
| 238 | @Inject Lazy<IStatusBarService> mIStatusBarService; |
| 239 | @Inject Lazy<DisplayMetrics> mDisplayMetrics; |
| 240 | @Inject Lazy<LockscreenGestureLogger> mLockscreenGestureLogger; |
| 241 | @Inject Lazy<KeyguardEnvironment> mKeyguardEnvironment; |
| 242 | @Inject Lazy<ShadeController> mShadeController; |
| 243 | @Inject Lazy<NotificationRemoteInputManager.Callback> mNotificationRemoteInputManagerCallback; |
| 244 | @Inject Lazy<InitController> mInitController; |
| 245 | @Inject Lazy<AppOpsController> mAppOpsController; |
| 246 | @Inject Lazy<DisplayNavigationBarController> mDisplayNavigationBarController; |
| 247 | @Inject Lazy<StatusBarStateController> mStatusBarStateController; |
| 248 | @Inject Lazy<NotificationLockscreenUserManager> mNotificationLockscreenUserManager; |
| 249 | @Inject Lazy<NotificationGroupAlertTransferHelper> mNotificationGroupAlertTransferHelper; |
| 250 | @Inject Lazy<NotificationGroupManager> mNotificationGroupManager; |
| 251 | @Inject Lazy<VisualStabilityManager> mVisualStabilityManager; |
| 252 | @Inject Lazy<NotificationGutsManager> mNotificationGutsManager; |
| 253 | @Inject Lazy<NotificationMediaManager> mNotificationMediaManager; |
| 254 | @Inject Lazy<AmbientPulseManager> mAmbientPulseManager; |
| 255 | @Inject Lazy<NotificationBlockingHelperManager> mNotificationBlockingHelperManager; |
| 256 | @Inject Lazy<NotificationRemoteInputManager> mNotificationRemoteInputManager; |
| 257 | @Inject Lazy<SmartReplyConstants> mSmartReplyConstants; |
| 258 | @Inject Lazy<NotificationListener> mNotificationListener; |
| 259 | @Inject Lazy<NotificationLogger> mNotificationLogger; |
| 260 | @Inject Lazy<NotificationViewHierarchyManager> mNotificationViewHierarchyManager; |
Gus Prevas | 8ba88a8 | 2018-12-18 11:13:44 -0500 | [diff] [blame] | 261 | @Inject Lazy<NotificationRowBinder> mNotificationRowBinder; |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 262 | @Inject Lazy<NotificationFilter> mNotificationFilter; |
| 263 | @Inject Lazy<NotificationInterruptionStateProvider> mNotificationInterruptionStateProvider; |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 264 | @Inject Lazy<KeyguardDismissUtil> mKeyguardDismissUtil; |
| 265 | @Inject Lazy<SmartReplyController> mSmartReplyController; |
| 266 | @Inject Lazy<RemoteInputQuickSettingsDisabler> mRemoteInputQuickSettingsDisabler; |
| 267 | @Inject Lazy<BubbleController> mBubbleController; |
| 268 | @Inject Lazy<NotificationEntryManager> mNotificationEntryManager; |
| 269 | @Inject Lazy<SensorPrivacyManager> mSensorPrivacyManager; |
| 270 | @Inject @Named(BG_LOOPER_NAME) Lazy<Looper> mBgLooper; |
| 271 | @Inject @Named(BG_HANDLER_NAME) Lazy<Handler> mBgHandler; |
| 272 | @Inject @Named(MAIN_HANDLER_NAME) Lazy<Handler> mMainHandler; |
| 273 | @Inject @Named(TIME_TICK_HANDLER_NAME) Lazy<Handler> mTimeTickHandler; |
| 274 | @Nullable |
| 275 | @Inject @Named(LEAK_REPORT_EMAIL_NAME) Lazy<String> mLeakReportEmail; |
| 276 | |
| 277 | @Inject |
| 278 | public Dependency() { |
| 279 | } |
| 280 | |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 281 | @Override |
| 282 | public void start() { |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 283 | // TODO: Think about ways to push these creation rules out of Dependency to cut down |
| 284 | // on imports. |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 285 | mProviders.put(TIME_TICK_HANDLER, mTimeTickHandler::get); |
| 286 | mProviders.put(BG_LOOPER, mBgLooper::get); |
| 287 | mProviders.put(BG_HANDLER, mBgHandler::get); |
| 288 | mProviders.put(MAIN_HANDLER, mMainHandler::get); |
| 289 | mProviders.put(ActivityStarter.class, mActivityStarter::get); |
| 290 | mProviders.put(ActivityStarterDelegate.class, mActivityStarterDelegate::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 291 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 292 | mProviders.put(AsyncSensorManager.class, mAsyncSensorManager::get); |
Adrian Roos | 7a8ae8a | 2017-08-02 16:26:50 +0200 | [diff] [blame] | 293 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 294 | mProviders.put(BluetoothController.class, mBluetoothController::get); |
| 295 | mProviders.put(SensorPrivacyManager.class, mSensorPrivacyManager::get); |
Chad Brubaker | 90f391f | 2018-10-19 10:26:19 -0700 | [diff] [blame] | 296 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 297 | mProviders.put(LocationController.class, mLocationController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 298 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 299 | mProviders.put(RotationLockController.class, mRotationLockController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 300 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 301 | mProviders.put(NetworkController.class, mNetworkController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 302 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 303 | mProviders.put(ZenModeController.class, mZenModeController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 304 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 305 | mProviders.put(HotspotController.class, mHotspotController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 306 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 307 | mProviders.put(CastController.class, mCastController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 308 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 309 | mProviders.put(FlashlightController.class, mFlashlightController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 310 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 311 | mProviders.put(KeyguardMonitor.class, mKeyguardMonitor::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 312 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 313 | mProviders.put(UserSwitcherController.class, mUserSwitcherController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 314 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 315 | mProviders.put(UserInfoController.class, mUserInfoController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 316 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 317 | mProviders.put(BatteryController.class, mBatteryController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 318 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 319 | mProviders.put(ColorDisplayController.class, mColorDisplayController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 320 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 321 | mProviders.put(ManagedProfileController.class, mManagedProfileController::get); |
Christine Franks | 69c2d1d | 2017-01-23 14:45:29 -0800 | [diff] [blame] | 322 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 323 | mProviders.put(NextAlarmController.class, mNextAlarmController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 324 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 325 | mProviders.put(DataSaverController.class, mDataSaverController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 326 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 327 | mProviders.put(AccessibilityController.class, mAccessibilityController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 328 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 329 | mProviders.put(DeviceProvisionedController.class, mDeviceProvisionedController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 330 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 331 | mProviders.put(PluginManager.class, mPluginManager::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 332 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 333 | mProviders.put(AssistManager.class, mAssistManager::get); |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 334 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 335 | mProviders.put(SecurityController.class, mSecurityController::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 336 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 337 | mProviders.put(LeakDetector.class, mLeakDetector::get); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 338 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 339 | mProviders.put(LEAK_REPORT_EMAIL, mLeakReportEmail::get); |
Adrian Roos | e1e0b48 | 2017-02-02 16:00:59 -0800 | [diff] [blame] | 340 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 341 | mProviders.put(LeakReporter.class, mLeakReporter::get); |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 342 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 343 | mProviders.put(GarbageMonitor.class, mGarbageMonitor::get); |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 344 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 345 | mProviders.put(TunerService.class, mTunerService::get); |
Adrian Roos | 9125068 | 2017-02-06 14:48:15 -0800 | [diff] [blame] | 346 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 347 | mProviders.put(StatusBarWindowController.class, mStatusBarWindowController::get); |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 348 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 349 | mProviders.put(DarkIconDispatcher.class, mDarkIconDispatcher::get); |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 350 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 351 | mProviders.put(ConfigurationController.class, mConfigurationController::get); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 352 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 353 | mProviders.put(StatusBarIconController.class, mStatusBarIconController::get); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 354 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 355 | mProviders.put(ScreenLifecycle.class, mScreenLifecycle::get); |
Jason Monk | aa573e9 | 2017-01-27 17:00:29 -0500 | [diff] [blame] | 356 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 357 | mProviders.put(WakefulnessLifecycle.class, mWakefulnessLifecycle::get); |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 358 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 359 | mProviders.put(FragmentService.class, mFragmentService::get); |
Adrian Roos | 369907f | 2017-07-14 14:53:39 +0200 | [diff] [blame] | 360 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 361 | mProviders.put(ExtensionController.class, mExtensionController::get); |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 362 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 363 | mProviders.put(PluginDependencyProvider.class, mPluginDependencyProvider::get); |
Jason Monk | 1d9632d | 2017-02-09 13:20:04 -0800 | [diff] [blame] | 364 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 365 | mProviders.put(LocalBluetoothManager.class, mLocalBluetoothManager::get); |
Jason Monk | ec34da8 | 2017-02-24 15:57:05 -0500 | [diff] [blame] | 366 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 367 | mProviders.put(VolumeDialogController.class, mVolumeDialogController::get); |
Jason Monk | 6a73e63 | 2017-03-17 11:08:30 -0400 | [diff] [blame] | 368 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 369 | mProviders.put(MetricsLogger.class, mMetricsLogger::get); |
Jason Monk | 782cd67 | 2017-03-22 12:50:57 -0400 | [diff] [blame] | 370 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 371 | mProviders.put(AccessibilityManagerWrapper.class, mAccessibilityManagerWrapper::get); |
Jason Monk | 8c09ac7 | 2017-03-16 11:53:40 -0400 | [diff] [blame] | 372 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 373 | mProviders.put(SysuiColorExtractor.class, mSysuiColorExtractor::get); |
Jason Monk | 91e587e | 2017-04-13 13:41:23 -0400 | [diff] [blame] | 374 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 375 | mProviders.put(TunablePaddingService.class, mTunablePaddingService::get); |
Lucas Dupin | 314d41f | 2017-05-08 15:52:58 -0700 | [diff] [blame] | 376 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 377 | mProviders.put(ForegroundServiceController.class, mForegroundServiceController::get); |
Jason Monk | d4afe15 | 2017-05-01 15:37:43 -0400 | [diff] [blame] | 378 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 379 | mProviders.put(UiOffloadThread.class, mUiOffloadThread::get); |
Dan Sandler | f5aafb9 | 2017-05-28 12:18:53 -0400 | [diff] [blame] | 380 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 381 | mProviders.put(PowerUI.WarningsUI.class, mWarningsUI::get); |
Jorim Jaggi | fabc743 | 2017-05-15 02:40:05 +0200 | [diff] [blame] | 382 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 383 | mProviders.put(IconLogger.class, mIconLogger::get); |
Jason Monk | d819c31 | 2017-08-11 12:53:36 -0400 | [diff] [blame] | 384 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 385 | mProviders.put(LightBarController.class, mLightBarController::get); |
Jason Monk | f8c2f7b | 2017-09-06 09:22:29 -0400 | [diff] [blame] | 386 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 387 | mProviders.put(IWindowManager.class, mIWindowManager::get); |
Jason Monk | 73112d3 | 2017-09-06 16:53:53 -0400 | [diff] [blame] | 388 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 389 | mProviders.put(OverviewProxyService.class, mOverviewProxyService::get); |
Jason Monk | 2044e6e | 2017-10-13 10:34:40 -0400 | [diff] [blame] | 390 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 391 | mProviders.put(EnhancedEstimates.class, mEnhancedEstimates::get); |
Matthew Ng | 13dbf87 | 2017-10-27 11:02:14 -0700 | [diff] [blame] | 392 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 393 | mProviders.put(VibratorHelper.class, mVibratorHelper::get); |
Salvador Martinez | f9e4750 | 2018-01-04 13:45:48 -0800 | [diff] [blame] | 394 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 395 | mProviders.put(IStatusBarService.class, mIStatusBarService::get); |
Matthew Ng | e2b4d79 | 2018-03-09 13:42:18 -0800 | [diff] [blame] | 396 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 397 | mProviders.put(DisplayMetrics.class, mDisplayMetrics::get); |
Kenny Guy | a0f6de8 | 2018-04-06 16:20:16 +0100 | [diff] [blame] | 398 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 399 | mProviders.put(LockscreenGestureLogger.class, mLockscreenGestureLogger::get); |
Jason Monk | e59dc40 | 2018-08-16 12:05:01 -0400 | [diff] [blame] | 400 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 401 | mProviders.put(KeyguardEnvironment.class, mKeyguardEnvironment::get); |
| 402 | mProviders.put(ShadeController.class, mShadeController::get); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 403 | mProviders.put(NotificationRemoteInputManager.Callback.class, |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 404 | mNotificationRemoteInputManagerCallback::get); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 405 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 406 | mProviders.put(InitController.class, mInitController::get); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 407 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 408 | mProviders.put(AppOpsController.class, mAppOpsController::get); |
Fabian Kozynski | 1f32cf0 | 2018-10-23 12:23:31 -0400 | [diff] [blame] | 409 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 410 | mProviders.put(DisplayNavigationBarController.class, |
| 411 | mDisplayNavigationBarController::get); |
Charles Chen | 61325fb | 2018-11-07 20:04:17 +0800 | [diff] [blame] | 412 | |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 413 | mProviders.put(StatusBarStateController.class, mStatusBarStateController::get); |
| 414 | mProviders.put(NotificationLockscreenUserManager.class, |
| 415 | mNotificationLockscreenUserManager::get); |
| 416 | mProviders.put(VisualStabilityManager.class, mVisualStabilityManager::get); |
| 417 | mProviders.put(NotificationGroupManager.class, mNotificationGroupManager::get); |
| 418 | mProviders.put(NotificationGroupAlertTransferHelper.class, |
| 419 | mNotificationGroupAlertTransferHelper::get); |
| 420 | mProviders.put(NotificationMediaManager.class, mNotificationMediaManager::get); |
| 421 | mProviders.put(NotificationGutsManager.class, mNotificationGutsManager::get); |
| 422 | mProviders.put(AmbientPulseManager.class, mAmbientPulseManager::get); |
| 423 | mProviders.put(NotificationBlockingHelperManager.class, |
| 424 | mNotificationBlockingHelperManager::get); |
| 425 | mProviders.put(NotificationRemoteInputManager.class, |
| 426 | mNotificationRemoteInputManager::get); |
| 427 | mProviders.put(SmartReplyConstants.class, mSmartReplyConstants::get); |
| 428 | mProviders.put(NotificationListener.class, mNotificationListener::get); |
| 429 | mProviders.put(NotificationLogger.class, mNotificationLogger::get); |
| 430 | mProviders.put(NotificationViewHierarchyManager.class, |
| 431 | mNotificationViewHierarchyManager::get); |
Gus Prevas | 8ba88a8 | 2018-12-18 11:13:44 -0500 | [diff] [blame] | 432 | mProviders.put(NotificationRowBinder.class, mNotificationRowBinder::get); |
Gus Prevas | ec9e1f0 | 2018-12-18 15:28:12 -0500 | [diff] [blame] | 433 | mProviders.put(NotificationFilter.class, mNotificationFilter::get); |
| 434 | mProviders.put(NotificationInterruptionStateProvider.class, |
| 435 | mNotificationInterruptionStateProvider::get); |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 436 | mProviders.put(KeyguardDismissUtil.class, mKeyguardDismissUtil::get); |
| 437 | mProviders.put(SmartReplyController.class, mSmartReplyController::get); |
| 438 | mProviders.put(RemoteInputQuickSettingsDisabler.class, |
| 439 | mRemoteInputQuickSettingsDisabler::get); |
| 440 | mProviders.put(BubbleController.class, mBubbleController::get); |
| 441 | mProviders.put(NotificationEntryManager.class, mNotificationEntryManager::get); |
Alison Cichowlas | fa7614d | 2018-05-09 19:35:11 -0400 | [diff] [blame] | 442 | |
| 443 | sDependency = this; |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | @Override |
Jason Monk | e107202 | 2017-04-06 15:14:18 -0400 | [diff] [blame] | 447 | public synchronized void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 448 | super.dump(fd, pw, args); |
| 449 | pw.println("Dumping existing controllers:"); |
| 450 | mDependencies.values().stream().filter(obj -> obj instanceof Dumpable) |
| 451 | .forEach(o -> ((Dumpable) o).dump(fd, pw, args)); |
| 452 | } |
| 453 | |
| 454 | @Override |
Jason Monk | e107202 | 2017-04-06 15:14:18 -0400 | [diff] [blame] | 455 | protected synchronized void onConfigurationChanged(Configuration newConfig) { |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 456 | super.onConfigurationChanged(newConfig); |
| 457 | mDependencies.values().stream().filter(obj -> obj instanceof ConfigurationChangedReceiver) |
| 458 | .forEach(o -> ((ConfigurationChangedReceiver) o).onConfigurationChanged(newConfig)); |
| 459 | } |
| 460 | |
| 461 | protected final <T> T getDependency(Class<T> cls) { |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 462 | return getDependencyInner(cls); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 463 | } |
| 464 | |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 465 | protected final <T> T getDependency(DependencyKey<T> key) { |
| 466 | return getDependencyInner(key); |
| 467 | } |
| 468 | |
Jason Monk | e107202 | 2017-04-06 15:14:18 -0400 | [diff] [blame] | 469 | private synchronized <T> T getDependencyInner(Object key) { |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 470 | @SuppressWarnings("unchecked") |
| 471 | T obj = (T) mDependencies.get(key); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 472 | if (obj == null) { |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 473 | obj = createDependency(key); |
| 474 | mDependencies.put(key, obj); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 475 | } |
| 476 | return obj; |
| 477 | } |
| 478 | |
| 479 | @VisibleForTesting |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 480 | protected <T> T createDependency(Object cls) { |
| 481 | Preconditions.checkArgument(cls instanceof DependencyKey<?> || cls instanceof Class<?>); |
| 482 | |
| 483 | @SuppressWarnings("unchecked") |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 484 | DependencyProvider<T> provider = mProviders.get(cls); |
| 485 | if (provider == null) { |
Evan Laird | f12a1f10 | 2017-09-13 14:05:37 -0400 | [diff] [blame] | 486 | throw new IllegalArgumentException("Unsupported dependency " + cls |
| 487 | + ". " + mProviders.size() + " providers known."); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 488 | } |
| 489 | return provider.createDependency(); |
| 490 | } |
| 491 | |
| 492 | private static Dependency sDependency; |
| 493 | |
| 494 | public interface DependencyProvider<T> { |
| 495 | T createDependency(); |
| 496 | } |
| 497 | |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 498 | private <T> void destroyDependency(Class<T> cls, Consumer<T> destroy) { |
| 499 | T dep = (T) mDependencies.remove(cls); |
| 500 | if (dep != null && destroy != null) { |
| 501 | destroy.accept(dep); |
| 502 | } |
| 503 | } |
| 504 | |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 505 | /** |
| 506 | * Used in separate processes (like tuner settings) to init the dependencies. |
| 507 | */ |
| 508 | public static void initDependencies(Context context) { |
| 509 | if (sDependency != null) return; |
| 510 | Dependency d = new Dependency(); |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 511 | d.mContext = context; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 512 | d.mComponents = new HashMap<>(); |
| 513 | d.start(); |
| 514 | } |
| 515 | |
Jason Monk | 790442e | 2017-02-13 17:49:39 -0500 | [diff] [blame] | 516 | /** |
| 517 | * Used in separate process teardown to ensure the context isn't leaked. |
| 518 | * |
| 519 | * TODO: Remove once PreferenceFragment doesn't reference getActivity() |
| 520 | * anymore and these context hacks are no longer needed. |
| 521 | */ |
| 522 | public static void clearDependencies() { |
| 523 | sDependency = null; |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Checks to see if a dependency is instantiated, if it is it removes it from |
| 528 | * the cache and calls the destroy callback. |
| 529 | */ |
| 530 | public static <T> void destroy(Class<T> cls, Consumer<T> destroy) { |
| 531 | sDependency.destroyDependency(cls, destroy); |
| 532 | } |
| 533 | |
Jason Monk | 7fc1f9b | 2018-12-20 15:12:17 -0500 | [diff] [blame^] | 534 | /** |
| 535 | * @deprecated see docs/dagger.md |
| 536 | */ |
| 537 | @Deprecated |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 538 | public static <T> T get(Class<T> cls) { |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 539 | return sDependency.getDependency(cls); |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 540 | } |
| 541 | |
Jason Monk | 7fc1f9b | 2018-12-20 15:12:17 -0500 | [diff] [blame^] | 542 | /** |
| 543 | * @deprecated see docs/dagger.md |
| 544 | */ |
| 545 | @Deprecated |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 546 | public static <T> T get(DependencyKey<T> cls) { |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 547 | return sDependency.getDependency(cls); |
| 548 | } |
Adrian Roos | 09c43c8 | 2017-02-09 19:58:25 +0100 | [diff] [blame] | 549 | |
| 550 | public static final class DependencyKey<V> { |
| 551 | private final String mDisplayName; |
| 552 | |
| 553 | public DependencyKey(String displayName) { |
| 554 | mDisplayName = displayName; |
| 555 | } |
| 556 | |
| 557 | @Override |
| 558 | public String toString() { |
| 559 | return mDisplayName; |
| 560 | } |
| 561 | } |
Jason Monk | 27d01a62 | 2018-12-10 15:57:09 -0500 | [diff] [blame] | 562 | |
| 563 | @Subcomponent |
| 564 | public interface DependencyInjector { |
| 565 | void createSystemUI(Dependency dependency); |
| 566 | } |
| 567 | |
| 568 | public static class DependencyCreator implements Injector { |
| 569 | @Override |
| 570 | public SystemUI apply(Context context) { |
| 571 | Dependency dependency = new Dependency(); |
| 572 | SystemUIFactory.getInstance().getRootComponent() |
| 573 | .createDependency() |
| 574 | .createSystemUI(dependency); |
| 575 | return dependency; |
| 576 | } |
| 577 | } |
Jason Monk | 9c7844c | 2017-01-18 15:21:53 -0500 | [diff] [blame] | 578 | } |