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;
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 import android.os.PowerManager;
26 import android.window.DisplayAreaOrganizer;
27 
28 import com.android.keyguard.KeyguardViewController;
29 import com.android.systemui.broadcast.BroadcastDispatcher;
30 import com.android.systemui.car.CarDeviceProvisionedController;
31 import com.android.systemui.car.CarDeviceProvisionedControllerImpl;
32 import com.android.systemui.car.keyguard.CarKeyguardViewController;
33 import com.android.systemui.car.notification.NotificationShadeWindowControllerImpl;
34 import com.android.systemui.car.privacy.MicPrivacyElementsProviderImpl;
35 import com.android.systemui.car.privacy.MicQcPanel;
36 import com.android.systemui.car.statusbar.DozeServiceHost;
37 import com.android.systemui.car.volume.CarVolumeModule;
38 import com.android.systemui.dagger.GlobalRootComponent;
39 import com.android.systemui.dagger.SysUISingleton;
40 import com.android.systemui.dagger.qualifiers.Background;
41 import com.android.systemui.dagger.qualifiers.Main;
42 import com.android.systemui.demomode.DemoModeController;
43 import com.android.systemui.dock.DockManager;
44 import com.android.systemui.dock.DockManagerImpl;
45 import com.android.systemui.doze.DozeHost;
46 import com.android.systemui.plugins.qs.QSFactory;
47 import com.android.systemui.plugins.statusbar.StatusBarStateController;
48 import com.android.systemui.power.EnhancedEstimates;
49 import com.android.systemui.power.EnhancedEstimatesImpl;
50 import com.android.systemui.power.dagger.PowerModule;
51 import com.android.systemui.qs.dagger.QSModule;
52 import com.android.systemui.qs.tileimpl.QSFactoryImpl;
53 import com.android.systemui.recents.Recents;
54 import com.android.systemui.recents.RecentsImplementation;
55 import com.android.systemui.statusbar.CommandQueue;
56 import com.android.systemui.statusbar.NotificationLockscreenUserManager;
57 import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
58 import com.android.systemui.statusbar.NotificationShadeWindowController;
59 import com.android.systemui.statusbar.notification.NotificationEntryManager;
60 import com.android.systemui.statusbar.notification.collection.render.GroupMembershipManager;
61 import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
62 import com.android.systemui.statusbar.phone.KeyguardBypassController;
63 import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
64 import com.android.systemui.statusbar.phone.ShadeController;
65 import com.android.systemui.statusbar.phone.ShadeControllerImpl;
66 import com.android.systemui.statusbar.policy.BatteryController;
67 import com.android.systemui.statusbar.policy.BatteryControllerImpl;
68 import com.android.systemui.statusbar.policy.ConfigurationController;
69 import com.android.systemui.statusbar.policy.DeviceProvisionedController;
70 import com.android.systemui.statusbar.policy.HeadsUpManager;
71 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyController;
72 import com.android.systemui.statusbar.policy.IndividualSensorPrivacyControllerImpl;
73 import com.android.systemui.statusbar.policy.SensorPrivacyController;
74 import com.android.systemui.statusbar.policy.SensorPrivacyControllerImpl;
75 
76 import java.util.concurrent.Executor;
77 
78 import javax.inject.Named;
79 
80 import dagger.Binds;
81 import dagger.Module;
82 import dagger.Provides;
83 
84 @Module(
85         includes = {
86                 PowerModule.class,
87                 QSModule.class,
88                 CarVolumeModule.class
89         })
90 abstract class CarSystemUIModule {
91 
92     @SysUISingleton
93     @Provides
94     @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME)
provideAllowNotificationLongPress()95     static boolean provideAllowNotificationLongPress() {
96         return false;
97     }
98 
99     @SysUISingleton
100     @Provides
provideHeadsUpManagerPhone( Context context, StatusBarStateController statusBarStateController, KeyguardBypassController bypassController, GroupMembershipManager groupManager, ConfigurationController configurationController)101     static HeadsUpManagerPhone provideHeadsUpManagerPhone(
102             Context context,
103             StatusBarStateController statusBarStateController,
104             KeyguardBypassController bypassController,
105             GroupMembershipManager groupManager,
106             ConfigurationController configurationController) {
107         return new HeadsUpManagerPhone(context, statusBarStateController, bypassController,
108                 groupManager, configurationController);
109     }
110 
111     @SysUISingleton
112     @Provides
113     @Named(LEAK_REPORT_EMAIL_NAME)
provideLeakReportEmail()114     static String provideLeakReportEmail() {
115         return "buganizer-system+181579@google.com";
116     }
117 
118     @Provides
119     @SysUISingleton
provideRecents(Context context, RecentsImplementation recentsImplementation, CommandQueue commandQueue)120     static Recents provideRecents(Context context, RecentsImplementation recentsImplementation,
121             CommandQueue commandQueue) {
122         return new Recents(context, recentsImplementation, commandQueue);
123     }
124 
125     @Provides
126     @SysUISingleton
provideDisplayAreaOrganizer(@ain Executor executor)127     static DisplayAreaOrganizer provideDisplayAreaOrganizer(@Main Executor executor) {
128         return new DisplayAreaOrganizer(executor);
129     }
130 
131     @Binds
bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone)132     abstract HeadsUpManager bindHeadsUpManagerPhone(HeadsUpManagerPhone headsUpManagerPhone);
133 
134     @Binds
bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates)135     abstract EnhancedEstimates bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates);
136 
137     @Binds
bindNotificationLockscreenUserManager( NotificationLockscreenUserManagerImpl notificationLockscreenUserManager)138     abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager(
139             NotificationLockscreenUserManagerImpl notificationLockscreenUserManager);
140 
141     @Provides
142     @SysUISingleton
provideBatteryController(Context context, EnhancedEstimates enhancedEstimates, PowerManager powerManager, BroadcastDispatcher broadcastDispatcher, DemoModeController demoModeController, @Main Handler mainHandler, @Background Handler bgHandler)143     static BatteryController provideBatteryController(Context context,
144             EnhancedEstimates enhancedEstimates, PowerManager powerManager,
145             BroadcastDispatcher broadcastDispatcher, DemoModeController demoModeController,
146             @Main Handler mainHandler,
147             @Background Handler bgHandler) {
148         BatteryController bC = new BatteryControllerImpl(context, enhancedEstimates, powerManager,
149                 broadcastDispatcher, demoModeController, mainHandler, bgHandler);
150         bC.init();
151         return bC;
152     }
153 
154     @Provides
155     @SysUISingleton
provideSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)156     static SensorPrivacyController provideSensorPrivacyController(
157             SensorPrivacyManager sensorPrivacyManager) {
158         SensorPrivacyController spC = new SensorPrivacyControllerImpl(sensorPrivacyManager);
159         spC.init();
160         return spC;
161     }
162 
163     @Provides
164     @SysUISingleton
provideIndividualSensorPrivacyController( SensorPrivacyManager sensorPrivacyManager)165     static IndividualSensorPrivacyController provideIndividualSensorPrivacyController(
166             SensorPrivacyManager sensorPrivacyManager) {
167         IndividualSensorPrivacyController spC = new IndividualSensorPrivacyControllerImpl(
168                 sensorPrivacyManager);
169         spC.init();
170         return spC;
171     }
172 
173     @Binds
174     @SysUISingleton
bindQSFactory(QSFactoryImpl qsFactoryImpl)175     public abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl);
176 
177     @Binds
bindDockManager(DockManagerImpl dockManager)178     abstract DockManager bindDockManager(DockManagerImpl dockManager);
179 
180     @Binds
bindKeyguardEnvironment( KeyguardEnvironmentImpl keyguardEnvironment)181     abstract NotificationEntryManager.KeyguardEnvironment bindKeyguardEnvironment(
182             KeyguardEnvironmentImpl keyguardEnvironment);
183 
184     @Binds
provideShadeController(ShadeControllerImpl shadeController)185     abstract ShadeController provideShadeController(ShadeControllerImpl shadeController);
186 
187     @Binds
bindGlobalRootComponent( CarGlobalRootComponent globalRootComponent)188     abstract GlobalRootComponent bindGlobalRootComponent(
189             CarGlobalRootComponent globalRootComponent);
190 
191     @Binds
bindKeyguardViewController( CarKeyguardViewController carKeyguardViewController)192     abstract KeyguardViewController bindKeyguardViewController(
193             CarKeyguardViewController carKeyguardViewController);
194 
195     @Binds
bindNotificationShadeController( NotificationShadeWindowControllerImpl notificationPanelViewController)196     abstract NotificationShadeWindowController bindNotificationShadeController(
197             NotificationShadeWindowControllerImpl notificationPanelViewController);
198 
199     @Provides
bindDeviceProvisionedController( CarDeviceProvisionedControllerImpl deviceProvisionedController)200     static DeviceProvisionedController bindDeviceProvisionedController(
201             CarDeviceProvisionedControllerImpl deviceProvisionedController) {
202         deviceProvisionedController.init();
203         return deviceProvisionedController;
204     };
205 
206     @Binds
bindCarDeviceProvisionedController( CarDeviceProvisionedControllerImpl deviceProvisionedController)207     abstract CarDeviceProvisionedController bindCarDeviceProvisionedController(
208             CarDeviceProvisionedControllerImpl deviceProvisionedController);
209 
210     @Binds
bindDozeHost(DozeServiceHost dozeServiceHost)211     abstract DozeHost bindDozeHost(DozeServiceHost dozeServiceHost);
212 
213     @Binds
bindMicPrivacyElementsProvider( MicPrivacyElementsProviderImpl micPrivacyElementsProvider)214     abstract MicQcPanel.MicPrivacyElementsProvider bindMicPrivacyElementsProvider(
215             MicPrivacyElementsProviderImpl micPrivacyElementsProvider);
216 }
217