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 18 package com.android.systemui.biometrics.data.repository 19 20 import android.util.Size 21 import com.android.systemui.biometrics.shared.model.DisplayRotation 22 import com.android.systemui.dagger.SysUISingleton 23 import dagger.Binds 24 import dagger.Module 25 import javax.inject.Inject 26 import kotlinx.coroutines.flow.MutableStateFlow 27 import kotlinx.coroutines.flow.StateFlow 28 import kotlinx.coroutines.flow.asStateFlow 29 30 @SysUISingleton 31 class FakeDisplayStateRepository @Inject constructor() : DisplayStateRepository { 32 private val _isInRearDisplayMode = MutableStateFlow<Boolean>(false) 33 override val isInRearDisplayMode: StateFlow<Boolean> = _isInRearDisplayMode.asStateFlow() 34 35 private val _currentRotation = MutableStateFlow<DisplayRotation>(DisplayRotation.ROTATION_0) 36 override val currentRotation: StateFlow<DisplayRotation> = _currentRotation.asStateFlow() 37 38 private val _currentDisplaySize = MutableStateFlow<Size>(Size(0, 0)) 39 override val currentDisplaySize: StateFlow<Size> = _currentDisplaySize.asStateFlow() 40 41 private val _isLargeScreen = MutableStateFlow<Boolean>(false) 42 override val isLargeScreen: StateFlow<Boolean> = _isLargeScreen.asStateFlow() 43 44 override val isReverseDefaultRotation = false 45 setIsInRearDisplayModenull46 fun setIsInRearDisplayMode(isInRearDisplayMode: Boolean) { 47 _isInRearDisplayMode.value = isInRearDisplayMode 48 } 49 setCurrentRotationnull50 fun setCurrentRotation(currentRotation: DisplayRotation) { 51 _currentRotation.value = currentRotation 52 } 53 setCurrentDisplaySizenull54 fun setCurrentDisplaySize(size: Size) { 55 _currentDisplaySize.value = size 56 } 57 setIsLargeScreennull58 fun setIsLargeScreen(isLargeScreen: Boolean) { 59 _isLargeScreen.value = isLargeScreen 60 } 61 } 62 63 @Module 64 interface FakeDisplayStateRepositoryModule { bindFakenull65 @Binds fun bindFake(fake: FakeDisplayStateRepository): DisplayStateRepository 66 } 67