1 /* <lambda>null2 * 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 package com.android.systemui.deviceentry.domain.interactor 17 18 import com.android.systemui.dagger.SysUISingleton 19 import com.android.systemui.keyguard.shared.model.BiometricUnlockSource 20 import javax.inject.Inject 21 import kotlinx.coroutines.ExperimentalCoroutinesApi 22 import kotlinx.coroutines.flow.Flow 23 import kotlinx.coroutines.flow.emptyFlow 24 import kotlinx.coroutines.flow.flatMapLatest 25 import kotlinx.coroutines.flow.map 26 import kotlinx.coroutines.flow.merge 27 28 /** Business logic for device entry auth ripple interactions. */ 29 @ExperimentalCoroutinesApi 30 @SysUISingleton 31 class AuthRippleInteractor 32 @Inject 33 constructor( 34 deviceEntrySourceInteractor: DeviceEntrySourceInteractor, 35 deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor, 36 ) { 37 private val showUnlockRippleFromDeviceEntryIcon: Flow<BiometricUnlockSource> = 38 deviceEntryUdfpsInteractor.isUdfpsSupported.flatMapLatest { isUdfpsSupported -> 39 if (isUdfpsSupported) { 40 deviceEntrySourceInteractor.deviceEntryFromDeviceEntryIcon.map { 41 BiometricUnlockSource.FINGERPRINT_SENSOR 42 } 43 } else { 44 emptyFlow() 45 } 46 } 47 48 private val showUnlockRippleFromBiometricUnlock: Flow<BiometricUnlockSource> = 49 deviceEntrySourceInteractor.deviceEntryFromBiometricSource 50 val showUnlockRipple: Flow<BiometricUnlockSource> = 51 merge( 52 showUnlockRippleFromDeviceEntryIcon, 53 showUnlockRippleFromBiometricUnlock, 54 ) 55 } 56