• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.domain.interactor.KeyguardInteractor
20 import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
21 import javax.inject.Inject
22 import kotlinx.coroutines.flow.Flow
23 import kotlinx.coroutines.flow.emptyFlow
24 import kotlinx.coroutines.flow.filter
25 import kotlinx.coroutines.flow.flatMapLatest
26 import kotlinx.coroutines.flow.map
27 import kotlinx.coroutines.flow.merge
28 
29 /** Business logic for device entry auth ripple interactions. */
30 @SysUISingleton
31 class AuthRippleInteractor
32 @Inject
33 constructor(
34     deviceEntrySourceInteractor: DeviceEntrySourceInteractor,
35     deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor,
36     keyguardInteractor: KeyguardInteractor,
37 ) {
38     private val successfulEntryFromDeviceEntryIcon: Flow<Unit> =
39         deviceEntrySourceInteractor.attemptEnterDeviceFromDeviceEntryIcon
40             .map { keyguardInteractor.isKeyguardDismissible.value }
41             .filter { it } // only emit events if the keyguard is dismissible
42             // map to Unit
43             .map {}
44 
45     private val showUnlockRippleFromDeviceEntryIcon: Flow<BiometricUnlockSource> =
46         deviceEntryUdfpsInteractor.isUdfpsSupported.flatMapLatest { isUdfpsSupported ->
47             if (isUdfpsSupported) {
48                 successfulEntryFromDeviceEntryIcon.map { BiometricUnlockSource.FINGERPRINT_SENSOR }
49             } else {
50                 emptyFlow()
51             }
52         }
53 
54     private val showUnlockRippleFromBiometricUnlock: Flow<BiometricUnlockSource> =
55         deviceEntrySourceInteractor.deviceEntryFromBiometricSource
56     val showUnlockRipple: Flow<BiometricUnlockSource> =
57         merge(showUnlockRippleFromDeviceEntryIcon, showUnlockRippleFromBiometricUnlock)
58 }
59