1 /* 2 * 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.communal.data.repository 18 19 import com.android.systemui.communal.data.model.CommunalMediaModel 20 import kotlinx.coroutines.flow.Flow 21 import kotlinx.coroutines.flow.MutableStateFlow 22 23 class FakeCommunalMediaRepository : CommunalMediaRepository { 24 private val _mediaModel = MutableStateFlow(CommunalMediaModel.INACTIVE) 25 26 override val mediaModel: Flow<CommunalMediaModel> = _mediaModel 27 mediaActivenull28 fun mediaActive(timestamp: Long = 0L) { 29 _mediaModel.value = 30 CommunalMediaModel( 31 hasAnyMediaOrRecommendation = true, 32 createdTimestampMillis = timestamp, 33 ) 34 } 35 mediaInactivenull36 fun mediaInactive() { 37 _mediaModel.value = CommunalMediaModel.INACTIVE 38 } 39 40 private var isListening = false 41 startListeningnull42 override fun startListening() { 43 isListening = true 44 } 45 stopListeningnull46 override fun stopListening() { 47 isListening = false 48 } 49 isListeningnull50 fun isListening(): Boolean { 51 return isListening 52 } 53 } 54