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.graphics.Point 21 import com.android.systemui.biometrics.shared.model.LockoutMode 22 import com.android.systemui.dagger.SysUISingleton 23 import com.android.systemui.keyguard.shared.model.DevicePosture 24 import dagger.Binds 25 import dagger.Module 26 import javax.inject.Inject 27 import kotlinx.coroutines.flow.MutableStateFlow 28 import kotlinx.coroutines.flow.StateFlow 29 30 @SysUISingleton 31 class FakeFacePropertyRepository @Inject constructor() : FacePropertyRepository { 32 private val faceSensorInfo = MutableStateFlow<FaceSensorInfo?>(null) 33 override val sensorInfo: StateFlow<FaceSensorInfo?> 34 get() = faceSensorInfo 35 36 private val lockoutModesForUser = mutableMapOf<Int, LockoutMode>() 37 38 private val faceSensorLocation = MutableStateFlow<Point?>(null) 39 override val sensorLocation: StateFlow<Point?> 40 get() = faceSensorLocation 41 42 private val currentCameraInfo = MutableStateFlow<CameraInfo?>(null) 43 override val cameraInfo: StateFlow<CameraInfo?> 44 get() = currentCameraInfo 45 46 override val supportedPostures: List<DevicePosture> = listOf(DevicePosture.CLOSED) 47 setLockoutModenull48 fun setLockoutMode(userId: Int, mode: LockoutMode) { 49 lockoutModesForUser[userId] = mode 50 } getLockoutModenull51 override suspend fun getLockoutMode(userId: Int): LockoutMode { 52 return lockoutModesForUser[userId]!! 53 } 54 setSensorInfonull55 fun setSensorInfo(value: FaceSensorInfo?) { 56 faceSensorInfo.value = value 57 } 58 setSensorLocationnull59 fun setSensorLocation(value: Point?) { 60 faceSensorLocation.value = value 61 } 62 setCameraInonull63 fun setCameraIno(value: CameraInfo?) { 64 currentCameraInfo.value = value 65 } 66 } 67 68 @Module 69 interface FakeFacePropertyRepositoryModule { bindFakenull70 @Binds fun bindFake(fake: FakeFacePropertyRepository): FacePropertyRepository 71 } 72