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.volume.dagger
18 
19 import android.media.session.MediaSessionManager
20 import com.android.settingslib.bluetooth.LocalBluetoothManager
21 import com.android.settingslib.volume.data.repository.MediaControllerRepository
22 import com.android.settingslib.volume.data.repository.MediaControllerRepositoryImpl
23 import com.android.settingslib.volume.shared.AudioManagerEventsReceiver
24 import com.android.systemui.dagger.SysUISingleton
25 import com.android.systemui.dagger.qualifiers.Application
26 import com.android.systemui.dagger.qualifiers.Background
27 import com.android.systemui.volume.panel.component.mediaoutput.data.repository.LocalMediaRepositoryFactory
28 import com.android.systemui.volume.panel.component.mediaoutput.data.repository.LocalMediaRepositoryFactoryImpl
29 import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaControllerInteractor
30 import com.android.systemui.volume.panel.component.mediaoutput.domain.interactor.MediaControllerInteractorImpl
31 import dagger.Binds
32 import dagger.Module
33 import dagger.Provides
34 import kotlin.coroutines.CoroutineContext
35 import kotlinx.coroutines.CoroutineScope
36 
37 @Module
38 interface MediaDevicesModule {
39 
40     @Binds
bindLocalMediaRepositoryFactorynull41     fun bindLocalMediaRepositoryFactory(
42         impl: LocalMediaRepositoryFactoryImpl
43     ): LocalMediaRepositoryFactory
44 
45     @Binds
46     fun bindMediaControllerInteractor(
47         impl: MediaControllerInteractorImpl
48     ): MediaControllerInteractor
49 
50     companion object {
51 
52         @Provides
53         @SysUISingleton
54         fun provideMediaDeviceSessionRepository(
55             intentsReceiver: AudioManagerEventsReceiver,
56             mediaSessionManager: MediaSessionManager,
57             localBluetoothManager: LocalBluetoothManager?,
58             @Application coroutineScope: CoroutineScope,
59             @Background backgroundContext: CoroutineContext,
60         ): MediaControllerRepository =
61             MediaControllerRepositoryImpl(
62                 intentsReceiver,
63                 mediaSessionManager,
64                 localBluetoothManager,
65                 coroutineScope,
66                 backgroundContext,
67             )
68     }
69 }
70