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; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 27 | import com.android.systemui.R; |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 28 | import com.android.systemui.dagger.qualifiers.Background; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 29 | import com.android.systemui.dagger.qualifiers.Main; |
| 30 | import com.android.systemui.dagger.qualifiers.UiBackground; |
| 31 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 32 | import com.android.systemui.settings.CurrentUserContextTracker; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 33 | import com.android.systemui.statusbar.FeatureFlags; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 34 | import com.android.systemui.statusbar.NotificationListener; |
| 35 | import com.android.systemui.statusbar.NotificationRemoteInputManager; |
| 36 | import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 37 | import com.android.systemui.statusbar.notification.NotificationEntryManager; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 38 | import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 39 | import com.android.systemui.statusbar.notification.VisualStabilityManager; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 40 | import com.android.systemui.statusbar.notification.collection.NotifPipeline; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 41 | import com.android.systemui.statusbar.notification.collection.NotificationRankingManager; |
| 42 | import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder; |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 43 | import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 44 | import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 45 | import com.android.systemui.statusbar.notification.init.NotificationsController; |
| 46 | import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl; |
| 47 | import com.android.systemui.statusbar.notification.init.NotificationsControllerStub; |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 48 | import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider; |
| 49 | import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 50 | import com.android.systemui.statusbar.notification.logging.NotificationLogger; |
Will Brockman | 492b381 | 2020-03-03 16:29:36 +0000 | [diff] [blame] | 51 | import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger; |
| 52 | import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl; |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 53 | import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 54 | import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager; |
| 55 | import com.android.systemui.statusbar.notification.row.NotificationGutsManager; |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 56 | import com.android.systemui.statusbar.notification.row.PriorityOnboardingDialogController; |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 57 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
| 58 | import com.android.systemui.statusbar.phone.StatusBar; |
| 59 | import com.android.systemui.util.leak.LeakDetector; |
| 60 | |
| 61 | import java.util.concurrent.Executor; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 62 | |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 63 | import javax.inject.Provider; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 64 | import javax.inject.Singleton; |
| 65 | |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 66 | import dagger.Binds; |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 67 | import dagger.Lazy; |
| 68 | import dagger.Module; |
| 69 | import dagger.Provides; |
| 70 | |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 71 | /** |
| 72 | * Dagger Module for classes found within the com.android.systemui.statusbar.notification package. |
| 73 | */ |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 74 | @Module |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 75 | public interface NotificationsModule { |
| 76 | /** Provides an instance of {@link NotificationEntryManager} */ |
| 77 | @Singleton |
| 78 | @Provides |
| 79 | static NotificationEntryManager provideNotificationEntryManager( |
| 80 | NotificationEntryManagerLogger logger, |
| 81 | NotificationGroupManager groupManager, |
| 82 | NotificationRankingManager rankingManager, |
| 83 | NotificationEntryManager.KeyguardEnvironment keyguardEnvironment, |
| 84 | FeatureFlags featureFlags, |
| 85 | Lazy<NotificationRowBinder> notificationRowBinderLazy, |
| 86 | Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy, |
| 87 | LeakDetector leakDetector, |
| 88 | ForegroundServiceDismissalFeatureController fgsFeatureController) { |
| 89 | return new NotificationEntryManager( |
| 90 | logger, |
| 91 | groupManager, |
| 92 | rankingManager, |
| 93 | keyguardEnvironment, |
| 94 | featureFlags, |
| 95 | notificationRowBinderLazy, |
| 96 | notificationRemoteInputManagerLazy, |
| 97 | leakDetector, |
| 98 | fgsFeatureController); |
| 99 | } |
| 100 | |
| 101 | /** Provides an instance of {@link NotificationGutsManager} */ |
| 102 | @Singleton |
| 103 | @Provides |
| 104 | static NotificationGutsManager provideNotificationGutsManager( |
| 105 | Context context, |
| 106 | VisualStabilityManager visualStabilityManager, |
| 107 | Lazy<StatusBar> statusBarLazy, |
| 108 | @Main Handler mainHandler, |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 109 | @Background Handler bgHandler, |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 110 | AccessibilityManager accessibilityManager, |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 111 | HighPriorityProvider highPriorityProvider, |
| 112 | INotificationManager notificationManager, |
| 113 | LauncherApps launcherApps, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 114 | ShortcutManager shortcutManager, |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 115 | ChannelEditorDialogController channelEditorDialogController, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 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, |
Steve Elliott | 6771f54 | 2020-05-26 13:31:10 -0400 | [diff] [blame] | 123 | bgHandler, |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 124 | accessibilityManager, |
Steve Elliott | 46bb2a1 | 2020-03-17 11:04:09 -0400 | [diff] [blame] | 125 | highPriorityProvider, |
| 126 | notificationManager, |
| 127 | launcherApps, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 128 | shortcutManager, |
Evan Laird | 18bd6e6 | 2019-08-30 16:39:25 -0400 | [diff] [blame] | 129 | channelEditorDialogController, |
Evan Laird | 31ca547 | 2020-04-08 17:45:24 -0400 | [diff] [blame] | 130 | contextTracker, |
| 131 | builderProvider); |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /** Provides an instance of {@link VisualStabilityManager} */ |
| 135 | @Singleton |
| 136 | @Provides |
| 137 | static VisualStabilityManager provideVisualStabilityManager( |
| 138 | NotificationEntryManager notificationEntryManager, Handler handler) { |
| 139 | return new VisualStabilityManager(notificationEntryManager, handler); |
| 140 | } |
| 141 | |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 142 | /** Provides an instance of {@link NotificationLogger} */ |
| 143 | @Singleton |
| 144 | @Provides |
| 145 | static NotificationLogger provideNotificationLogger( |
| 146 | NotificationListener notificationListener, |
| 147 | @UiBackground Executor uiBgExecutor, |
| 148 | NotificationEntryManager entryManager, |
| 149 | StatusBarStateController statusBarStateController, |
Will Brockman | 492b381 | 2020-03-03 16:29:36 +0000 | [diff] [blame] | 150 | NotificationLogger.ExpansionStateLogger expansionStateLogger, |
| 151 | NotificationPanelLogger notificationPanelLogger) { |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 152 | return new NotificationLogger( |
| 153 | notificationListener, |
| 154 | uiBgExecutor, |
| 155 | entryManager, |
| 156 | statusBarStateController, |
Will Brockman | 492b381 | 2020-03-03 16:29:36 +0000 | [diff] [blame] | 157 | expansionStateLogger, |
| 158 | notificationPanelLogger); |
| 159 | } |
| 160 | |
| 161 | /** Provides an instance of {@link NotificationPanelLogger} */ |
| 162 | @Singleton |
| 163 | @Provides |
| 164 | static NotificationPanelLogger provideNotificationPanelLogger() { |
| 165 | return new NotificationPanelLoggerImpl(); |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /** Provides an instance of {@link NotificationBlockingHelperManager} */ |
| 169 | @Singleton |
| 170 | @Provides |
| 171 | static NotificationBlockingHelperManager provideNotificationBlockingHelperManager( |
| 172 | Context context, |
| 173 | NotificationGutsManager notificationGutsManager, |
| 174 | NotificationEntryManager notificationEntryManager, |
| 175 | MetricsLogger metricsLogger) { |
| 176 | return new NotificationBlockingHelperManager( |
| 177 | context, notificationGutsManager, notificationEntryManager, metricsLogger); |
| 178 | } |
| 179 | |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 180 | /** Initializes the notification data pipeline (can be disabled via config). */ |
| 181 | @Singleton |
| 182 | @Provides |
| 183 | static NotificationsController provideNotificationsController( |
| 184 | Context context, |
| 185 | Lazy<NotificationsControllerImpl> realController, |
| 186 | Lazy<NotificationsControllerStub> stubController) { |
| 187 | if (context.getResources().getBoolean(R.bool.config_renderNotifications)) { |
| 188 | return realController.get(); |
| 189 | } else { |
| 190 | return stubController.get(); |
| 191 | } |
| 192 | } |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 193 | |
| 194 | /** |
| 195 | * Provide the active notification collection managing the notifications to render. |
| 196 | */ |
| 197 | @Provides |
| 198 | @Singleton |
Sergey Nikolaienkov | f6ad632 | 2020-02-10 15:46:32 +0100 | [diff] [blame] | 199 | static CommonNotifCollection provideCommonNotifCollection( |
Kevin Han | f400aee | 2020-01-30 13:10:29 -0800 | [diff] [blame] | 200 | FeatureFlags featureFlags, |
| 201 | Lazy<NotifPipeline> pipeline, |
| 202 | NotificationEntryManager entryManager) { |
| 203 | return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager; |
| 204 | } |
Beverly Tai | d1e175c | 2020-03-10 16:37:04 +0000 | [diff] [blame] | 205 | |
| 206 | /** */ |
| 207 | @Binds |
| 208 | NotificationInterruptStateProvider bindNotificationInterruptStateProvider( |
| 209 | NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl); |
Ned Burns | 46597ba | 2020-01-30 13:58:46 -0500 | [diff] [blame] | 210 | } |