• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.deviceentry.domain.interactor
18 
19 import com.android.systemui.CoreStartable
20 import com.android.systemui.deviceentry.shared.model.FaceAuthenticationStatus
21 import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus
22 import kotlinx.coroutines.flow.Flow
23 import kotlinx.coroutines.flow.StateFlow
24 
25 /**
26  * Interactor that exposes API to get the face authentication status and handle any events that can
27  * cause face authentication to run for device entry.
28  */
29 interface DeviceEntryFaceAuthInteractor : CoreStartable {
30 
31     /** Current authentication status */
32     val authenticationStatus: Flow<FaceAuthenticationStatus>
33 
34     /** Current detection status */
35     val detectionStatus: Flow<FaceDetectionStatus>
36 
37     val isLockedOut: StateFlow<Boolean>
38 
39     val isAuthenticated: StateFlow<Boolean>
40 
41     /** Whether bypass is enabled. If enabled, face unlock dismisses the lock screen. */
42     val isBypassEnabled: Flow<Boolean>
43 
44     /** Can face auth be run right now */
canFaceAuthRunnull45     fun canFaceAuthRun(): Boolean
46 
47     /** Whether face auth is currently running or not. */
48     fun isRunning(): Boolean
49 
50     /** Whether face auth is enrolled and enabled for the current user */
51     fun isFaceAuthEnabledAndEnrolled(): Boolean
52 
53     /**
54      * Register listener for use from code that cannot use [authenticationStatus] or
55      * [detectionStatus]
56      */
57     fun registerListener(listener: FaceAuthenticationListener)
58 
59     /** Unregister previously registered listener */
60     fun unregisterListener(listener: FaceAuthenticationListener)
61 
62     fun onUdfpsSensorTouched()
63     fun onAssistantTriggeredOnLockScreen()
64     fun onDeviceLifted()
65     fun onQsExpansionStared()
66     fun onNotificationPanelClicked()
67     fun onSwipeUpOnBouncer()
68     fun onPrimaryBouncerUserInput()
69     fun onAccessibilityAction()
70     fun onWalletLaunched()
71     fun onDeviceUnfolded()
72 
73     /** Whether face auth is considered class 3 */
74     fun isFaceAuthStrong(): Boolean
75 }
76 
77 /**
78  * Listener that can be registered with the [DeviceEntryFaceAuthInteractor] to receive updates about
79  * face authentication & detection updates.
80  *
81  * This is present to make it easier for use the new face auth API for code that cannot use
82  * [DeviceEntryFaceAuthInteractor.authenticationStatus] or
83  * [DeviceEntryFaceAuthInteractor.detectionStatus] flows.
84  */
85 interface FaceAuthenticationListener {
86     /** Receive face isAuthenticated updates */
87     fun onAuthenticatedChanged(isAuthenticated: Boolean)
88 
89     /** Receive face authentication status updates */
90     fun onAuthenticationStatusChanged(status: FaceAuthenticationStatus)
91 
92     /** Receive status updates whenever face detection runs */
93     fun onDetectionStatusChanged(status: FaceDetectionStatus)
94 
95     fun onLockoutStateChanged(isLockedOut: Boolean)
96 
97     fun onRunningStateChanged(isRunning: Boolean)
98 
99     fun onAuthEnrollmentStateChanged(enrolled: Boolean)
100 }
101