1 /* 2 * Copyright (C) 2019 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.dagger; 18 19 import static com.android.systemui.Dependency.ALLOW_NOTIFICATION_LONG_PRESS_NAME; 20 import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME; 21 22 import android.content.Context; 23 import android.hardware.SensorPrivacyManager; 24 import android.os.Handler; 25 26 import com.android.internal.logging.UiEventLogger; 27 import com.android.keyguard.KeyguardViewController; 28 import com.android.systemui.battery.BatterySaverModule; 29 import com.android.systemui.dagger.qualifiers.Main; 30 import com.android.systemui.dock.DockManager; 31 import com.android.systemui.dock.DockManagerImpl; 32 import com.android.systemui.doze.DozeHost; 33 import com.android.systemui.media.dagger.MediaModule; 34 import com.android.systemui.navigationbar.gestural.GestureModule; 35 import com.android.systemui.plugins.qs.QSFactory; 36 import com.android.systemui.plugins.statusbar.StatusBarStateController; 37 import com.android.systemui.power.dagger.PowerModule; 38 import com.android.systemui.qs.dagger.QSModule; 39 import com.android.systemui.qs.tileimpl.QSFactoryImpl; 40 import com.android.systemui.recents.Recents; 41 import com.android.systemui.recents.RecentsImplementation; 42 import com.android.systemui.rotationlock.RotationLockModule; 43 import com.android.systemui.screenshot.ReferenceScreenshotModule; 44 import com.android.systemui.settings.dagger.MultiUserUtilsModule; 45 import com.android.systemui.shade.NotificationShadeWindowControllerImpl; 46 import com.android.systemui.shade.ShadeExpansionStateManager; 47 import com.android.systemui.statusbar.CommandQueue; 48 import com.android.systemui.statusbar.KeyboardShortcutsModule; 49 import com.android.systemui.statusbar.NotificationLockscreenUserManager; 50 import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; 51 import com.android.systemui.statusbar.NotificationShadeWindowController; 52 import com.android.systemui.statusbar.dagger.StartCentralSurfacesModule; 53 import com.android.systemui.statusbar.events.StatusBarEventsModule; 54 import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; 55 import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; 56 import com.android.systemui.statusbar.phone.DozeServiceHost; 57 import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; 58 import com.android.systemui.statusbar.phone.KeyguardBypassController; 59 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 60 import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; 61 import com.android.systemui.statusbar.policy.AospPolicyModule; 62 import com.android.systemui.statusbar.policy.ConfigurationController; 63 import com.android.systemui.statusbar.policy.DeviceProvisionedController; 64 import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl; 65 import com.android.systemui.statusbar.policy.HeadsUpManager; 66 import com.android.systemui.statusbar.policy.HeadsUpManagerLogger; 67 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController; 68 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyControllerImpl; 69 import com.android.systemui.statusbar.policy.SensorPrivacyController; 70 import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl; 71 import com.android.systemui.volume.dagger.VolumeModule; 72 import com.android.systemui.wallpapers.dagger.WallpaperModule; 73 74 import dagger.Binds; 75 import dagger.Module; 76 import dagger.Provides; 77 78 import javax.inject.Named; 79 80 /** 81 * A dagger module for injecting default implementations of components of System UI. 82 * 83 * Variants of SystemUI should make a copy of this, include it in their component, and customize it 84 * as needed. 85 * 86 * This module might alternatively be named `AospSystemUIModule`, `PhoneSystemUIModule`, 87 * or `BasicSystemUIModule`. 88 * 89 * Nothing in the module should be strictly required. Each piece should either be swappable with 90 * a different implementation or entirely removable. 91 * 92 * This is different from {@link SystemUIModule} which should be used for pieces of required 93 * SystemUI code that variants of SystemUI _must_ include to function correctly. 94 */ 95 @Module(includes = { 96 AospPolicyModule.class, 97 BatterySaverModule.class, 98 GestureModule.class, 99 MediaModule.class, 100 MultiUserUtilsModule.class, 101 PowerModule.class, 102 QSModule.class, 103 ReferenceScreenshotModule.class, 104 RotationLockModule.class, 105 StatusBarEventsModule.class, 106 StartCentralSurfacesModule.class, 107 VolumeModule.class, 108 WallpaperModule.class, 109 KeyboardShortcutsModule.class 110 }) 111 public abstract class ReferenceSystemUIModule { 112 113 @SysUISingleton 114 @Provides 115 @Named(LEAK_REPORT_EMAIL_NAME) provideLeakReportEmail()116 static String provideLeakReportEmail() { 117 return ""; 118 } 119 120 @Binds bindNotificationLockscreenUserManager( NotificationLockscreenUserManagerImpl notificationLockscreenUserManager)121 abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager( 122 NotificationLockscreenUserManagerImpl notificationLockscreenUserManager); 123 124 @Provides 125 @SysUISingleton provideSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)126 static SensorPrivacyController provideSensorPrivacyController( 127 SensorPrivacyManager sensorPrivacyManager) { 128 SensorPrivacyController spC = new SensorPrivacyControllerImpl(sensorPrivacyManager); 129 spC.init(); 130 return spC; 131 } 132 133 @Provides 134 @SysUISingleton provideIndividualSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)135 static IndividualSensorPrivacyController provideIndividualSensorPrivacyController( 136 SensorPrivacyManager sensorPrivacyManager) { 137 IndividualSensorPrivacyController spC = new IndividualSensorPrivacyControllerImpl( 138 sensorPrivacyManager); 139 spC.init(); 140 return spC; 141 } 142 143 /** */ 144 @Binds 145 @SysUISingleton bindQSFactory(QSFactoryImpl qsFactoryImpl)146 public abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl); 147 148 @Binds bindDockManager(DockManagerImpl dockManager)149 abstract DockManager bindDockManager(DockManagerImpl dockManager); 150 151 @SysUISingleton 152 @Provides 153 @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) provideAllowNotificationLongPress()154 static boolean provideAllowNotificationLongPress() { 155 return true; 156 } 157 158 @SysUISingleton 159 @Provides provideHeadsUpManagerPhone( Context context, HeadsUpManagerLogger headsUpManagerLogger, StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupManager, VisualStabilityProvider visualStabilityProvider, ConfigurationController configurationController, @Main Handler handler, AccessibilityManagerWrapper accessibilityManagerWrapper, UiEventLogger uiEventLogger, ShadeExpansionStateManager shadeExpansionStateManager)160 static HeadsUpManagerPhone provideHeadsUpManagerPhone( 161 Context context, 162 HeadsUpManagerLogger headsUpManagerLogger, 163 StatusBarStateController statusBarStateController, 164 KeyguardBypassController bypassController, 165 GroupMembershipManager groupManager, 166 VisualStabilityProvider visualStabilityProvider, 167 ConfigurationController configurationController, 168 @Main Handler handler, 169 AccessibilityManagerWrapper accessibilityManagerWrapper, 170 UiEventLogger uiEventLogger, 171 ShadeExpansionStateManager shadeExpansionStateManager) { 172 return new HeadsUpManagerPhone( 173 context, 174 headsUpManagerLogger, 175 statusBarStateController, 176 bypassController, 177 groupManager, 178 visualStabilityProvider, 179 configurationController, 180 handler, 181 accessibilityManagerWrapper, 182 uiEventLogger, 183 shadeExpansionStateManager 184 ); 185 } 186 187 @Binds bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone)188 abstract HeadsUpManager bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone); 189 190 @Provides 191 @SysUISingleton provideRecents(Context context, RecentsImplementation recentsImplementation, CommandQueue commandQueue)192 static Recents provideRecents(Context context, RecentsImplementation recentsImplementation, 193 CommandQueue commandQueue) { 194 return new Recents(context, recentsImplementation, commandQueue); 195 } 196 197 @SysUISingleton 198 @Provides bindDeviceProvisionedController( DeviceProvisionedControllerImpl deviceProvisionedController)199 static DeviceProvisionedController bindDeviceProvisionedController( 200 DeviceProvisionedControllerImpl deviceProvisionedController) { 201 deviceProvisionedController.init(); 202 return deviceProvisionedController; 203 } 204 205 @Binds bindKeyguardViewController( StatusBarKeyguardViewManager statusBarKeyguardViewManager)206 abstract KeyguardViewController bindKeyguardViewController( 207 StatusBarKeyguardViewManager statusBarKeyguardViewManager); 208 209 @Binds bindNotificationShadeController( NotificationShadeWindowControllerImpl notificationShadeWindowController)210 abstract NotificationShadeWindowController bindNotificationShadeController( 211 NotificationShadeWindowControllerImpl notificationShadeWindowController); 212 213 @Binds provideDozeHost(DozeServiceHost dozeServiceHost)214 abstract DozeHost provideDozeHost(DozeServiceHost dozeServiceHost); 215 } 216