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.biometrics.shared.model
18 
19 sealed interface PromptKind {
20     object None : PromptKind
21 
22     data class Biometric(
23         /** The available modalities for the authentication on the prompt. */
24         val activeModalities: BiometricModalities = BiometricModalities(),
25         val paneType: PaneType = PaneType.ONE_PANE_PORTRAIT,
26     ) : PromptKind {
27         enum class PaneType {
28             TWO_PANE_LANDSCAPE,
29             ONE_PANE_PORTRAIT,
30             ONE_PANE_NO_SENSOR_LANDSCAPE,
31             ONE_PANE_LARGE_SCREEN_LANDSCAPE
32         }
33     }
34 
35     data object Pin : PromptKind
36     data object Pattern : PromptKind
37     data object Password : PromptKind
38 
isBiometricnull39     fun isBiometric() = this is Biometric
40     fun isTwoPaneLandscapeBiometric(): Boolean =
41         (this as? Biometric)?.paneType == Biometric.PaneType.TWO_PANE_LANDSCAPE
42     fun isOnePanePortraitBiometric() =
43         (this as? Biometric)?.paneType == Biometric.PaneType.ONE_PANE_PORTRAIT
44     fun isOnePaneNoSensorLandscapeBiometric() =
45         (this as? Biometric)?.paneType == Biometric.PaneType.ONE_PANE_NO_SENSOR_LANDSCAPE
46     fun isOnePaneLargeScreenLandscapeBiometric() =
47         (this as? Biometric)?.paneType == Biometric.PaneType.ONE_PANE_LARGE_SCREEN_LANDSCAPE
48     fun isCredential() = (this is Pin) || (this is Pattern) || (this is Password)
49 }
50