Loading packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +6 −17 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.biometrics package com.android.systemui.biometrics import android.Manifest import android.Manifest import android.annotation.IntDef import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX Loading @@ -39,14 +38,9 @@ import android.view.WindowMetrics import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityManager import android.view.accessibility.AccessibilityManager import com.android.internal.widget.LockPatternUtils import com.android.internal.widget.LockPatternUtils import java.lang.annotation.Retention import com.android.systemui.biometrics.shared.model.PromptKind import java.lang.annotation.RetentionPolicy object Utils { object Utils { const val CREDENTIAL_PIN = 1 const val CREDENTIAL_PATTERN = 2 const val CREDENTIAL_PASSWORD = 3 /** Base set of layout flags for fingerprint overlay widgets. */ /** Base set of layout flags for fingerprint overlay widgets. */ const val FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS = const val FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS = (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or Loading Loading @@ -91,17 +85,16 @@ object Utils { (promptInfo.authenticators and Authenticators.BIOMETRIC_WEAK) != 0 (promptInfo.authenticators and Authenticators.BIOMETRIC_WEAK) != 0 @JvmStatic @JvmStatic @CredentialType fun getCredentialType(utils: LockPatternUtils, userId: Int): PromptKind = fun getCredentialType(utils: LockPatternUtils, userId: Int): Int = when (utils.getKeyguardStoredPasswordQuality(userId)) { when (utils.getKeyguardStoredPasswordQuality(userId)) { PASSWORD_QUALITY_SOMETHING -> CREDENTIAL_PATTERN PASSWORD_QUALITY_SOMETHING -> PromptKind.Pattern PASSWORD_QUALITY_NUMERIC, PASSWORD_QUALITY_NUMERIC, PASSWORD_QUALITY_NUMERIC_COMPLEX -> CREDENTIAL_PIN PASSWORD_QUALITY_NUMERIC_COMPLEX -> PromptKind.Pin PASSWORD_QUALITY_ALPHABETIC, PASSWORD_QUALITY_ALPHABETIC, PASSWORD_QUALITY_ALPHANUMERIC, PASSWORD_QUALITY_ALPHANUMERIC, PASSWORD_QUALITY_COMPLEX, PASSWORD_QUALITY_COMPLEX, PASSWORD_QUALITY_MANAGED -> CREDENTIAL_PASSWORD PASSWORD_QUALITY_MANAGED -> PromptKind.Password else -> CREDENTIAL_PASSWORD else -> PromptKind.Password } } @JvmStatic @JvmStatic Loading Loading @@ -129,8 +122,4 @@ object Utils { return windowMetrics?.windowInsets?.getInsets(WindowInsets.Type.navigationBars()) return windowMetrics?.windowInsets?.getInsets(WindowInsets.Type.navigationBars()) ?: Insets.NONE ?: Insets.NONE } } @Retention(RetentionPolicy.SOURCE) @IntDef(CREDENTIAL_PIN, CREDENTIAL_PATTERN, CREDENTIAL_PASSWORD) annotation class CredentialType } } packages/SystemUI/src/com/android/systemui/biometrics/shared/model/PromptKind.kt→packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/shared/model/PromptKind.kt +9 −5 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2023 The Android Open Source Project * Copyright (C) 2024 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -16,16 +16,20 @@ package com.android.systemui.biometrics.shared.model package com.android.systemui.biometrics.shared.model import com.android.systemui.biometrics.Utils // TODO(b/251476085): this should eventually replace Utils.CredentialType /** Credential options for biometric prompt. Shadows [Utils.CredentialType]. */ sealed interface PromptKind { sealed interface PromptKind { object None : PromptKind data class Biometric( data class Biometric( val activeModalities: BiometricModalities = BiometricModalities(), val activeModalities: BiometricModalities = BiometricModalities(), // TODO(b/330908557): Use this value to decide whether to show two pane layout, instead of // simply depending on rotations. val showTwoPane: Boolean = false ) : PromptKind ) : PromptKind object Pin : PromptKind object Pin : PromptKind object Pattern : PromptKind object Pattern : PromptKind object Password : PromptKind object Password : PromptKind fun isBiometric() = this is Biometric fun isCredential() = (this is Pin) or (this is Pattern) or (this is Password) } } packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +12 −17 Original line number Original line Diff line number Diff line Loading @@ -76,6 +76,7 @@ import com.android.systemui.biometrics.AuthController.ScaleFactorProvider; import com.android.systemui.biometrics.domain.interactor.PromptCredentialInteractor; import com.android.systemui.biometrics.domain.interactor.PromptCredentialInteractor; import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor; import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor; import com.android.systemui.biometrics.shared.model.BiometricModalities; import com.android.systemui.biometrics.shared.model.BiometricModalities; import com.android.systemui.biometrics.shared.model.PromptKind; import com.android.systemui.biometrics.ui.BiometricPromptLayout; import com.android.systemui.biometrics.ui.BiometricPromptLayout; import com.android.systemui.biometrics.ui.CredentialView; import com.android.systemui.biometrics.ui.CredentialView; import com.android.systemui.biometrics.ui.binder.BiometricViewBinder; import com.android.systemui.biometrics.ui.binder.BiometricViewBinder; Loading Loading @@ -500,24 +501,18 @@ public class AuthContainerView extends LinearLayout private void addCredentialView(boolean animatePanel, boolean animateContents) { private void addCredentialView(boolean animatePanel, boolean animateContents) { final LayoutInflater factory = LayoutInflater.from(mContext); final LayoutInflater factory = LayoutInflater.from(mContext); @Utils.CredentialType final int credentialType = Utils.getCredentialType( PromptKind credentialType = Utils.getCredentialType(mLockPatternUtils, mEffectiveUserId); mLockPatternUtils, mEffectiveUserId); final int layoutResourceId; if (credentialType instanceof PromptKind.Pattern) { switch (credentialType) { layoutResourceId = R.layout.auth_credential_pattern_view; case Utils.CREDENTIAL_PATTERN: } else if (credentialType instanceof PromptKind.Pin) { mCredentialView = factory.inflate( layoutResourceId = R.layout.auth_credential_pin_view; R.layout.auth_credential_pattern_view, null, false); } else if (credentialType instanceof PromptKind.Password) { break; layoutResourceId = R.layout.auth_credential_password_view; case Utils.CREDENTIAL_PIN: } else { mCredentialView = factory.inflate(R.layout.auth_credential_pin_view, null, false); break; case Utils.CREDENTIAL_PASSWORD: mCredentialView = factory.inflate( R.layout.auth_credential_password_view, null, false); break; default: throw new IllegalStateException("Unknown credential type: " + credentialType); throw new IllegalStateException("Unknown credential type: " + credentialType); } } mCredentialView = factory.inflate(layoutResourceId, null, false); // The background is used for detecting taps / cancelling authentication. Since the // The background is used for detecting taps / cancelling authentication. Since the // credential view is full-screen and should not be canceled from background taps, // credential view is full-screen and should not be canceled from background taps, Loading packages/SystemUI/src/com/android/systemui/biometrics/data/repository/PromptRepository.kt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -125,7 +125,7 @@ constructor( private val _userId: MutableStateFlow<Int?> = MutableStateFlow(null) private val _userId: MutableStateFlow<Int?> = MutableStateFlow(null) override val userId = _userId.asStateFlow() override val userId = _userId.asStateFlow() private val _kind: MutableStateFlow<PromptKind> = MutableStateFlow(PromptKind.Biometric()) private val _kind: MutableStateFlow<PromptKind> = MutableStateFlow(PromptKind.None) override val kind = _kind.asStateFlow() override val kind = _kind.asStateFlow() private val _opPackageName: MutableStateFlow<String?> = MutableStateFlow(null) private val _opPackageName: MutableStateFlow<String?> = MutableStateFlow(null) Loading @@ -149,7 +149,7 @@ constructor( override val showBpWithoutIconForCredential = _showBpWithoutIconForCredential.asStateFlow() override val showBpWithoutIconForCredential = _showBpWithoutIconForCredential.asStateFlow() override fun setShouldShowBpWithoutIconForCredential(promptInfo: PromptInfo) { override fun setShouldShowBpWithoutIconForCredential(promptInfo: PromptInfo) { val hasCredentialViewShown = kind.value !is PromptKind.Biometric val hasCredentialViewShown = kind.value.isCredential() val showBpForCredential = val showBpForCredential = Flags.customBiometricPrompt() && Flags.customBiometricPrompt() && constraintBp() && constraintBp() && Loading Loading @@ -178,7 +178,7 @@ constructor( _promptInfo.value = null _promptInfo.value = null _userId.value = null _userId.value = null _challenge.value = null _challenge.value = null _kind.value = PromptKind.Biometric() _kind.value = PromptKind.None _opPackageName.value = null _opPackageName.value = null } } Loading packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/PromptCredentialInteractor.kt +0 −40 Original line number Original line Diff line number Diff line Loading @@ -16,10 +16,8 @@ package com.android.systemui.biometrics.domain.interactor package com.android.systemui.biometrics.domain.interactor import android.hardware.biometrics.PromptInfo import com.android.internal.widget.LockPatternView import com.android.internal.widget.LockPatternView import com.android.internal.widget.LockscreenCredential import com.android.internal.widget.LockscreenCredential import com.android.systemui.biometrics.Utils import com.android.systemui.biometrics.data.repository.PromptRepository import com.android.systemui.biometrics.data.repository.PromptRepository import com.android.systemui.biometrics.domain.model.BiometricOperationInfo import com.android.systemui.biometrics.domain.model.BiometricOperationInfo import com.android.systemui.biometrics.domain.model.BiometricPromptRequest import com.android.systemui.biometrics.domain.model.BiometricPromptRequest Loading @@ -42,12 +40,6 @@ import kotlinx.coroutines.withContext * Business logic for BiometricPrompt's CredentialViews, which primarily includes checking a users * Business logic for BiometricPrompt's CredentialViews, which primarily includes checking a users * PIN, pattern, or password credential instead of a biometric. * PIN, pattern, or password credential instead of a biometric. * * * This is used to cache the calling app's options that were given to the underlying authenticate * APIs and should be set before any UI is shown to the user. * * There can be at most one request active at a given time. Use [resetPrompt] when no request is * active to clear the cache. * * Views that use any biometric should use [PromptSelectorInteractor] instead. * Views that use any biometric should use [PromptSelectorInteractor] instead. */ */ class PromptCredentialInteractor class PromptCredentialInteractor Loading Loading @@ -137,28 +129,6 @@ constructor( private val _verificationError = MutableStateFlow<CredentialStatus.Fail?>(null) private val _verificationError = MutableStateFlow<CredentialStatus.Fail?>(null) val verificationError: Flow<CredentialStatus.Fail?> = _verificationError.asStateFlow() val verificationError: Flow<CredentialStatus.Fail?> = _verificationError.asStateFlow() /** Update the current request to use credential-based authentication instead of biometrics. */ fun useCredentialsForAuthentication( promptInfo: PromptInfo, @Utils.CredentialType kind: Int, userId: Int, challenge: Long, opPackageName: String, ) { biometricPromptRepository.setPrompt( promptInfo, userId, challenge, kind.asBiometricPromptCredential(), opPackageName, ) } /** Unset the current authentication request. */ fun resetPrompt() { biometricPromptRepository.unsetPrompt() } /** /** * Check a credential and return the attestation token (HAT) if successful. * Check a credential and return the attestation token (HAT) if successful. * * Loading Loading @@ -231,13 +201,3 @@ constructor( _verificationError.value = null _verificationError.value = null } } } } // TODO(b/251476085): remove along with Utils.CredentialType /** Convert a [Utils.CredentialType] to the corresponding [PromptKind]. */ private fun @receiver:Utils.CredentialType Int.asBiometricPromptCredential(): PromptKind = when (this) { Utils.CREDENTIAL_PIN -> PromptKind.Pin Utils.CREDENTIAL_PASSWORD -> PromptKind.Password Utils.CREDENTIAL_PATTERN -> PromptKind.Pattern else -> PromptKind.Biometric() } Loading
packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/Utils.kt +6 −17 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.biometrics package com.android.systemui.biometrics import android.Manifest import android.Manifest import android.annotation.IntDef import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX import android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX Loading @@ -39,14 +38,9 @@ import android.view.WindowMetrics import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityEvent import android.view.accessibility.AccessibilityManager import android.view.accessibility.AccessibilityManager import com.android.internal.widget.LockPatternUtils import com.android.internal.widget.LockPatternUtils import java.lang.annotation.Retention import com.android.systemui.biometrics.shared.model.PromptKind import java.lang.annotation.RetentionPolicy object Utils { object Utils { const val CREDENTIAL_PIN = 1 const val CREDENTIAL_PATTERN = 2 const val CREDENTIAL_PASSWORD = 3 /** Base set of layout flags for fingerprint overlay widgets. */ /** Base set of layout flags for fingerprint overlay widgets. */ const val FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS = const val FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS = (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or Loading Loading @@ -91,17 +85,16 @@ object Utils { (promptInfo.authenticators and Authenticators.BIOMETRIC_WEAK) != 0 (promptInfo.authenticators and Authenticators.BIOMETRIC_WEAK) != 0 @JvmStatic @JvmStatic @CredentialType fun getCredentialType(utils: LockPatternUtils, userId: Int): PromptKind = fun getCredentialType(utils: LockPatternUtils, userId: Int): Int = when (utils.getKeyguardStoredPasswordQuality(userId)) { when (utils.getKeyguardStoredPasswordQuality(userId)) { PASSWORD_QUALITY_SOMETHING -> CREDENTIAL_PATTERN PASSWORD_QUALITY_SOMETHING -> PromptKind.Pattern PASSWORD_QUALITY_NUMERIC, PASSWORD_QUALITY_NUMERIC, PASSWORD_QUALITY_NUMERIC_COMPLEX -> CREDENTIAL_PIN PASSWORD_QUALITY_NUMERIC_COMPLEX -> PromptKind.Pin PASSWORD_QUALITY_ALPHABETIC, PASSWORD_QUALITY_ALPHABETIC, PASSWORD_QUALITY_ALPHANUMERIC, PASSWORD_QUALITY_ALPHANUMERIC, PASSWORD_QUALITY_COMPLEX, PASSWORD_QUALITY_COMPLEX, PASSWORD_QUALITY_MANAGED -> CREDENTIAL_PASSWORD PASSWORD_QUALITY_MANAGED -> PromptKind.Password else -> CREDENTIAL_PASSWORD else -> PromptKind.Password } } @JvmStatic @JvmStatic Loading Loading @@ -129,8 +122,4 @@ object Utils { return windowMetrics?.windowInsets?.getInsets(WindowInsets.Type.navigationBars()) return windowMetrics?.windowInsets?.getInsets(WindowInsets.Type.navigationBars()) ?: Insets.NONE ?: Insets.NONE } } @Retention(RetentionPolicy.SOURCE) @IntDef(CREDENTIAL_PIN, CREDENTIAL_PATTERN, CREDENTIAL_PASSWORD) annotation class CredentialType } }
packages/SystemUI/src/com/android/systemui/biometrics/shared/model/PromptKind.kt→packages/SystemUI/shared/biometrics/src/com/android/systemui/biometrics/shared/model/PromptKind.kt +9 −5 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2023 The Android Open Source Project * Copyright (C) 2024 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -16,16 +16,20 @@ package com.android.systemui.biometrics.shared.model package com.android.systemui.biometrics.shared.model import com.android.systemui.biometrics.Utils // TODO(b/251476085): this should eventually replace Utils.CredentialType /** Credential options for biometric prompt. Shadows [Utils.CredentialType]. */ sealed interface PromptKind { sealed interface PromptKind { object None : PromptKind data class Biometric( data class Biometric( val activeModalities: BiometricModalities = BiometricModalities(), val activeModalities: BiometricModalities = BiometricModalities(), // TODO(b/330908557): Use this value to decide whether to show two pane layout, instead of // simply depending on rotations. val showTwoPane: Boolean = false ) : PromptKind ) : PromptKind object Pin : PromptKind object Pin : PromptKind object Pattern : PromptKind object Pattern : PromptKind object Password : PromptKind object Password : PromptKind fun isBiometric() = this is Biometric fun isCredential() = (this is Pin) or (this is Pattern) or (this is Password) } }
packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +12 −17 Original line number Original line Diff line number Diff line Loading @@ -76,6 +76,7 @@ import com.android.systemui.biometrics.AuthController.ScaleFactorProvider; import com.android.systemui.biometrics.domain.interactor.PromptCredentialInteractor; import com.android.systemui.biometrics.domain.interactor.PromptCredentialInteractor; import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor; import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor; import com.android.systemui.biometrics.shared.model.BiometricModalities; import com.android.systemui.biometrics.shared.model.BiometricModalities; import com.android.systemui.biometrics.shared.model.PromptKind; import com.android.systemui.biometrics.ui.BiometricPromptLayout; import com.android.systemui.biometrics.ui.BiometricPromptLayout; import com.android.systemui.biometrics.ui.CredentialView; import com.android.systemui.biometrics.ui.CredentialView; import com.android.systemui.biometrics.ui.binder.BiometricViewBinder; import com.android.systemui.biometrics.ui.binder.BiometricViewBinder; Loading Loading @@ -500,24 +501,18 @@ public class AuthContainerView extends LinearLayout private void addCredentialView(boolean animatePanel, boolean animateContents) { private void addCredentialView(boolean animatePanel, boolean animateContents) { final LayoutInflater factory = LayoutInflater.from(mContext); final LayoutInflater factory = LayoutInflater.from(mContext); @Utils.CredentialType final int credentialType = Utils.getCredentialType( PromptKind credentialType = Utils.getCredentialType(mLockPatternUtils, mEffectiveUserId); mLockPatternUtils, mEffectiveUserId); final int layoutResourceId; if (credentialType instanceof PromptKind.Pattern) { switch (credentialType) { layoutResourceId = R.layout.auth_credential_pattern_view; case Utils.CREDENTIAL_PATTERN: } else if (credentialType instanceof PromptKind.Pin) { mCredentialView = factory.inflate( layoutResourceId = R.layout.auth_credential_pin_view; R.layout.auth_credential_pattern_view, null, false); } else if (credentialType instanceof PromptKind.Password) { break; layoutResourceId = R.layout.auth_credential_password_view; case Utils.CREDENTIAL_PIN: } else { mCredentialView = factory.inflate(R.layout.auth_credential_pin_view, null, false); break; case Utils.CREDENTIAL_PASSWORD: mCredentialView = factory.inflate( R.layout.auth_credential_password_view, null, false); break; default: throw new IllegalStateException("Unknown credential type: " + credentialType); throw new IllegalStateException("Unknown credential type: " + credentialType); } } mCredentialView = factory.inflate(layoutResourceId, null, false); // The background is used for detecting taps / cancelling authentication. Since the // The background is used for detecting taps / cancelling authentication. Since the // credential view is full-screen and should not be canceled from background taps, // credential view is full-screen and should not be canceled from background taps, Loading
packages/SystemUI/src/com/android/systemui/biometrics/data/repository/PromptRepository.kt +3 −3 Original line number Original line Diff line number Diff line Loading @@ -125,7 +125,7 @@ constructor( private val _userId: MutableStateFlow<Int?> = MutableStateFlow(null) private val _userId: MutableStateFlow<Int?> = MutableStateFlow(null) override val userId = _userId.asStateFlow() override val userId = _userId.asStateFlow() private val _kind: MutableStateFlow<PromptKind> = MutableStateFlow(PromptKind.Biometric()) private val _kind: MutableStateFlow<PromptKind> = MutableStateFlow(PromptKind.None) override val kind = _kind.asStateFlow() override val kind = _kind.asStateFlow() private val _opPackageName: MutableStateFlow<String?> = MutableStateFlow(null) private val _opPackageName: MutableStateFlow<String?> = MutableStateFlow(null) Loading @@ -149,7 +149,7 @@ constructor( override val showBpWithoutIconForCredential = _showBpWithoutIconForCredential.asStateFlow() override val showBpWithoutIconForCredential = _showBpWithoutIconForCredential.asStateFlow() override fun setShouldShowBpWithoutIconForCredential(promptInfo: PromptInfo) { override fun setShouldShowBpWithoutIconForCredential(promptInfo: PromptInfo) { val hasCredentialViewShown = kind.value !is PromptKind.Biometric val hasCredentialViewShown = kind.value.isCredential() val showBpForCredential = val showBpForCredential = Flags.customBiometricPrompt() && Flags.customBiometricPrompt() && constraintBp() && constraintBp() && Loading Loading @@ -178,7 +178,7 @@ constructor( _promptInfo.value = null _promptInfo.value = null _userId.value = null _userId.value = null _challenge.value = null _challenge.value = null _kind.value = PromptKind.Biometric() _kind.value = PromptKind.None _opPackageName.value = null _opPackageName.value = null } } Loading
packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/PromptCredentialInteractor.kt +0 −40 Original line number Original line Diff line number Diff line Loading @@ -16,10 +16,8 @@ package com.android.systemui.biometrics.domain.interactor package com.android.systemui.biometrics.domain.interactor import android.hardware.biometrics.PromptInfo import com.android.internal.widget.LockPatternView import com.android.internal.widget.LockPatternView import com.android.internal.widget.LockscreenCredential import com.android.internal.widget.LockscreenCredential import com.android.systemui.biometrics.Utils import com.android.systemui.biometrics.data.repository.PromptRepository import com.android.systemui.biometrics.data.repository.PromptRepository import com.android.systemui.biometrics.domain.model.BiometricOperationInfo import com.android.systemui.biometrics.domain.model.BiometricOperationInfo import com.android.systemui.biometrics.domain.model.BiometricPromptRequest import com.android.systemui.biometrics.domain.model.BiometricPromptRequest Loading @@ -42,12 +40,6 @@ import kotlinx.coroutines.withContext * Business logic for BiometricPrompt's CredentialViews, which primarily includes checking a users * Business logic for BiometricPrompt's CredentialViews, which primarily includes checking a users * PIN, pattern, or password credential instead of a biometric. * PIN, pattern, or password credential instead of a biometric. * * * This is used to cache the calling app's options that were given to the underlying authenticate * APIs and should be set before any UI is shown to the user. * * There can be at most one request active at a given time. Use [resetPrompt] when no request is * active to clear the cache. * * Views that use any biometric should use [PromptSelectorInteractor] instead. * Views that use any biometric should use [PromptSelectorInteractor] instead. */ */ class PromptCredentialInteractor class PromptCredentialInteractor Loading Loading @@ -137,28 +129,6 @@ constructor( private val _verificationError = MutableStateFlow<CredentialStatus.Fail?>(null) private val _verificationError = MutableStateFlow<CredentialStatus.Fail?>(null) val verificationError: Flow<CredentialStatus.Fail?> = _verificationError.asStateFlow() val verificationError: Flow<CredentialStatus.Fail?> = _verificationError.asStateFlow() /** Update the current request to use credential-based authentication instead of biometrics. */ fun useCredentialsForAuthentication( promptInfo: PromptInfo, @Utils.CredentialType kind: Int, userId: Int, challenge: Long, opPackageName: String, ) { biometricPromptRepository.setPrompt( promptInfo, userId, challenge, kind.asBiometricPromptCredential(), opPackageName, ) } /** Unset the current authentication request. */ fun resetPrompt() { biometricPromptRepository.unsetPrompt() } /** /** * Check a credential and return the attestation token (HAT) if successful. * Check a credential and return the attestation token (HAT) if successful. * * Loading Loading @@ -231,13 +201,3 @@ constructor( _verificationError.value = null _verificationError.value = null } } } } // TODO(b/251476085): remove along with Utils.CredentialType /** Convert a [Utils.CredentialType] to the corresponding [PromptKind]. */ private fun @receiver:Utils.CredentialType Int.asBiometricPromptCredential(): PromptKind = when (this) { Utils.CREDENTIAL_PIN -> PromptKind.Pin Utils.CREDENTIAL_PASSWORD -> PromptKind.Password Utils.CREDENTIAL_PATTERN -> PromptKind.Pattern else -> PromptKind.Biometric() }