1 /*
2  * Copyright (C) 2020 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.qs.dagger;
18 
19 import static com.android.systemui.qs.dagger.QSFlagsModule.RBC_AVAILABLE;
20 
21 import android.content.Context;
22 import android.os.Handler;
23 
24 import com.android.systemui.dagger.NightDisplayListenerModule;
25 import com.android.systemui.dagger.SysUISingleton;
26 import com.android.systemui.dagger.qualifiers.Background;
27 import com.android.systemui.media.dagger.MediaModule;
28 import com.android.systemui.qs.AutoAddTracker;
29 import com.android.systemui.qs.QSHost;
30 import com.android.systemui.qs.ReduceBrightColorsController;
31 import com.android.systemui.qs.ReduceBrightColorsControllerImpl;
32 import com.android.systemui.qs.external.QSExternalModule;
33 import com.android.systemui.qs.panels.dagger.PanelsModule;
34 import com.android.systemui.qs.pipeline.dagger.QSPipelineModule;
35 import com.android.systemui.qs.tileimpl.QSTileImpl;
36 import com.android.systemui.qs.tiles.di.QSTilesModule;
37 import com.android.systemui.qs.ui.adapter.QSSceneAdapter;
38 import com.android.systemui.qs.ui.adapter.QSSceneAdapterImpl;
39 import com.android.systemui.statusbar.phone.AutoTileManager;
40 import com.android.systemui.statusbar.phone.ManagedProfileController;
41 import com.android.systemui.statusbar.policy.CastController;
42 import com.android.systemui.statusbar.policy.DataSaverController;
43 import com.android.systemui.statusbar.policy.DeviceControlsController;
44 import com.android.systemui.statusbar.policy.HotspotController;
45 import com.android.systemui.statusbar.policy.SafetyController;
46 import com.android.systemui.statusbar.policy.WalletController;
47 import com.android.systemui.util.settings.SecureSettings;
48 
49 import dagger.Binds;
50 import dagger.Module;
51 import dagger.Provides;
52 import dagger.multibindings.Multibinds;
53 
54 import java.util.Map;
55 
56 import javax.inject.Named;
57 
58 /**
59  * Module for QS dependencies
60  */
61 @Module(subcomponents = {QSFragmentComponent.class, QSSceneComponent.class},
62         includes = {
63                 MediaModule.class,
64                 PanelsModule.class,
65                 QSExternalModule.class,
66                 QSFlagsModule.class,
67                 QSHostModule.class,
68                 QSPipelineModule.class,
69                 QSTilesModule.class,
70         }
71 )
72 public interface QSModule {
73 
74     /**
75      * A map of internal QS tiles. Ensures that this can be injected even if
76      * it is empty
77      */
78     @Multibinds
tileMap()79     Map<String, QSTileImpl<?>> tileMap();
80 
81     @Provides
82     @SysUISingleton
provideAutoTileManager( Context context, AutoAddTracker.Builder autoAddTrackerBuilder, QSHost host, @Background Handler handler, SecureSettings secureSettings, HotspotController hotspotController, DataSaverController dataSaverController, ManagedProfileController managedProfileController, NightDisplayListenerModule.Builder nightDisplayListenerBuilder, CastController castController, ReduceBrightColorsController reduceBrightColorsController, DeviceControlsController deviceControlsController, WalletController walletController, SafetyController safetyController, @Named(RBC_AVAILABLE) boolean isReduceBrightColorsAvailable)83     static AutoTileManager provideAutoTileManager(
84             Context context,
85             AutoAddTracker.Builder autoAddTrackerBuilder,
86             QSHost host,
87             @Background Handler handler,
88             SecureSettings secureSettings,
89             HotspotController hotspotController,
90             DataSaverController dataSaverController,
91             ManagedProfileController managedProfileController,
92             NightDisplayListenerModule.Builder nightDisplayListenerBuilder,
93             CastController castController,
94             ReduceBrightColorsController reduceBrightColorsController,
95             DeviceControlsController deviceControlsController,
96             WalletController walletController,
97             SafetyController safetyController,
98             @Named(RBC_AVAILABLE) boolean isReduceBrightColorsAvailable) {
99         AutoTileManager manager = new AutoTileManager(
100                 context,
101                 autoAddTrackerBuilder,
102                 host,
103                 handler,
104                 secureSettings,
105                 hotspotController,
106                 dataSaverController,
107                 managedProfileController,
108                 nightDisplayListenerBuilder,
109                 castController,
110                 reduceBrightColorsController,
111                 deviceControlsController,
112                 walletController,
113                 safetyController,
114                 isReduceBrightColorsAvailable
115         );
116         manager.init();
117         return manager;
118     }
119 
120     @Binds
bindsQsSceneInteractor(QSSceneAdapterImpl impl)121     QSSceneAdapter bindsQsSceneInteractor(QSSceneAdapterImpl impl);
122 
123     /**
124      * Dims the screen
125      */
126     @Binds
bindReduceBrightColorsController( ReduceBrightColorsControllerImpl impl)127     ReduceBrightColorsController bindReduceBrightColorsController(
128             ReduceBrightColorsControllerImpl impl);
129 }
130