• 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.MetricsLogger;
27 import com.android.internal.logging.UiEventLogger;
28 import com.android.systemui.R;
29 import com.android.systemui.bubbles.BubbleController;
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.plugins.statusbar.StatusBarStateController;
34 import com.android.systemui.settings.CurrentUserContextTracker;
35 import com.android.systemui.statusbar.FeatureFlags;
36 import com.android.systemui.statusbar.NotificationListener;
37 import com.android.systemui.statusbar.NotificationRemoteInputManager;
38 import com.android.systemui.statusbar.notification.ForegroundServiceDismissalFeatureController;
39 import com.android.systemui.statusbar.notification.NotificationEntryManager;
40 import com.android.systemui.statusbar.notification.NotificationEntryManagerLogger;
41 import com.android.systemui.statusbar.notification.VisualStabilityManager;
42 import com.android.systemui.statusbar.notification.collection.NotifPipeline;
43 import com.android.systemui.statusbar.notification.collection.NotificationRankingManager;
44 import com.android.systemui.statusbar.notification.collection.inflation.NotificationRowBinder;
45 import com.android.systemui.statusbar.notification.collection.notifcollection.CommonNotifCollection;
46 import com.android.systemui.statusbar.notification.collection.provider.HighPriorityProvider;
47 import com.android.systemui.statusbar.notification.init.NotificationsController;
48 import com.android.systemui.statusbar.notification.init.NotificationsControllerImpl;
49 import com.android.systemui.statusbar.notification.init.NotificationsControllerStub;
50 import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProvider;
51 import com.android.systemui.statusbar.notification.interruption.NotificationInterruptStateProviderImpl;
52 import com.android.systemui.statusbar.notification.logging.NotificationLogger;
53 import com.android.systemui.statusbar.notification.logging.NotificationPanelLogger;
54 import com.android.systemui.statusbar.notification.logging.NotificationPanelLoggerImpl;
55 import com.android.systemui.statusbar.notification.row.ChannelEditorDialogController;
56 import com.android.systemui.statusbar.notification.row.NotificationBlockingHelperManager;
57 import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
58 import com.android.systemui.statusbar.notification.row.PriorityOnboardingDialogController;
59 import com.android.systemui.statusbar.phone.NotificationGroupManager;
60 import com.android.systemui.statusbar.phone.StatusBar;
61 import com.android.systemui.util.leak.LeakDetector;
62 
63 import java.util.concurrent.Executor;
64 
65 import javax.inject.Provider;
66 import javax.inject.Singleton;
67 
68 import dagger.Binds;
69 import dagger.Lazy;
70 import dagger.Module;
71 import dagger.Provides;
72 
73 /**
74  * Dagger Module for classes found within the com.android.systemui.statusbar.notification package.
75  */
76 @Module
77 public interface NotificationsModule {
78     /** Provides an instance of {@link NotificationEntryManager} */
79     @Singleton
80     @Provides
provideNotificationEntryManager( NotificationEntryManagerLogger logger, NotificationGroupManager groupManager, NotificationRankingManager rankingManager, NotificationEntryManager.KeyguardEnvironment keyguardEnvironment, FeatureFlags featureFlags, Lazy<NotificationRowBinder> notificationRowBinderLazy, Lazy<NotificationRemoteInputManager> notificationRemoteInputManagerLazy, LeakDetector leakDetector, Lazy<BubbleController> bubbleController, ForegroundServiceDismissalFeatureController fgsFeatureController)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             Lazy<BubbleController> bubbleController,
91             ForegroundServiceDismissalFeatureController fgsFeatureController) {
92         return new NotificationEntryManager(
93                 logger,
94                 groupManager,
95                 rankingManager,
96                 keyguardEnvironment,
97                 featureFlags,
98                 notificationRowBinderLazy,
99                 notificationRemoteInputManagerLazy,
100                 leakDetector,
101                 bubbleController,
102                 fgsFeatureController);
103     }
104 
105     /** Provides an instance of {@link NotificationGutsManager} */
106     @Singleton
107     @Provides
provideNotificationGutsManager( Context context, VisualStabilityManager visualStabilityManager, Lazy<StatusBar> statusBarLazy, @Main Handler mainHandler, @Background Handler bgHandler, AccessibilityManager accessibilityManager, HighPriorityProvider highPriorityProvider, INotificationManager notificationManager, LauncherApps launcherApps, ShortcutManager shortcutManager, ChannelEditorDialogController channelEditorDialogController, CurrentUserContextTracker contextTracker, Provider<PriorityOnboardingDialogController.Builder> builderProvider, BubbleController bubbleController, UiEventLogger uiEventLogger)108     static NotificationGutsManager provideNotificationGutsManager(
109             Context context,
110             VisualStabilityManager visualStabilityManager,
111             Lazy<StatusBar> statusBarLazy,
112             @Main Handler mainHandler,
113             @Background Handler bgHandler,
114             AccessibilityManager accessibilityManager,
115             HighPriorityProvider highPriorityProvider,
116             INotificationManager notificationManager,
117             LauncherApps launcherApps,
118             ShortcutManager shortcutManager,
119             ChannelEditorDialogController channelEditorDialogController,
120             CurrentUserContextTracker contextTracker,
121             Provider<PriorityOnboardingDialogController.Builder> builderProvider,
122             BubbleController bubbleController,
123             UiEventLogger uiEventLogger) {
124         return new NotificationGutsManager(
125                 context,
126                 visualStabilityManager,
127                 statusBarLazy,
128                 mainHandler,
129                 bgHandler,
130                 accessibilityManager,
131                 highPriorityProvider,
132                 notificationManager,
133                 launcherApps,
134                 shortcutManager,
135                 channelEditorDialogController,
136                 contextTracker,
137                 builderProvider,
138                 bubbleController,
139                 uiEventLogger);
140     }
141 
142     /** Provides an instance of {@link VisualStabilityManager} */
143     @Singleton
144     @Provides
provideVisualStabilityManager( NotificationEntryManager notificationEntryManager, Handler handler)145     static VisualStabilityManager provideVisualStabilityManager(
146             NotificationEntryManager notificationEntryManager, Handler handler) {
147         return new VisualStabilityManager(notificationEntryManager, handler);
148     }
149 
150     /** Provides an instance of {@link NotificationLogger} */
151     @Singleton
152     @Provides
provideNotificationLogger( NotificationListener notificationListener, @UiBackground Executor uiBgExecutor, NotificationEntryManager entryManager, StatusBarStateController statusBarStateController, NotificationLogger.ExpansionStateLogger expansionStateLogger, NotificationPanelLogger notificationPanelLogger)153     static NotificationLogger provideNotificationLogger(
154             NotificationListener notificationListener,
155             @UiBackground Executor uiBgExecutor,
156             NotificationEntryManager entryManager,
157             StatusBarStateController statusBarStateController,
158             NotificationLogger.ExpansionStateLogger expansionStateLogger,
159             NotificationPanelLogger notificationPanelLogger) {
160         return new NotificationLogger(
161                 notificationListener,
162                 uiBgExecutor,
163                 entryManager,
164                 statusBarStateController,
165                 expansionStateLogger,
166                 notificationPanelLogger);
167     }
168 
169     /** Provides an instance of {@link NotificationPanelLogger} */
170     @Singleton
171     @Provides
provideNotificationPanelLogger()172     static NotificationPanelLogger provideNotificationPanelLogger() {
173         return new NotificationPanelLoggerImpl();
174     }
175 
176     /** Provides an instance of {@link NotificationBlockingHelperManager} */
177     @Singleton
178     @Provides
provideNotificationBlockingHelperManager( Context context, NotificationGutsManager notificationGutsManager, NotificationEntryManager notificationEntryManager, MetricsLogger metricsLogger)179     static NotificationBlockingHelperManager provideNotificationBlockingHelperManager(
180             Context context,
181             NotificationGutsManager notificationGutsManager,
182             NotificationEntryManager notificationEntryManager,
183             MetricsLogger metricsLogger) {
184         return new NotificationBlockingHelperManager(
185                 context, notificationGutsManager, notificationEntryManager, metricsLogger);
186     }
187 
188     /** Initializes the notification data pipeline (can be disabled via config). */
189     @Singleton
190     @Provides
provideNotificationsController( Context context, Lazy<NotificationsControllerImpl> realController, Lazy<NotificationsControllerStub> stubController)191     static NotificationsController provideNotificationsController(
192             Context context,
193             Lazy<NotificationsControllerImpl> realController,
194             Lazy<NotificationsControllerStub> stubController) {
195         if (context.getResources().getBoolean(R.bool.config_renderNotifications)) {
196             return realController.get();
197         } else {
198             return stubController.get();
199         }
200     }
201 
202     /**
203      * Provide the active notification collection managing the notifications to render.
204      */
205     @Provides
206     @Singleton
provideCommonNotifCollection( FeatureFlags featureFlags, Lazy<NotifPipeline> pipeline, NotificationEntryManager entryManager)207     static CommonNotifCollection provideCommonNotifCollection(
208             FeatureFlags featureFlags,
209             Lazy<NotifPipeline> pipeline,
210             NotificationEntryManager entryManager) {
211         return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager;
212     }
213 
214     /** */
215     @Binds
bindNotificationInterruptStateProvider( NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl)216     NotificationInterruptStateProvider bindNotificationInterruptStateProvider(
217             NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl);
218 }
219