1 /* 2 * Copyright (C) 2021 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.collection.coordinator.dagger 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.statusbar.notification.collection.coordinator.NotifCoordinators 21 import com.android.systemui.statusbar.notification.collection.coordinator.NotifCoordinatorsImpl 22 import com.android.systemui.statusbar.notification.collection.coordinator.SensitiveContentCoordinatorModule 23 import dagger.Binds 24 import dagger.Module 25 import dagger.Provides 26 import dagger.Subcomponent 27 import javax.inject.Qualifier 28 import javax.inject.Scope 29 30 @Module(subcomponents = [CoordinatorsSubcomponent::class]) 31 object CoordinatorsModule { 32 @SysUISingleton 33 @JvmStatic 34 @Provides notifCoordinatorsnull35 fun notifCoordinators(factory: CoordinatorsSubcomponent.Factory): NotifCoordinators = 36 factory.create().notifCoordinators 37 } 38 39 @CoordinatorScope 40 @Subcomponent(modules = [InternalCoordinatorsModule::class]) 41 interface CoordinatorsSubcomponent { 42 @get:Internal val notifCoordinators: NotifCoordinators 43 44 @Subcomponent.Factory 45 interface Factory { 46 fun create(): CoordinatorsSubcomponent 47 } 48 } 49 50 @Module(includes = [ 51 SensitiveContentCoordinatorModule::class, 52 ]) 53 abstract class InternalCoordinatorsModule { 54 @Binds 55 @Internal bindNotifCoordinatorsnull56 abstract fun bindNotifCoordinators(impl: NotifCoordinatorsImpl): NotifCoordinators 57 } 58 59 @Qualifier 60 @MustBeDocumented 61 @Retention(AnnotationRetention.RUNTIME) 62 private annotation class Internal 63 64 @Scope 65 @MustBeDocumented 66 @Retention(AnnotationRetention.RUNTIME) 67 annotation class CoordinatorScope 68