blob: 355990b7754458290bb0d06be3a8fc3af0bddab7 [file] [log] [blame]
Ned Burns46597ba2020-01-30 13:58:46 -05001/*
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
17package com.android.systemui.statusbar.notification.dagger;
18
Steve Elliott46bb2a12020-03-17 11:04:09 -040019import android.app.INotificationManager;
Ned Burns46597ba2020-01-30 13:58:46 -050020import android.content.Context;
Steve Elliott46bb2a12020-03-17 11:04:09 -040021import android.content.pm.LauncherApps;
22import android.content.pm.ShortcutManager;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010023import android.os.Handler;
24import android.view.accessibility.AccessibilityManager;
Ned Burns46597ba2020-01-30 13:58:46 -050025
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010026import com.android.internal.logging.MetricsLogger;
Will Brockmanb65faa82020-03-06 10:26:04 -050027import com.android.internal.logging.UiEventLogger;
28import com.android.internal.logging.UiEventLoggerImpl;
Ned Burns46597ba2020-01-30 13:58:46 -050029import com.android.systemui.R;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010030import com.android.systemui.dagger.qualifiers.Main;
31import com.android.systemui.dagger.qualifiers.UiBackground;
32import com.android.systemui.plugins.statusbar.StatusBarStateController;
Evan Laird31ca5472020-04-08 17:45:24 -040033import com.android.systemui.settings.CurrentUserContextTracker;
Kevin Hanf400aee2020-01-30 13:10:29 -080034import com.android.systemui.statusbar.FeatureFlags;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010035import com.android.systemui.statusbar.NotificationListener;
36import com.android.systemui.statusbar.NotificationRemoteInputManager;
37import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
Kevin Hanf400aee2020-01-30 13:10:29 -080038import com.android.systemui.statusbar.notification.NotificationEntryManager;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010039import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010040import com.android.systemui.statusbar.notification.VisualStabilityManager;
Kevin Hanf400aee2020-01-30 13:10:29 -080041import com.android.systemui.statusbar.notification.collection.NotifPipeline;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010042import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
43import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
Kevin Hanf400aee2020-01-30 13:10:29 -080044import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010045import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
Ned Burns46597ba2020-01-30 13:58:46 -050046import com.android.systemui.statusbar.notification.init.NotificationsController;
47import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl;
48import com.android.systemui.statusbar.notification.init.NotificationsControllerStub;
Beverly Taid1e175c2020-03-10 16:37:04 +000049import com.android.systemui.statusbar.notification.interruption.NotificationAlertingManager;
50import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
51import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010052import com.android.systemui.statusbar.notification.logging.NotificationLogger;
Will Brockman492b3812020-03-03 16:29:36 +000053import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
54import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010055import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
56import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
Evan Laird31ca5472020-04-08 17:45:24 -040057import com.android.systemui.statusbar.notification.row.PriorityOnboardingDialogController;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010058import com.android.systemui.statusbar.phone.NotificationGroupManager;
59import com.android.systemui.statusbar.phone.StatusBar;
Beverly95a0802ac2020-02-10 15:27:40 -050060import com.android.systemui.statusbar.policy.HeadsUpManager;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010061import com.android.systemui.util.leak.LeakDetector;
62
63import java.util.concurrent.Executor;
Ned Burns46597ba2020-01-30 13:58:46 -050064
Evan Laird31ca5472020-04-08 17:45:24 -040065import javax.inject.Provider;
Ned Burns46597ba2020-01-30 13:58:46 -050066import javax.inject.Singleton;
67
Beverly Taid1e175c2020-03-10 16:37:04 +000068import dagger.Binds;
Ned Burns46597ba2020-01-30 13:58:46 -050069import dagger.Lazy;
70import dagger.Module;
71import dagger.Provides;
72
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010073/**
74 * Dagger Module for classes found within the com.android.systemui.statusbar.notification package.
75 */
Ned Burns46597ba2020-01-30 13:58:46 -050076@Module
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010077public 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 Elliott46bb2a12020-03-17 11:04:09 -0400112 HighPriorityProvider highPriorityProvider,
113 INotificationManager notificationManager,
114 LauncherApps launcherApps,
Evan Laird31ca5472020-04-08 17:45:24 -0400115 ShortcutManager shortcutManager,
116 CurrentUserContextTracker contextTracker,
117 Provider<PriorityOnboardingDialogController.Builder> builderProvider) {
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100118 return new NotificationGutsManager(
119 context,
120 visualStabilityManager,
121 statusBarLazy,
122 mainHandler,
123 accessibilityManager,
Steve Elliott46bb2a12020-03-17 11:04:09 -0400124 highPriorityProvider,
125 notificationManager,
126 launcherApps,
Evan Laird31ca5472020-04-08 17:45:24 -0400127 shortcutManager,
128 contextTracker,
129 builderProvider);
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100130 }
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 Taid1e175c2020-03-10 16:37:04 +0000148 NotificationInterruptStateProvider notificationInterruptStateProvider,
Beverly95a0802ac2020-02-10 15:27:40 -0500149 NotificationListener notificationListener,
150 HeadsUpManager headsUpManager) {
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100151 return new NotificationAlertingManager(
152 notificationEntryManager,
153 remoteInputManager,
154 visualStabilityManager,
155 statusBarStateController,
Beverly Taid1e175c2020-03-10 16:37:04 +0000156 notificationInterruptStateProvider,
Beverly95a0802ac2020-02-10 15:27:40 -0500157 notificationListener,
158 headsUpManager);
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100159 }
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 Brockman492b3812020-03-03 16:29:36 +0000169 NotificationLogger.ExpansionStateLogger expansionStateLogger,
170 NotificationPanelLogger notificationPanelLogger) {
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100171 return new NotificationLogger(
172 notificationListener,
173 uiBgExecutor,
174 entryManager,
175 statusBarStateController,
Will Brockman492b3812020-03-03 16:29:36 +0000176 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 Nikolaienkovf6ad6322020-02-10 15:46:32 +0100185 }
186
Will Brockmanb65faa82020-03-06 10:26:04 -0500187 /** 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 Nikolaienkovf6ad6322020-02-10 15:46:32 +0100194 /** 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 Burns46597ba2020-01-30 13:58:46 -0500206 /** 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 Hanf400aee2020-01-30 13:10:29 -0800219
220 /**
221 * Provide the active notification collection managing the notifications to render.
222 */
223 @Provides
224 @Singleton
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100225 static CommonNotifCollection provideCommonNotifCollection(
Kevin Hanf400aee2020-01-30 13:10:29 -0800226 FeatureFlags featureFlags,
227 Lazy<NotifPipeline> pipeline,
228 NotificationEntryManager entryManager) {
229 return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager;
230 }
Beverly Taid1e175c2020-03-10 16:37:04 +0000231
232 /** */
233 @Binds
234 NotificationInterruptStateProvider bindNotificationInterruptStateProvider(
235 NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl);
Ned Burns46597ba2020-01-30 13:58:46 -0500236}