1 /* <lambda>null2 * 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.statusbar.notification.data 18 19 import com.android.app.tracing.coroutines.launchTraced as launch 20 import com.android.systemui.CoreStartable 21 import com.android.systemui.dagger.SysUISingleton 22 import com.android.systemui.dagger.qualifiers.Application 23 import com.android.systemui.dagger.qualifiers.Background 24 import com.android.systemui.settings.UserSettingsRepositoryModule 25 import com.android.systemui.shared.notifications.data.repository.NotificationSettingsRepository 26 import com.android.systemui.shared.settings.data.repository.SecureSettingsRepository 27 import com.android.systemui.shared.settings.data.repository.SystemSettingsRepository 28 import com.android.systemui.statusbar.notification.interruption.VisualInterruptionDecisionLogger 29 import dagger.Module 30 import dagger.Provides 31 import dagger.multibindings.ClassKey 32 import dagger.multibindings.IntoMap 33 import kotlinx.coroutines.CoroutineDispatcher 34 import kotlinx.coroutines.CoroutineScope 35 36 @Module(includes = [UserSettingsRepositoryModule::class]) 37 object NotificationSettingsRepositoryModule { 38 @Provides 39 @SysUISingleton 40 fun provideNotificationSettingsRepository( 41 @Background backgroundScope: CoroutineScope, 42 @Background backgroundDispatcher: CoroutineDispatcher, 43 secureSettingsRepository: SecureSettingsRepository, 44 systemSettingsRepository: SystemSettingsRepository, 45 ): NotificationSettingsRepository = 46 NotificationSettingsRepository( 47 backgroundScope, 48 backgroundDispatcher, 49 secureSettingsRepository, 50 systemSettingsRepository, 51 ) 52 53 @Provides 54 @IntoMap 55 @ClassKey(NotificationSettingsRepository::class) 56 @SysUISingleton 57 fun provideCoreStartable( 58 @Application applicationScope: CoroutineScope, 59 repository: NotificationSettingsRepository, 60 logger: VisualInterruptionDecisionLogger, 61 ) = CoreStartable { 62 applicationScope.launch { 63 repository.isCooldownEnabled.collect { value -> logger.logCooldownSetting(value) } 64 } 65 } 66 } 67