Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.notification.dagger; |
| 18 | |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 19 | import android.app.INotificationManager; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 20 | import android.content.Context; |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 21 | import android.content.pm.LauncherApps; |
| 22 | import android.content.pm.ShortcutManager; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 23 | import android.os.Handler; |
| 24 | import android.view.accessibility.AccessibilityManager; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 25 | |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 26 | import com.android.internal.logging.MetricsLogger; |
Will Brockman | b65faa8 | 2020-03-06 10:26:04 -0500 | [diff] [blame] | 27 | import com.android.internal.logging.UiEventLogger; |
| 28 | import com.android.internal.logging.UiEventLoggerImpl; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 29 | import com.android.systemui.R; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 30 | import com.android.systemui.dagger.qualifiers.Main; |
| 31 | import com.android.systemui.dagger.qualifiers.UiBackground; |
| 32 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 33 | import com.android.systemui.settings.CurrentUserContextTracker; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 34 | import com.android.systemui.statusbar.FeatureFlags; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 35 | import com.android.systemui.statusbar.NotificationListener; |
| 36 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
| 37 | import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 38 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 39 | import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 40 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 41 | import com.android.systemui.statusbar.notification.collection.NotifPipeline; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 42 | import com.android.systemui.statusbar.notification.collection.NotificationRankingManager; |
| 43 | import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 44 | import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 45 | import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 46 | import com.android.systemui.statusbar.notification.init.NotificationsController; |
| 47 | import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl; |
| 48 | import com.android.systemui.statusbar.notification.init.NotificationsControllerStub; |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 49 | import com.android.systemui.statusbar.notification.interruption.NotificationAlertingManager; |
| 50 | import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; |
| 51 | import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 52 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
Will Brockman | 492b381 | 2020-03-03 16:29:36 +0000 | [diff] [blame] | 53 | import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger; |
| 54 | import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 55 | import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; |
| 56 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 57 | import com.android.systemui.statusbar.notification.row.PriorityOnboardingDialogController; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 58 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
| 59 | import com.android.systemui.statusbar.phone.StatusBar; |
Beverly | 95a0802ac | 2020-02-10 15:27:40 -0500 | [diff] [blame] | 60 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 61 | import com.android.systemui.util.leak.LeakDetector; |
| 62 | |
| 63 | import java.util.concurrent.Executor; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 64 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 65 | import javax.inject.Provider; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 66 | import javax.inject.Singleton; |
| 67 | |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 68 | import dagger.Binds; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 69 | import dagger.Lazy; |
| 70 | import dagger.Module; |
| 71 | import dagger.Provides; |
| 72 | |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 73 | /** |
| 74 | * Dagger Module for classes found within the com.android.systemui.statusbar.notification package. |
| 75 | */ |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 76 | @Module |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 77 | public interface NotificationsModule { |
| 78 | /** Provides an instance of {@link NotificationEntryManager} */ |
| 79 | @Singleton |
| 80 | @Provides |
| 81 | static NotificationEntryManager provideNotificationEntryManager( |
| 82 | NotificationEntryManagerLogger logger, |
| 83 | NotificationGroupManager groupManager, |
| 84 | NotificationRankingManager rankingManager, |
| 85 | NotificationEntryManager.KeyguardEnvironment keyguardEnvironment, |
| 86 | FeatureFlags featureFlags, |
| 87 | Lazy<NotificationRowBinder> notificationRowBinderLazy, |
| 88 | Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy, |
| 89 | LeakDetector leakDetector, |
| 90 | ForegroundServiceDismissalFeatureController fgsFeatureController) { |
| 91 | return new NotificationEntryManager( |
| 92 | logger, |
| 93 | groupManager, |
| 94 | rankingManager, |
| 95 | keyguardEnvironment, |
| 96 | featureFlags, |
| 97 | notificationRowBinderLazy, |
| 98 | notificationRemoteInputManagerLazy, |
| 99 | leakDetector, |
| 100 | fgsFeatureController); |
| 101 | } |
| 102 | |
| 103 | /** Provides an instance of {@link NotificationGutsManager} */ |
| 104 | @Singleton |
| 105 | @Provides |
| 106 | static NotificationGutsManager provideNotificationGutsManager( |
| 107 | Context context, |
| 108 | VisualStabilityManager visualStabilityManager, |
| 109 | Lazy<StatusBar> statusBarLazy, |
| 110 | @Main Handler mainHandler, |
| 111 | AccessibilityManager accessibilityManager, |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 112 | HighPriorityProvider highPriorityProvider, |
| 113 | INotificationManager notificationManager, |
| 114 | LauncherApps launcherApps, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 115 | ShortcutManager shortcutManager, |
| 116 | CurrentUserContextTracker contextTracker, |
| 117 | Provider<PriorityOnboardingDialogController.Builder> builderProvider) { |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 118 | return new NotificationGutsManager( |
| 119 | context, |
| 120 | visualStabilityManager, |
| 121 | statusBarLazy, |
| 122 | mainHandler, |
| 123 | accessibilityManager, |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 124 | highPriorityProvider, |
| 125 | notificationManager, |
| 126 | launcherApps, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 127 | shortcutManager, |
| 128 | contextTracker, |
| 129 | builderProvider); |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | /** Provides an instance of {@link VisualStabilityManager} */ |
| 133 | @Singleton |
| 134 | @Provides |
| 135 | static VisualStabilityManager provideVisualStabilityManager( |
| 136 | NotificationEntryManager notificationEntryManager, Handler handler) { |
| 137 | return new VisualStabilityManager(notificationEntryManager, handler); |
| 138 | } |
| 139 | |
| 140 | /** Provides an instance of {@link NotificationAlertingManager} */ |
| 141 | @Singleton |
| 142 | @Provides |
| 143 | static NotificationAlertingManager provideNotificationAlertingManager( |
| 144 | NotificationEntryManager notificationEntryManager, |
| 145 | NotificationRemoteInputManager remoteInputManager, |
| 146 | VisualStabilityManager visualStabilityManager, |
| 147 | StatusBarStateController statusBarStateController, |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 148 | NotificationInterruptStateProvider notificationInterruptStateProvider, |
Beverly | 95a0802ac | 2020-02-10 15:27:40 -0500 | [diff] [blame] | 149 | NotificationListener notificationListener, |
| 150 | HeadsUpManager headsUpManager) { |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 151 | return new NotificationAlertingManager( |
| 152 | notificationEntryManager, |
| 153 | remoteInputManager, |
| 154 | visualStabilityManager, |
| 155 | statusBarStateController, |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 156 | notificationInterruptStateProvider, |
Beverly | 95a0802ac | 2020-02-10 15:27:40 -0500 | [diff] [blame] | 157 | notificationListener, |
| 158 | headsUpManager); |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /** Provides an instance of {@link NotificationLogger} */ |
| 162 | @Singleton |
| 163 | @Provides |
| 164 | static NotificationLogger provideNotificationLogger( |
| 165 | NotificationListener notificationListener, |
| 166 | @UiBackground Executor uiBgExecutor, |
| 167 | NotificationEntryManager entryManager, |
| 168 | StatusBarStateController statusBarStateController, |
Will Brockman | 492b381 | 2020-03-03 16:29:36 +0000 | [diff] [blame] | 169 | NotificationLogger.ExpansionStateLogger expansionStateLogger, |
| 170 | NotificationPanelLogger notificationPanelLogger) { |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 171 | return new NotificationLogger( |
| 172 | notificationListener, |
| 173 | uiBgExecutor, |
| 174 | entryManager, |
| 175 | statusBarStateController, |
Will Brockman | 492b381 | 2020-03-03 16:29:36 +0000 | [diff] [blame] | 176 | expansionStateLogger, |
| 177 | notificationPanelLogger); |
| 178 | } |
| 179 | |
| 180 | /** Provides an instance of {@link NotificationPanelLogger} */ |
| 181 | @Singleton |
| 182 | @Provides |
| 183 | static NotificationPanelLogger provideNotificationPanelLogger() { |
| 184 | return new NotificationPanelLoggerImpl(); |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 185 | } |
| 186 | |
Will Brockman | b65faa8 | 2020-03-06 10:26:04 -0500 | [diff] [blame] | 187 | /** Provides an instance of {@link com.android.internal.logging.UiEventLogger} */ |
| 188 | @Singleton |
| 189 | @Provides |
| 190 | static UiEventLogger provideUiEventLogger() { |
| 191 | return new UiEventLoggerImpl(); |
| 192 | } |
| 193 | |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 194 | /** Provides an instance of {@link NotificationBlockingHelperManager} */ |
| 195 | @Singleton |
| 196 | @Provides |
| 197 | static NotificationBlockingHelperManager provideNotificationBlockingHelperManager( |
| 198 | Context context, |
| 199 | NotificationGutsManager notificationGutsManager, |
| 200 | NotificationEntryManager notificationEntryManager, |
| 201 | MetricsLogger metricsLogger) { |
| 202 | return new NotificationBlockingHelperManager( |
| 203 | context, notificationGutsManager, notificationEntryManager, metricsLogger); |
| 204 | } |
| 205 | |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 206 | /** Initializes the notification data pipeline (can be disabled via config). */ |
| 207 | @Singleton |
| 208 | @Provides |
| 209 | static NotificationsController provideNotificationsController( |
| 210 | Context context, |
| 211 | Lazy<NotificationsControllerImpl> realController, |
| 212 | Lazy<NotificationsControllerStub> stubController) { |
| 213 | if (context.getResources().getBoolean(R.bool.config_renderNotifications)) { |
| 214 | return realController.get(); |
| 215 | } else { |
| 216 | return stubController.get(); |
| 217 | } |
| 218 | } |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 219 | |
| 220 | /** |
| 221 | * Provide the active notification collection managing the notifications to render. |
| 222 | */ |
| 223 | @Provides |
| 224 | @Singleton |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 225 | static CommonNotifCollection provideCommonNotifCollection( |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 226 | FeatureFlags featureFlags, |
| 227 | Lazy<NotifPipeline> pipeline, |
| 228 | NotificationEntryManager entryManager) { |
| 229 | return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager; |
| 230 | } |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 231 | |
| 232 | /** */ |
| 233 | @Binds |
| 234 | NotificationInterruptStateProvider bindNotificationInterruptStateProvider( |
| 235 | NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl); |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 236 | } |