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