BiometricAvailability

sealed interface BiometricAvailability(source)

Why biometric authentication can or cannot run right now, on this device, in this app.

This is the capability flag for BiometricAuthenticator, and it is deliberately not a Boolean. A boolean answers "can I?" and throws away the only part a caller can act on: a device with no sensor needs a different fallback (PIN entry, forever) than one where the user simply has not enrolled a fingerprint yet (deep-link them to Settings), and both differ from "the host app never wired this up" (a bug, not a device state). The shareText silent-no-op is what happens when that distinction is thrown away — the button did nothing and nobody could say why.

reason is a plain-English sentence, safe to log and safe to show, so even the cases this hierarchy does not name arrive with an explanation attached.

Inheritors

Types

Link copied to clipboard

A strong biometric is enrolled and ready; BiometricAuthenticator.authenticate will prompt.

Link copied to clipboard

Too many failed attempts. Temporary on both platforms; a passcode unlock clears it.

Link copied to clipboard

No biometric sensor on this device. Permanent — fall back to a non-biometric factor.

Link copied to clipboard

Hardware exists but nothing is enrolled. Recoverable — send the user to system settings.

Link copied to clipboard

The host app has not wired biometrics up yet. On Android that means no Activity provider was installed (BiometricAndroid.install { … }); BiometricPrompt needs a FragmentActivity and a library module cannot invent one. This is a wiring bug in the app, not a device state.

Link copied to clipboard

No device passcode/screen lock, so the OS disables biometrics entirely. Recoverable.

Link copied to clipboard
data class Unavailable(val reason: String) : BiometricAvailability

Anything the platform reported that the cases above do not name; reason carries the detail.

Properties

Link copied to clipboard

True only for Available; a convenience for if, not a replacement for reason.

Link copied to clipboard
abstract val reason: String

Plain-English explanation of this state. Never blank.