diff options
Diffstat (limited to 'mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/biometric/ext/BiometricManager.kt')
-rw-r--r-- | mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/biometric/ext/BiometricManager.kt | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/biometric/ext/BiometricManager.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/biometric/ext/BiometricManager.kt new file mode 100644 index 0000000000..7b3788d972 --- /dev/null +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/biometric/ext/BiometricManager.kt @@ -0,0 +1,27 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.settings.biometric.ext + +import androidx.biometric.BiometricManager +import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_WEAK +import androidx.biometric.BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE +import androidx.biometric.BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE +import androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS + +/** + * Checks if the hardware requirements are met for using the [BiometricManager]. + */ +fun BiometricManager.isHardwareAvailable(): Boolean { + val status = canAuthenticate(BIOMETRIC_WEAK) + return status != BIOMETRIC_ERROR_NO_HARDWARE && status != BIOMETRIC_ERROR_HW_UNAVAILABLE +} + +/** + * Checks if the user can use the [BiometricManager] and is therefore enrolled. + */ +fun BiometricManager.isEnrolled(): Boolean { + val status = canAuthenticate(BIOMETRIC_WEAK) + return status == BIOMETRIC_SUCCESS +} |