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, 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 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 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)106 static NotificationGutsManager provideNotificationGutsManager( 107 Context context, 108 VisualStabilityManager visualStabilityManager, 109 Lazy<StatusBar> statusBarLazy, 110 @Main Handler mainHandler, 111 @Background Handler bgHandler, 112 AccessibilityManager accessibilityManager, 113 HighPriorityProvider highPriorityProvider, 114 INotificationManager notificationManager, 115 LauncherApps launcherApps, 116 ShortcutManager shortcutManager, 117 ChannelEditorDialogController channelEditorDialogController, 118 CurrentUserContextTracker contextTracker, 119 Provider<PriorityOnboardingDialogController.Builder> builderProvider, 120 BubbleController bubbleController, 121 UiEventLogger uiEventLogger) { 122 return new NotificationGutsManager( 123 context, 124 visualStabilityManager, 125 statusBarLazy, 126 mainHandler, 127 bgHandler, 128 accessibilityManager, 129 highPriorityProvider, 130 notificationManager, 131 launcherApps, 132 shortcutManager, 133 channelEditorDialogController, 134 contextTracker, 135 builderProvider, 136 bubbleController, 137 uiEventLogger); 138 } 139 140 /** Provides an instance of {@link VisualStabilityManager} */ 141 @Singleton 142 @Provides provideVisualStabilityManager( NotificationEntryManager notificationEntryManager, Handler handler)143 static VisualStabilityManager provideVisualStabilityManager( 144 NotificationEntryManager notificationEntryManager, Handler handler) { 145 return new VisualStabilityManager(notificationEntryManager, handler); 146 } 147 148 /** Provides an instance of {@link NotificationLogger} */ 149 @Singleton 150 @Provides provideNotificationLogger( NotificationListener notificationListener, @UiBackground Executor uiBgExecutor, NotificationEntryManager entryManager, StatusBarStateController statusBarStateController, NotificationLogger.ExpansionStateLogger expansionStateLogger, NotificationPanelLogger notificationPanelLogger)151 static NotificationLogger provideNotificationLogger( 152 NotificationListener notificationListener, 153 @UiBackground Executor uiBgExecutor, 154 NotificationEntryManager entryManager, 155 StatusBarStateController statusBarStateController, 156 NotificationLogger.ExpansionStateLogger expansionStateLogger, 157 NotificationPanelLogger notificationPanelLogger) { 158 return new NotificationLogger( 159 notificationListener, 160 uiBgExecutor, 161 entryManager, 162 statusBarStateController, 163 expansionStateLogger, 164 notificationPanelLogger); 165 } 166 167 /** Provides an instance of {@link NotificationPanelLogger} */ 168 @Singleton 169 @Provides provideNotificationPanelLogger()170 static NotificationPanelLogger provideNotificationPanelLogger() { 171 return new NotificationPanelLoggerImpl(); 172 } 173 174 /** Provides an instance of {@link NotificationBlockingHelperManager} */ 175 @Singleton 176 @Provides provideNotificationBlockingHelperManager( Context context, NotificationGutsManager notificationGutsManager, NotificationEntryManager notificationEntryManager, MetricsLogger metricsLogger)177 static NotificationBlockingHelperManager provideNotificationBlockingHelperManager( 178 Context context, 179 NotificationGutsManager notificationGutsManager, 180 NotificationEntryManager notificationEntryManager, 181 MetricsLogger metricsLogger) { 182 return new NotificationBlockingHelperManager( 183 context, notificationGutsManager, notificationEntryManager, metricsLogger); 184 } 185 186 /** Initializes the notification data pipeline (can be disabled via config). */ 187 @Singleton 188 @Provides provideNotificationsController( Context context, Lazy<NotificationsControllerImpl> realController, Lazy<NotificationsControllerStub> stubController)189 static NotificationsController provideNotificationsController( 190 Context context, 191 Lazy<NotificationsControllerImpl> realController, 192 Lazy<NotificationsControllerStub> stubController) { 193 if (context.getResources().getBoolean(R.bool.config_renderNotifications)) { 194 return realController.get(); 195 } else { 196 return stubController.get(); 197 } 198 } 199 200 /** 201 * Provide the active notification collection managing the notifications to render. 202 */ 203 @Provides 204 @Singleton provideCommonNotifCollection( FeatureFlags featureFlags, Lazy<NotifPipeline> pipeline, NotificationEntryManager entryManager)205 static CommonNotifCollection provideCommonNotifCollection( 206 FeatureFlags featureFlags, 207 Lazy<NotifPipeline> pipeline, 208 NotificationEntryManager entryManager) { 209 return featureFlags.isNewNotifPipelineRenderingEnabled() ? pipeline.get() : entryManager; 210 } 211 212 /** */ 213 @Binds bindNotificationInterruptStateProvider( NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl)214 NotificationInterruptStateProvider bindNotificationInterruptStateProvider( 215 NotificationInterruptStateProviderImpl notificationInterruptStateProviderImpl); 216 } 217