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