blob: 033a638bdd73be24f6caac497457b2825aaa62d8 [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;
Ned Burns46597ba2020-01-30 13:58:46 -050027import com.android.systemui.R;
Steve Elliott6771f542020-05-26 13:31:10 -040028import com.android.systemui.dagger.qualifiers.Background;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010029import com.android.systemui.dagger.qualifiers.Main;
30import com.android.systemui.dagger.qualifiers.UiBackground;
31import com.android.systemui.plugins.statusbar.StatusBarStateController;
Evan Laird31ca5472020-04-08 17:45:24 -040032import com.android.systemui.settings.CurrentUserContextTracker;
Kevin Hanf400aee2020-01-30 13:10:29 -080033import com.android.systemui.statusbar.FeatureFlags;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010034import com.android.systemui.statusbar.NotificationListener;
35import com.android.systemui.statusbar.NotificationRemoteInputManager;
36import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
Kevin Hanf400aee2020-01-30 13:10:29 -080037import com.android.systemui.statusbar.notification.NotificationEntryManager;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010038import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010039import com.android.systemui.statusbar.notification.VisualStabilityManager;
Kevin Hanf400aee2020-01-30 13:10:29 -080040import com.android.systemui.statusbar.notification.collection.NotifPipeline;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010041import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
42import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
Kevin Hanf400aee2020-01-30 13:10:29 -080043import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010044import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
Ned Burns46597ba2020-01-30 13:58:46 -050045import com.android.systemui.statusbar.notification.init.NotificationsController;
46import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl;
47import com.android.systemui.statusbar.notification.init.NotificationsControllerStub;
Beverly Taid1e175c2020-03-10 16:37:04 +000048import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
49import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010050import com.android.systemui.statusbar.notification.logging.NotificationLogger;
Will Brockman492b3812020-03-03 16:29:36 +000051import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
52import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl;
Evan Laird18bd6e62019-08-30 16:39:25 -040053import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010054import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
55import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
Evan Laird31ca5472020-04-08 17:45:24 -040056import com.android.systemui.statusbar.notification.row.PriorityOnboardingDialogController;
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010057import com.android.systemui.statusbar.phone.NotificationGroupManager;
58import com.android.systemui.statusbar.phone.StatusBar;
59import com.android.systemui.util.leak.LeakDetector;
60
61import java.util.concurrent.Executor;
Ned Burns46597ba2020-01-30 13:58:46 -050062
Evan Laird31ca5472020-04-08 17:45:24 -040063import javax.inject.Provider;
Ned Burns46597ba2020-01-30 13:58:46 -050064import javax.inject.Singleton;
65
Beverly Taid1e175c2020-03-10 16:37:04 +000066import dagger.Binds;
Ned Burns46597ba2020-01-30 13:58:46 -050067import dagger.Lazy;
68import dagger.Module;
69import dagger.Provides;
70
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010071/**
72 * Dagger Module for classes found within the com.android.systemui.statusbar.notification package.
73 */
Ned Burns46597ba2020-01-30 13:58:46 -050074@Module
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +010075public 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 Elliott6771f542020-05-26 13:31:10 -0400109 @Background Handler bgHandler,
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100110 AccessibilityManager accessibilityManager,
Steve Elliott46bb2a12020-03-17 11:04:09 -0400111 HighPriorityProvider highPriorityProvider,
112 INotificationManager notificationManager,
113 LauncherApps launcherApps,
Evan Laird31ca5472020-04-08 17:45:24 -0400114 ShortcutManager shortcutManager,
Evan Laird18bd6e62019-08-30 16:39:25 -0400115 ChannelEditorDialogController channelEditorDialogController,
Evan Laird31ca5472020-04-08 17:45:24 -0400116 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,
Steve Elliott6771f542020-05-26 13:31:10 -0400123 bgHandler,
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100124 accessibilityManager,
Steve Elliott46bb2a12020-03-17 11:04:09 -0400125 highPriorityProvider,
126 notificationManager,
127 launcherApps,
Evan Laird31ca5472020-04-08 17:45:24 -0400128 shortcutManager,
Evan Laird18bd6e62019-08-30 16:39:25 -0400129 channelEditorDialogController,
Evan Laird31ca5472020-04-08 17:45:24 -0400130 contextTracker,
131 builderProvider);
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100132 }
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 Nikolaienkovf6ad6322020-02-10 15:46:32 +0100142 /** 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 Brockman492b3812020-03-03 16:29:36 +0000150 NotificationLogger.ExpansionStateLogger expansionStateLogger,
151 NotificationPanelLogger notificationPanelLogger) {
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100152 return new NotificationLogger(
153 notificationListener,
154 uiBgExecutor,
155 entryManager,
156 statusBarStateController,
Will Brockman492b3812020-03-03 16:29:36 +0000157 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 Nikolaienkovf6ad6322020-02-10 15:46:32 +0100166 }
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 Burns46597ba2020-01-30 13:58:46 -0500180 /** 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 Hanf400aee2020-01-30 13:10:29 -0800193
194 /**
195 * Provide the active notification collection managing the notifications to render.
196 */
197 @Provides
198 @Singleton
Sergey Nikolaienkovf6ad6322020-02-10 15:46:32 +0100199 static CommonNotifCollection provideCommonNotifCollection(
Kevin Hanf400aee2020-01-30 13:10:29 -0800200 FeatureFlags featureFlags,
201 Lazy<NotifPipeline> pipeline,
202 NotificationEntryManager entryManager) {
203 return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager;
204 }
Beverly Taid1e175c2020-03-10 16:37:04 +0000205
206 /** */
207 @Binds
208 NotificationInterruptStateProvider bindNotificationInterruptStateProvider(
209 NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl);
Ned Burns46597ba2020-01-30 13:58:46 -0500210}