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.tv; 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.dagger.ReferenceSystemUIModule; 31 import com.android.systemui.dagger.SysUISingleton; 32 import com.android.systemui.dagger.qualifiers.Main; 33 import com.android.systemui.dock.DockManager; 34 import com.android.systemui.dock.DockManagerImpl; 35 import com.android.systemui.doze.DozeHost; 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.privacy.MediaProjectionPrivacyItemMonitor; 41 import com.android.systemui.privacy.PrivacyItemMonitor; 42 import com.android.systemui.qs.dagger.QSModule; 43 import com.android.systemui.qs.tileimpl.QSFactoryImpl; 44 import com.android.systemui.recents.Recents; 45 import com.android.systemui.recents.RecentsImplementation; 46 import com.android.systemui.screenshot.ReferenceScreenshotModule; 47 import com.android.systemui.shade.NotificationShadeWindowControllerImpl; 48 import com.android.systemui.shade.ShadeController; 49 import com.android.systemui.shade.ShadeControllerImpl; 50 import com.android.systemui.shade.ShadeExpansionStateManager; 51 import com.android.systemui.statusbar.CommandQueue; 52 import com.android.systemui.statusbar.NotificationListener; 53 import com.android.systemui.statusbar.NotificationLockscreenUserManager; 54 import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl; 55 import com.android.systemui.statusbar.NotificationShadeWindowController; 56 import com.android.systemui.statusbar.events.StatusBarEventsModule; 57 import com.android.systemui.statusbar.notification.collection.provider.VisualStabilityProvider; 58 import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager; 59 import com.android.systemui.statusbar.phone.DozeServiceHost; 60 import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; 61 import com.android.systemui.statusbar.phone.KeyguardBypassController; 62 import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; 63 import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper; 64 import com.android.systemui.statusbar.policy.AospPolicyModule; 65 import com.android.systemui.statusbar.policy.ConfigurationController; 66 import com.android.systemui.statusbar.policy.DeviceProvisionedController; 67 import com.android.systemui.statusbar.policy.DeviceProvisionedControllerImpl; 68 import com.android.systemui.statusbar.policy.HeadsUpManager; 69 import com.android.systemui.statusbar.policy.HeadsUpManagerLogger; 70 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController; 71 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyControllerImpl; 72 import com.android.systemui.statusbar.policy.SensorPrivacyController; 73 import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl; 74 import com.android.systemui.statusbar.tv.notifications.TvNotificationHandler; 75 import com.android.systemui.volume.dagger.VolumeModule; 76 77 import javax.inject.Named; 78 79 import dagger.Binds; 80 import dagger.Module; 81 import dagger.Provides; 82 import dagger.multibindings.IntoSet; 83 84 /** 85 * A TV specific version of {@link ReferenceSystemUIModule}. 86 * 87 * Code here should be specific to the TV variant of SystemUI and will not be included in other 88 * variants of SystemUI. 89 */ 90 @Module( 91 includes = { 92 AospPolicyModule.class, 93 GestureModule.class, 94 PowerModule.class, 95 QSModule.class, 96 ReferenceScreenshotModule.class, 97 StatusBarEventsModule.class, 98 VolumeModule.class, 99 } 100 ) 101 public abstract class TvSystemUIModule { 102 103 @SysUISingleton 104 @Provides 105 @Named(LEAK_REPORT_EMAIL_NAME) 106 @Nullable provideLeakReportEmail()107 static String provideLeakReportEmail() { 108 return null; 109 } 110 111 @Binds bindNotificationLockscreenUserManager( NotificationLockscreenUserManagerImpl notificationLockscreenUserManager)112 abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager( 113 NotificationLockscreenUserManagerImpl notificationLockscreenUserManager); 114 115 @Provides 116 @SysUISingleton provideSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)117 static SensorPrivacyController provideSensorPrivacyController( 118 SensorPrivacyManager sensorPrivacyManager) { 119 SensorPrivacyController spC = new SensorPrivacyControllerImpl(sensorPrivacyManager); 120 spC.init(); 121 return spC; 122 } 123 124 @Provides 125 @SysUISingleton provideIndividualSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)126 static IndividualSensorPrivacyController provideIndividualSensorPrivacyController( 127 SensorPrivacyManager sensorPrivacyManager) { 128 IndividualSensorPrivacyController spC = new IndividualSensorPrivacyControllerImpl( 129 sensorPrivacyManager); 130 spC.init(); 131 return spC; 132 } 133 134 @Binds 135 @SysUISingleton bindQSFactory(QSFactoryImpl qsFactoryImpl)136 abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl); 137 138 @Binds bindDockManager(DockManagerImpl dockManager)139 abstract DockManager bindDockManager(DockManagerImpl dockManager); 140 141 @Binds provideShadeController(ShadeControllerImpl shadeController)142 abstract ShadeController provideShadeController(ShadeControllerImpl shadeController); 143 144 @SysUISingleton 145 @Provides 146 @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) provideAllowNotificationLongPress()147 static boolean provideAllowNotificationLongPress() { 148 return true; 149 } 150 151 @SysUISingleton 152 @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)153 static HeadsUpManagerPhone provideHeadsUpManagerPhone( 154 Context context, 155 HeadsUpManagerLogger headsUpManagerLogger, 156 StatusBarStateController statusBarStateController, 157 KeyguardBypassController bypassController, 158 GroupMembershipManager groupManager, 159 VisualStabilityProvider visualStabilityProvider, 160 ConfigurationController configurationController, 161 @Main Handler handler, 162 AccessibilityManagerWrapper accessibilityManagerWrapper, 163 UiEventLogger uiEventLogger, 164 ShadeExpansionStateManager shadeExpansionStateManager) { 165 return new HeadsUpManagerPhone( 166 context, 167 headsUpManagerLogger, 168 statusBarStateController, 169 bypassController, 170 groupManager, 171 visualStabilityProvider, 172 configurationController, 173 handler, 174 accessibilityManagerWrapper, 175 uiEventLogger, 176 shadeExpansionStateManager 177 ); 178 } 179 180 @Binds bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone)181 abstract HeadsUpManager bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone); 182 183 @Provides 184 @SysUISingleton provideRecents(Context context, RecentsImplementation recentsImplementation, CommandQueue commandQueue)185 static Recents provideRecents(Context context, RecentsImplementation recentsImplementation, 186 CommandQueue commandQueue) { 187 return new Recents(context, recentsImplementation, commandQueue); 188 } 189 190 @SysUISingleton 191 @Provides providesDeviceProvisionedController( DeviceProvisionedControllerImpl deviceProvisionedController)192 static DeviceProvisionedController providesDeviceProvisionedController( 193 DeviceProvisionedControllerImpl deviceProvisionedController) { 194 deviceProvisionedController.init(); 195 return deviceProvisionedController; 196 } 197 198 @Binds bindKeyguardViewController( StatusBarKeyguardViewManager statusBarKeyguardViewManager)199 abstract KeyguardViewController bindKeyguardViewController( 200 StatusBarKeyguardViewManager statusBarKeyguardViewManager); 201 202 @Binds bindNotificationShadeController( NotificationShadeWindowControllerImpl notificationShadeWindowController)203 abstract NotificationShadeWindowController bindNotificationShadeController( 204 NotificationShadeWindowControllerImpl notificationShadeWindowController); 205 206 @Binds provideDozeHost(DozeServiceHost dozeServiceHost)207 abstract DozeHost provideDozeHost(DozeServiceHost dozeServiceHost); 208 209 @Provides 210 @SysUISingleton provideTvNotificationHandler( NotificationListener notificationListener)211 static TvNotificationHandler provideTvNotificationHandler( 212 NotificationListener notificationListener) { 213 return new TvNotificationHandler(notificationListener); 214 } 215 216 /** 217 * Binds {@link MediaProjectionPrivacyItemMonitor} into the set of {@link PrivacyItemMonitor}. 218 */ 219 @Binds 220 @IntoSet bindMediaProjectionPrivacyItemMonitor( MediaProjectionPrivacyItemMonitor mediaProjectionPrivacyItemMonitor)221 abstract PrivacyItemMonitor bindMediaProjectionPrivacyItemMonitor( 222 MediaProjectionPrivacyItemMonitor mediaProjectionPrivacyItemMonitor); 223 } 224