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 package com.android.systemui.volume.panel.component.mediaoutput.data.repository 17 18 import com.android.settingslib.volume.data.repository.LocalMediaRepository 19 import com.android.settingslib.volume.data.repository.LocalMediaRepositoryImpl 20 import com.android.settingslib.volume.shared.AudioManagerEventsReceiver 21 import com.android.systemui.dagger.SysUISingleton 22 import com.android.systemui.media.controls.util.LocalMediaManagerFactory 23 import javax.inject.Inject 24 import kotlinx.coroutines.CoroutineScope 25 26 interface LocalMediaRepositoryFactory { 27 createnull28 fun create(packageName: String?, coroutineScope: CoroutineScope): LocalMediaRepository 29 } 30 31 @SysUISingleton 32 class LocalMediaRepositoryFactoryImpl 33 @Inject 34 constructor( 35 private val eventsReceiver: AudioManagerEventsReceiver, 36 private val localMediaManagerFactory: LocalMediaManagerFactory, 37 ) : LocalMediaRepositoryFactory { 38 39 override fun create( 40 packageName: String?, 41 coroutineScope: CoroutineScope 42 ): LocalMediaRepository = 43 LocalMediaRepositoryImpl( 44 eventsReceiver, 45 localMediaManagerFactory.create(packageName), 46 coroutineScope, 47 ) 48 } 49