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 25 import com.android.keyguard.KeyguardViewController; 26 import com.android.systemui.CoreStartable; 27 import com.android.systemui.ScreenDecorationsModule; 28 import com.android.systemui.accessibility.SystemActionsModule; 29 import com.android.systemui.battery.BatterySaverModule; 30 import com.android.systemui.display.ui.viewmodel.ConnectingDisplayViewModel; 31 import com.android.systemui.dock.DockManager; 32 import com.android.systemui.dock.DockManagerImpl; 33 import com.android.systemui.doze.DozeHost; 34 import com.android.systemui.keyboard.shortcut.ShortcutHelperModule; 35 import com.android.systemui.keyguard.ui.composable.blueprint.DefaultBlueprintModule; 36 import com.android.systemui.keyguard.ui.view.layout.blueprints.KeyguardBlueprintModule; 37 import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule; 38 import com.android.systemui.media.dagger.MediaModule; 39 import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionCli; 40 import com.android.systemui.media.nearby.NearbyMediaDevicesManager; 41 import com.android.systemui.navigationbar.NavigationBarControllerModule; 42 import com.android.systemui.navigationbar.gestural.GestureModule; 43 import com.android.systemui.plugins.qs.QSFactory; 44 import com.android.systemui.power.dagger.PowerModule; 45 import com.android.systemui.qs.dagger.QSModule; 46 import com.android.systemui.qs.tileimpl.QSFactoryImpl; 47 import com.android.systemui.reardisplay.RearDisplayModule; 48 import com.android.systemui.recents.Recents; 49 import com.android.systemui.recents.RecentsImplementation; 50 import com.android.systemui.rotationlock.RotationLockModule; 51 import com.android.systemui.rotationlock.RotationLockNewModule; 52 import com.android.systemui.scene.SceneContainerFrameworkModule; 53 import com.android.systemui.screenshot.ReferenceScreenshotModule; 54 import com.android.systemui.settings.MultiUserUtilsModule; 55 import com.android.systemui.shade.NotificationShadeWindowControllerImpl; 56 import com.android.systemui.shade.ShadeModule; 57 import com.android.systemui.startable.Dependencies; 58 import com.android.systemui.statusbar.CommandQueue; 59 import com.android.systemui.statusbar.KeyboardShortcutsModule; 60 import com.android.systemui.statusbar.NotificationLockscreenUserManager; 61 import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; 62 import com.android.systemui.statusbar.NotificationShadeWindowController; 63 import com.android.systemui.statusbar.SysuiStatusBarStateController; 64 import com.android.systemui.statusbar.dagger.StartCentralSurfacesModule; 65 import com.android.systemui.statusbar.phone.CentralSurfaces; 66 import com.android.systemui.statusbar.phone.DozeServiceHost; 67 import com.android.systemui.statusbar.phone.HeadsUpModule; 68 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 69 import com.android.systemui.statusbar.phone.fragment.CollapsedStatusBarFragmentStartableModule; 70 import com.android.systemui.statusbar.policy.AospPolicyModule; 71 import com.android.systemui.statusbar.policy.DeviceProvisionedController; 72 import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl; 73 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController; 74 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyControllerImpl; 75 import com.android.systemui.statusbar.policy.SensorPrivacyController; 76 import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl; 77 import com.android.systemui.toast.ToastModule; 78 import com.android.systemui.unfold.SysUIUnfoldStartableModule; 79 import com.android.systemui.unfold.UnfoldTransitionModule; 80 import com.android.systemui.util.kotlin.SysUICoroutinesModule; 81 import com.android.systemui.volume.dagger.VolumeModule; 82 import com.android.systemui.wallpapers.dagger.WallpaperModule; 83 84 import dagger.Binds; 85 import dagger.Module; 86 import dagger.Provides; 87 import dagger.multibindings.ClassKey; 88 import dagger.multibindings.IntoMap; 89 90 import java.util.Set; 91 92 import javax.inject.Named; 93 94 /** 95 * A dagger module for injecting default implementations of components of System UI. 96 * 97 * Variants of SystemUI should make a copy of this, include it in their component, and customize it 98 * as needed. 99 * 100 * This module might alternatively be named `AospSystemUIModule`, `PhoneSystemUIModule`, 101 * or `BasicSystemUIModule`. 102 * 103 * Nothing in the module should be strictly required. Each piece should either be swappable with 104 * a different implementation or entirely removable. 105 * 106 * This is different from {@link SystemUIModule} which should be used for pieces of required 107 * SystemUI code that variants of SystemUI _must_ include to function correctly. 108 */ 109 @Module(includes = { 110 AospPolicyModule.class, 111 BatterySaverModule.class, 112 CollapsedStatusBarFragmentStartableModule.class, 113 ConnectingDisplayViewModel.StartableModule.class, 114 DefaultBlueprintModule.class, 115 GestureModule.class, 116 HeadsUpModule.class, 117 KeyboardShortcutsModule.class, 118 KeyguardBlueprintModule.class, 119 KeyguardSectionsModule.class, 120 MediaModule.class, 121 MediaMuteAwaitConnectionCli.StartableModule.class, 122 MultiUserUtilsModule.class, 123 NavigationBarControllerModule.class, 124 NearbyMediaDevicesManager.StartableModule.class, 125 PowerModule.class, 126 QSModule.class, 127 RearDisplayModule.class, 128 ReferenceScreenshotModule.class, 129 RotationLockModule.class, 130 RotationLockNewModule.class, 131 ScreenDecorationsModule.class, 132 SystemActionsModule.class, 133 ShadeModule.class, 134 StartCentralSurfacesModule.class, 135 SceneContainerFrameworkModule.class, 136 SysUICoroutinesModule.class, 137 SysUIUnfoldStartableModule.class, 138 UnfoldTransitionModule.Startables.class, 139 ToastModule.class, 140 VolumeModule.class, 141 WallpaperModule.class, 142 ShortcutHelperModule.class, 143 }) 144 public abstract class ReferenceSystemUIModule { 145 146 @SysUISingleton 147 @Provides 148 @Named(LEAK_REPORT_EMAIL_NAME) provideLeakReportEmail()149 static String provideLeakReportEmail() { 150 return ""; 151 } 152 153 @Binds bindNotificationLockscreenUserManager( NotificationLockscreenUserManagerImpl notificationLockscreenUserManager)154 abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager( 155 NotificationLockscreenUserManagerImpl notificationLockscreenUserManager); 156 157 @Provides 158 @SysUISingleton provideSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)159 static SensorPrivacyController provideSensorPrivacyController( 160 SensorPrivacyManager sensorPrivacyManager) { 161 SensorPrivacyController spC = new SensorPrivacyControllerImpl(sensorPrivacyManager); 162 spC.init(); 163 return spC; 164 } 165 166 @Provides 167 @SysUISingleton provideIndividualSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)168 static IndividualSensorPrivacyController provideIndividualSensorPrivacyController( 169 SensorPrivacyManager sensorPrivacyManager) { 170 IndividualSensorPrivacyController spC = new IndividualSensorPrivacyControllerImpl( 171 sensorPrivacyManager); 172 spC.init(); 173 return spC; 174 } 175 176 /** */ 177 @Binds 178 @SysUISingleton bindQSFactory(QSFactoryImpl qsFactoryImpl)179 public abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl); 180 181 @Binds bindDockManager(DockManagerImpl dockManager)182 abstract DockManager bindDockManager(DockManagerImpl dockManager); 183 184 @SysUISingleton 185 @Provides 186 @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) provideAllowNotificationLongPress()187 static boolean provideAllowNotificationLongPress() { 188 return true; 189 } 190 191 @Provides 192 @SysUISingleton provideRecents(Context context, RecentsImplementation recentsImplementation, CommandQueue commandQueue)193 static Recents provideRecents(Context context, RecentsImplementation recentsImplementation, 194 CommandQueue commandQueue) { 195 return new Recents(context, recentsImplementation, commandQueue); 196 } 197 198 @SysUISingleton 199 @Provides bindDeviceProvisionedController( DeviceProvisionedControllerImpl deviceProvisionedController)200 static DeviceProvisionedController bindDeviceProvisionedController( 201 DeviceProvisionedControllerImpl deviceProvisionedController) { 202 deviceProvisionedController.init(); 203 return deviceProvisionedController; 204 } 205 206 @Binds bindKeyguardViewController( StatusBarKeyguardViewManager statusBarKeyguardViewManager)207 abstract KeyguardViewController bindKeyguardViewController( 208 StatusBarKeyguardViewManager statusBarKeyguardViewManager); 209 210 @Binds bindNotificationShadeController( NotificationShadeWindowControllerImpl notificationShadeWindowController)211 abstract NotificationShadeWindowController bindNotificationShadeController( 212 NotificationShadeWindowControllerImpl notificationShadeWindowController); 213 214 @Binds provideDozeHost(DozeServiceHost dozeServiceHost)215 abstract DozeHost provideDozeHost(DozeServiceHost dozeServiceHost); 216 217 /** */ 218 @Provides 219 @IntoMap 220 @Dependencies 221 @ClassKey(SysuiStatusBarStateController.class) providesStatusBarStateControllerDeps()222 static Set<Class<? extends CoreStartable>> providesStatusBarStateControllerDeps() { 223 return Set.of(CentralSurfaces.class); 224 } 225 } 226