1 /* 2 * Copyright (C) 2024 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.common.ui 18 19 import android.content.Context 20 import com.android.systemui.common.ui.data.repository.ConfigurationRepository 21 import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor 22 import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractorImpl 23 import com.android.systemui.dagger.SysUISingleton 24 import com.android.systemui.dagger.qualifiers.Main 25 import com.android.systemui.statusbar.policy.ConfigurationController 26 import dagger.Binds 27 import dagger.Module 28 import dagger.Provides 29 30 @Module 31 interface ConfigurationModule { 32 33 /** 34 * Deprecated: [ConfigurationState] should be injected only with the correct annotation. For 35 * now, without annotation the global config associated state is provided. 36 */ 37 @Binds 38 @Deprecated("Use the @Main annotated one instead of this.") provideGlobalConfigurationStatenull39 fun provideGlobalConfigurationState( 40 @Main configurationState: ConfigurationState 41 ): ConfigurationState 42 43 @Binds 44 @Deprecated("Use the @Main annotated one instead of this.") 45 fun provideDefaultConfigurationState( 46 @Main configurationState: ConfigurationInteractor 47 ): ConfigurationInteractor 48 49 companion object { 50 @SysUISingleton 51 @Provides 52 @Main 53 fun provideGlobalConfigurationState( 54 configStateFactory: ConfigurationStateImpl.Factory, 55 configurationController: ConfigurationController, 56 @Main context: Context, 57 ): ConfigurationState { 58 return configStateFactory.create(context, configurationController) 59 } 60 61 @SysUISingleton 62 @Provides 63 @Main 64 fun provideGlobalConfigurationInteractor( 65 configurationRepository: ConfigurationRepository 66 ): ConfigurationInteractor { 67 return ConfigurationInteractorImpl(configurationRepository) 68 } 69 } 70 } 71