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