/* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.shade import android.os.UserHandle import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogBufferFactory import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractorPassThrough import com.android.systemui.shade.carrier.ShadeCarrierGroupControllerLog import com.android.systemui.shade.data.repository.PrivacyChipRepository import com.android.systemui.shade.data.repository.PrivacyChipRepositoryImpl import com.android.systemui.shade.data.repository.ShadeRepository import com.android.systemui.shade.data.repository.ShadeRepositoryImpl import com.android.systemui.shade.domain.interactor.BaseShadeInteractor import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.domain.interactor.PanelExpansionInteractorImpl import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractor import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractorLegacyImpl import com.android.systemui.shade.domain.interactor.ShadeAnimationInteractorSceneContainerImpl import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractorImpl import com.android.systemui.shade.domain.interactor.ShadeExpandedStateInteractor import com.android.systemui.shade.domain.interactor.ShadeExpandedStateInteractorImpl import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shade.domain.interactor.ShadeInteractorImpl import com.android.systemui.shade.domain.interactor.ShadeInteractorLegacyImpl import com.android.systemui.shade.domain.interactor.ShadeInteractorSceneContainerImpl import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractorImpl import com.android.systemui.shade.domain.interactor.ShadeModeInteractor import com.android.systemui.shade.domain.interactor.ShadeModeInteractorImpl import com.android.systemui.window.dagger.WindowRootViewBlurModule import dagger.Binds import dagger.Module import dagger.Provides import javax.inject.Provider /** Module for classes related to the notification shade. */ @Module( includes = [ StartShadeModule::class, ShadeViewProviderModule::class, WindowRootViewBlurModule::class, ShadeDisplayAwareWithShadeWindowModule::class, ] ) abstract class ShadeModule { companion object { @Provides @SysUISingleton fun provideBaseShadeInteractor( sceneContainerOn: Provider, sceneContainerOff: Provider, ): BaseShadeInteractor { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun provideShadeController( sceneContainerOn: Provider, sceneContainerOff: Provider, ): ShadeController { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun provideShadeAnimationInteractor( sceneContainerOn: Provider, sceneContainerOff: Provider, ): ShadeAnimationInteractor { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun provideShadeBackActionInteractor( sceneContainerOn: Provider, sceneContainerOff: Provider, ): ShadeBackActionInteractor { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun provideShadeLockscreenInteractor( sceneContainerOn: Provider, sceneContainerOff: Provider, ): ShadeLockscreenInteractor { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun providePanelExpansionInteractor( sceneContainerOn: Provider, sceneContainerOff: Provider, ): PanelExpansionInteractor { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun provideQuickSettingsController( sceneContainerOn: Provider, sceneContainerOff: Provider, ): QuickSettingsController { return if (SceneContainerFlag.isEnabled) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton fun providesBrightnessMirrorInteractor( sceneContainerOn: Provider, sceneContainerOff: Provider, ): BrightnessMirrorShowingInteractor { // Do not use NPVC if the user is not system. We don't want to create an NPVC in that // case. return if ( SceneContainerFlag.isEnabled || UserHandle.myUserId() != UserHandle.USER_SYSTEM ) { sceneContainerOn.get() } else { sceneContainerOff.get() } } @Provides @SysUISingleton @ShadeCarrierGroupControllerLog fun provideShadeCarrierLog(factory: LogBufferFactory): LogBuffer { return factory.create("ShadeCarrierGroupControllerLog", 400) } } @Binds @SysUISingleton abstract fun bindsShadeRepository(impl: ShadeRepositoryImpl): ShadeRepository @Binds @SysUISingleton abstract fun bindsShadeInteractor(si: ShadeInteractorImpl): ShadeInteractor @Binds @SysUISingleton abstract fun bindsShadeViewController(shadeSurface: ShadeSurface): ShadeViewController @Binds @SysUISingleton abstract fun bindsPrivacyChipRepository(impl: PrivacyChipRepositoryImpl): PrivacyChipRepository @Binds @SysUISingleton abstract fun bindShadeModeInteractor(impl: ShadeModeInteractorImpl): ShadeModeInteractor @Binds @SysUISingleton abstract fun bindShadeExpandedStateInteractor( impl: ShadeExpandedStateInteractorImpl ): ShadeExpandedStateInteractor }