• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
19 import android.app.INotificationManager;
20 import android.content.Context;
21 import android.content.pm.LauncherApps;
22 import android.content.pm.ShortcutManager;
23 import android.os.Handler;
24 import android.view.accessibility.AccessibilityManager;
25 
26 import com.android.internal.logging.UiEventLogger;
27 import com.android.internal.statusbar.IStatusBarService;
28 import com.android.systemui.R;
29 import com.android.systemui.dagger.SysUISingleton;
30 import com.android.systemui.dagger.qualifiers.Background;
31 import com.android.systemui.dagger.qualifiers.Main;
32 import com.android.systemui.dagger.qualifiers.UiBackground;
33 import com.android.systemui.keyguard.WakefulnessLifecycle;
34 import com.android.systemui.people.widget.PeopleSpaceWidgetManager;
35 import com.android.systemui.plugins.statusbar.StatusBarStateController;
36 import com.android.systemui.settings.UserContextProvider;
37 import com.android.systemui.statusbar.FeatureFlags;
38 import com.android.systemui.statusbar.NotificationListener;
39 import com.android.systemui.statusbar.NotificationRemoteInputManager;
40 import com.android.systemui.statusbar.notification.AssistantFeedbackController;
41 import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
42 import com.android.systemui.statusbar.notification.NotificationEntryManager;
43 import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger;
44 import com.android.systemui.statusbar.notification.collection.NotifCollection;
45 import com.android.systemui.statusbar.notification.collection.NotifInflaterImpl;
46 import com.android.systemui.statusbar.notification.collection.NotifPipeline;
47 import com.android.systemui.statusbar.notification.collection.coordinator.VisualStabilityCoordinator;
48 import com.android.systemui.statusbar.notification.collection.inflation.NotifInflater;
49 import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
50 import com.android.systemui.statusbar.notification.collection.inflation.OnUserInteractionCallbackImpl;
51 import com.android.systemui.statusbar.notification.collection.legacy.NotificationGroupManagerLegacy;
52 import com.android.systemui.statusbar.notification.collection.legacy.OnUserInteractionCallbackImplLegacy;
53 import com.android.systemui.statusbar.notification.collection.legacy.VisualStabilityManager;
54 import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
55 import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
56 import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManager;
57 import com.android.systemui.statusbar.notification.collection.render.GroupExpansionManagerImpl;
58 import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager;
59 import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManagerImpl;
60 import com.android.systemui.statusbar.notification.init.NotificationsController;
61 import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl;
62 import com.android.systemui.statusbar.notification.init.NotificationsControllerStub;
63 import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
64 import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl;
65 import com.android.systemui.statusbar.notification.logging.NotificationLogger;
66 import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
67 import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl;
68 import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController;
69 import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
70 import com.android.systemui.statusbar.notification.row.OnUserInteractionCallback;
71 import com.android.systemui.statusbar.notification.stack.NotificationSectionsManager;
72 import com.android.systemui.statusbar.notification.stack.StackScrollAlgorithm;
73 import com.android.systemui.statusbar.phone.KeyguardBypassController;
74 import com.android.systemui.statusbar.phone.ShadeController;
75 import com.android.systemui.statusbar.phone.StatusBar;
76 import com.android.systemui.statusbar.policy.HeadsUpManager;
77 import com.android.systemui.util.leak.LeakDetector;
78 import com.android.systemui.wmshell.BubblesManager;
79 
80 import java.util.Optional;
81 import java.util.concurrent.Executor;
82 
83 import dagger.Binds;
84 import dagger.Lazy;
85 import dagger.Module;
86 import dagger.Provides;
87 
88 /**
89  * Dagger Module for classes found within the com.android.systemui.statusbar.notification package.
90  */
91 @Module(includes = { NotificationSectionHeadersModule.class })
92 public interface NotificationsModule {
93     @Binds
bindSectionProvider( NotificationSectionsManager impl)94     StackScrollAlgorithm.SectionProvider bindSectionProvider(
95             NotificationSectionsManager impl);
96 
97     @Binds
bindBypassController( KeyguardBypassController impl)98     StackScrollAlgorithm.BypassController bindBypassController(
99             KeyguardBypassController impl);
100 
101     /** Provides an instance of {@link NotificationEntryManager} */
102     @SysUISingleton
103     @Provides
provideNotificationEntryManager( NotificationEntryManagerLogger logger, NotificationGroupManagerLegacy groupManager, FeatureFlags featureFlags, Lazy<NotificationRowBinder> notificationRowBinderLazy, Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy, LeakDetector leakDetector, ForegroundServiceDismissalFeatureController fgsFeatureController, IStatusBarService statusBarService)104     static NotificationEntryManager provideNotificationEntryManager(
105             NotificationEntryManagerLogger logger,
106             NotificationGroupManagerLegacy groupManager,
107             FeatureFlags featureFlags,
108             Lazy<NotificationRowBinder> notificationRowBinderLazy,
109             Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy,
110             LeakDetector leakDetector,
111             ForegroundServiceDismissalFeatureController fgsFeatureController,
112             IStatusBarService statusBarService) {
113         return new NotificationEntryManager(
114                 logger,
115                 groupManager,
116                 featureFlags,
117                 notificationRowBinderLazy,
118                 notificationRemoteInputManagerLazy,
119                 leakDetector,
120                 fgsFeatureController,
121                 statusBarService);
122     }
123 
124     /** Provides an instance of {@link NotificationGutsManager} */
125     @SysUISingleton
126     @Provides
provideNotificationGutsManager( Context context, Lazy<StatusBar> statusBarLazy, @Main Handler mainHandler, @Background Handler bgHandler, AccessibilityManager accessibilityManager, HighPriorityProvider highPriorityProvider, INotificationManager notificationManager, NotificationEntryManager notificationEntryManager, PeopleSpaceWidgetManager peopleSpaceWidgetManager, LauncherApps launcherApps, ShortcutManager shortcutManager, ChannelEditorDialogController channelEditorDialogController, UserContextProvider contextTracker, AssistantFeedbackController assistantFeedbackController, Optional<BubblesManager> bubblesManagerOptional, UiEventLogger uiEventLogger, OnUserInteractionCallback onUserInteractionCallback, ShadeController shadeController)127     static NotificationGutsManager provideNotificationGutsManager(
128             Context context,
129             Lazy<StatusBar> statusBarLazy,
130             @Main Handler mainHandler,
131             @Background Handler bgHandler,
132             AccessibilityManager accessibilityManager,
133             HighPriorityProvider highPriorityProvider,
134             INotificationManager notificationManager,
135             NotificationEntryManager notificationEntryManager,
136             PeopleSpaceWidgetManager peopleSpaceWidgetManager,
137             LauncherApps launcherApps,
138             ShortcutManager shortcutManager,
139             ChannelEditorDialogController channelEditorDialogController,
140             UserContextProvider contextTracker,
141             AssistantFeedbackController assistantFeedbackController,
142             Optional<BubblesManager> bubblesManagerOptional,
143             UiEventLogger uiEventLogger,
144             OnUserInteractionCallback onUserInteractionCallback,
145             ShadeController shadeController) {
146         return new NotificationGutsManager(
147                 context,
148                 statusBarLazy,
149                 mainHandler,
150                 bgHandler,
151                 accessibilityManager,
152                 highPriorityProvider,
153                 notificationManager,
154                 notificationEntryManager,
155                 peopleSpaceWidgetManager,
156                 launcherApps,
157                 shortcutManager,
158                 channelEditorDialogController,
159                 contextTracker,
160                 assistantFeedbackController,
161                 bubblesManagerOptional,
162                 uiEventLogger,
163                 onUserInteractionCallback,
164                 shadeController);
165     }
166 
167     /** Provides an instance of {@link VisualStabilityManager} */
168     @SysUISingleton
169     @Provides
provideVisualStabilityManager( FeatureFlags featureFlags, NotificationEntryManager notificationEntryManager, Handler handler, StatusBarStateController statusBarStateController, WakefulnessLifecycle wakefulnessLifecycle)170     static VisualStabilityManager provideVisualStabilityManager(
171             FeatureFlags featureFlags,
172             NotificationEntryManager notificationEntryManager,
173             Handler handler,
174             StatusBarStateController statusBarStateController,
175             WakefulnessLifecycle wakefulnessLifecycle) {
176         return new VisualStabilityManager(
177                 notificationEntryManager,
178                 handler,
179                 statusBarStateController,
180                 wakefulnessLifecycle);
181     }
182 
183     /** Provides an instance of {@link NotificationLogger} */
184     @SysUISingleton
185     @Provides
provideNotificationLogger( NotificationListener notificationListener, @UiBackground Executor uiBgExecutor, NotificationEntryManager entryManager, StatusBarStateController statusBarStateController, NotificationLogger.ExpansionStateLogger expansionStateLogger, NotificationPanelLogger notificationPanelLogger)186     static NotificationLogger provideNotificationLogger(
187             NotificationListener notificationListener,
188             @UiBackground Executor uiBgExecutor,
189             NotificationEntryManager entryManager,
190             StatusBarStateController statusBarStateController,
191             NotificationLogger.ExpansionStateLogger expansionStateLogger,
192             NotificationPanelLogger notificationPanelLogger) {
193         return new NotificationLogger(
194                 notificationListener,
195                 uiBgExecutor,
196                 entryManager,
197                 statusBarStateController,
198                 expansionStateLogger,
199                 notificationPanelLogger);
200     }
201 
202     /** Provides an instance of {@link NotificationPanelLogger} */
203     @SysUISingleton
204     @Provides
provideNotificationPanelLogger()205     static NotificationPanelLogger provideNotificationPanelLogger() {
206         return new NotificationPanelLoggerImpl();
207     }
208 
209     /** Provides an instance of {@link GroupMembershipManager} */
210     @SysUISingleton
211     @Provides
provideGroupMembershipManager( FeatureFlags featureFlags, Lazy<NotificationGroupManagerLegacy> groupManagerLegacy)212     static GroupMembershipManager provideGroupMembershipManager(
213             FeatureFlags featureFlags,
214             Lazy<NotificationGroupManagerLegacy> groupManagerLegacy) {
215         return featureFlags.isNewNotifPipelineRenderingEnabled()
216                 ? new GroupMembershipManagerImpl()
217                 : groupManagerLegacy.get();
218     }
219 
220     /** Provides an instance of {@link GroupExpansionManager} */
221     @SysUISingleton
222     @Provides
provideGroupExpansionManager( FeatureFlags featureFlags, Lazy<GroupMembershipManager> groupMembershipManager, Lazy<NotificationGroupManagerLegacy> groupManagerLegacy)223     static GroupExpansionManager provideGroupExpansionManager(
224             FeatureFlags featureFlags,
225             Lazy<GroupMembershipManager> groupMembershipManager,
226             Lazy<NotificationGroupManagerLegacy> groupManagerLegacy) {
227         return featureFlags.isNewNotifPipelineRenderingEnabled()
228                 ? new GroupExpansionManagerImpl(groupMembershipManager.get())
229                 : groupManagerLegacy.get();
230     }
231 
232     /** Initializes the notification data pipeline (can be disabled via config). */
233     @SysUISingleton
234     @Provides
provideNotificationsController( Context context, Lazy<NotificationsControllerImpl> realController, Lazy<NotificationsControllerStub> stubController)235     static NotificationsController provideNotificationsController(
236             Context context,
237             Lazy<NotificationsControllerImpl> realController,
238             Lazy<NotificationsControllerStub> stubController) {
239         if (context.getResources().getBoolean(R.bool.config_renderNotifications)) {
240             return realController.get();
241         } else {
242             return stubController.get();
243         }
244     }
245 
246     /**
247      * Provide the active notification collection managing the notifications to render.
248      */
249     @Provides
250     @SysUISingleton
provideCommonNotifCollection( FeatureFlags featureFlags, Lazy<NotifPipeline> pipeline, NotificationEntryManager entryManager)251     static CommonNotifCollection provideCommonNotifCollection(
252             FeatureFlags featureFlags,
253             Lazy<NotifPipeline> pipeline,
254             NotificationEntryManager entryManager) {
255         return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager;
256     }
257 
258     /**
259      * Provide a dismissal callback that's triggered when a user manually dismissed a notification
260      * from the notification shade or it gets auto-cancelled by click.
261      */
262     @Provides
263     @SysUISingleton
provideOnUserInteractionCallback( FeatureFlags featureFlags, HeadsUpManager headsUpManager, StatusBarStateController statusBarStateController, Lazy<NotifPipeline> pipeline, Lazy<NotifCollection> notifCollection, Lazy<VisualStabilityCoordinator> visualStabilityCoordinator, NotificationEntryManager entryManager, VisualStabilityManager visualStabilityManager, Lazy<GroupMembershipManager> groupMembershipManagerLazy)264     static OnUserInteractionCallback provideOnUserInteractionCallback(
265             FeatureFlags featureFlags,
266             HeadsUpManager headsUpManager,
267             StatusBarStateController statusBarStateController,
268             Lazy<NotifPipeline> pipeline,
269             Lazy<NotifCollection> notifCollection,
270             Lazy<VisualStabilityCoordinator> visualStabilityCoordinator,
271             NotificationEntryManager entryManager,
272             VisualStabilityManager visualStabilityManager,
273             Lazy<GroupMembershipManager> groupMembershipManagerLazy) {
274         return featureFlags.isNewNotifPipelineRenderingEnabled()
275                 ? new OnUserInteractionCallbackImpl(
276                         pipeline.get(),
277                         notifCollection.get(),
278                         headsUpManager,
279                         statusBarStateController,
280                         visualStabilityCoordinator.get(),
281                         groupMembershipManagerLazy.get())
282                 : new OnUserInteractionCallbackImplLegacy(
283                         entryManager,
284                         headsUpManager,
285                         statusBarStateController,
286                         visualStabilityManager,
287                         groupMembershipManagerLazy.get());
288     }
289 
290     /** */
291     @Binds
bindNotificationInterruptStateProvider( NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl)292     NotificationInterruptStateProvider bindNotificationInterruptStateProvider(
293             NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl);
294 
295     /** */
296     @Binds
bindNotifInflater(NotifInflaterImpl notifInflaterImpl)297     NotifInflater bindNotifInflater(NotifInflaterImpl notifInflaterImpl);
298 }
299