1 /* 2 * Copyright (C) 2023 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.shade 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.log.LogBuffer 21 import com.android.systemui.log.LogBufferFactory 22 import com.android.systemui.plugins.qs.QSContainerController 23 import com.android.systemui.qs.ui.adapter.QSSceneAdapterImpl 24 import com.android.systemui.scene.shared.flag.SceneContainerFlag 25 import com.android.systemui.shade.carrier.ShadeCarrierGroupControllerLog 26 import com.android.systemui.shade.data.repository.PrivacyChipRepository 27 import com.android.systemui.shade.data.repository.PrivacyChipRepositoryImpl 28 import com.android.systemui.shade.data.repository.ShadeRepository 29 import com.android.systemui.shade.data.repository.ShadeRepositoryImpl 30 import com.android.systemui.shade.domain.interactor.BaseShadeInteractor 31 import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor 32 import com.android.systemui.shade.domain.interactor.PanelExpansionInteractorImpl 33 import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractor 34 import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractorLegacyImpl 35 import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractorSceneContainerImpl 36 import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor 37 import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractorImpl 38 import com.android.systemui.shade.domain.interactor.ShadeInteractor 39 import com.android.systemui.shade.domain.interactor.ShadeInteractorImpl 40 import com.android.systemui.shade.domain.interactor.ShadeInteractorLegacyImpl 41 import com.android.systemui.shade.domain.interactor.ShadeInteractorSceneContainerImpl 42 import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor 43 import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractorImpl 44 import dagger.Binds 45 import dagger.Module 46 import dagger.Provides 47 import javax.inject.Provider 48 49 /** Module for classes related to the notification shade. */ 50 @Module(includes = [StartShadeModule::class, ShadeViewProviderModule::class]) 51 abstract class ShadeModule { 52 companion object { 53 @Provides 54 @SysUISingleton provideBaseShadeInteractornull55 fun provideBaseShadeInteractor( 56 sceneContainerOn: Provider<ShadeInteractorSceneContainerImpl>, 57 sceneContainerOff: Provider<ShadeInteractorLegacyImpl> 58 ): BaseShadeInteractor { 59 return if (SceneContainerFlag.isEnabled) { 60 sceneContainerOn.get() 61 } else { 62 sceneContainerOff.get() 63 } 64 } 65 66 @Provides 67 @SysUISingleton provideShadeControllernull68 fun provideShadeController( 69 sceneContainerOn: Provider<ShadeControllerSceneImpl>, 70 sceneContainerOff: Provider<ShadeControllerImpl> 71 ): ShadeController { 72 return if (SceneContainerFlag.isEnabled) { 73 sceneContainerOn.get() 74 } else { 75 sceneContainerOff.get() 76 } 77 } 78 79 @Provides 80 @SysUISingleton provideShadeAnimationInteractornull81 fun provideShadeAnimationInteractor( 82 sceneContainerOn: Provider<ShadeAnimationInteractorSceneContainerImpl>, 83 sceneContainerOff: Provider<ShadeAnimationInteractorLegacyImpl> 84 ): ShadeAnimationInteractor { 85 return if (SceneContainerFlag.isEnabled) { 86 sceneContainerOn.get() 87 } else { 88 sceneContainerOff.get() 89 } 90 } 91 92 @Provides 93 @SysUISingleton provideShadeBackActionInteractornull94 fun provideShadeBackActionInteractor( 95 sceneContainerOn: Provider<ShadeBackActionInteractorImpl>, 96 sceneContainerOff: Provider<NotificationPanelViewController> 97 ): ShadeBackActionInteractor { 98 return if (SceneContainerFlag.isEnabled) { 99 sceneContainerOn.get() 100 } else { 101 sceneContainerOff.get() 102 } 103 } 104 105 @Provides 106 @SysUISingleton provideShadeLockscreenInteractornull107 fun provideShadeLockscreenInteractor( 108 sceneContainerOn: Provider<ShadeLockscreenInteractorImpl>, 109 sceneContainerOff: Provider<NotificationPanelViewController> 110 ): ShadeLockscreenInteractor { 111 return if (SceneContainerFlag.isEnabled) { 112 sceneContainerOn.get() 113 } else { 114 sceneContainerOff.get() 115 } 116 } 117 118 @Provides 119 @SysUISingleton providePanelExpansionInteractornull120 fun providePanelExpansionInteractor( 121 sceneContainerOn: Provider<PanelExpansionInteractorImpl>, 122 sceneContainerOff: Provider<NotificationPanelViewController> 123 ): PanelExpansionInteractor { 124 return if (SceneContainerFlag.isEnabled) { 125 sceneContainerOn.get() 126 } else { 127 sceneContainerOff.get() 128 } 129 } 130 131 @Provides 132 @SysUISingleton provideQuickSettingsControllernull133 fun provideQuickSettingsController( 134 sceneContainerOn: Provider<QuickSettingsControllerSceneImpl>, 135 sceneContainerOff: Provider<QuickSettingsControllerImpl>, 136 ): QuickSettingsController { 137 return if (SceneContainerFlag.isEnabled) { 138 sceneContainerOn.get() 139 } else { 140 sceneContainerOff.get() 141 } 142 } 143 144 @Provides 145 @SysUISingleton providesQSContainerControllernull146 fun providesQSContainerController(impl: QSSceneAdapterImpl): QSContainerController { 147 return impl 148 } 149 150 @Provides 151 @SysUISingleton 152 @ShadeCarrierGroupControllerLog provideShadeCarrierLognull153 fun provideShadeCarrierLog(factory: LogBufferFactory): LogBuffer { 154 return factory.create("ShadeCarrierGroupControllerLog", 400) 155 } 156 } 157 158 @Binds 159 @SysUISingleton bindsShadeRepositorynull160 abstract fun bindsShadeRepository(impl: ShadeRepositoryImpl): ShadeRepository 161 162 @Binds 163 @SysUISingleton 164 abstract fun bindsShadeInteractor(si: ShadeInteractorImpl): ShadeInteractor 165 166 @Binds 167 @SysUISingleton 168 abstract fun bindsShadeViewController(shadeSurface: ShadeSurface): ShadeViewController 169 170 @Binds 171 @SysUISingleton 172 abstract fun bindsPrivacyChipRepository(impl: PrivacyChipRepositoryImpl): PrivacyChipRepository 173 } 174