Skip to content

termux-fingerprint without biometric hardware #801

@jace

Description

@jace

Feature description

I have an Onyx Boox e-reader that I've been using Termux on awhile. I've recently setup Tergent on my main phone and on this device, and I've found it works on both of them, but with one problem: termux-fingerprint doesn't work on the e-reader because it has no biometric hardware.

{
  "errors": [
    "ERROR_NO_HARDWARE",
    "ERROR_NO_ENROLLED_FINGERPRINTS"
  ],
  "failed_attempts": 0,
  "auth_result": "AUTH_RESULT_UNKNOWN"
}

However, the SSH key itself works if I lock and unlock the device using the physical button, and termux-keystore list shows that the key is inside secure hardware.

Physically locking the device turns off Wi-Fi and Bluetooth, and unlocking then requires several seconds for a connection to become available. It'll help if I can directly invoke the non-biometric device credentials unlock screen, but there is no termux-unlock command or API.

Reference implementation

I'm not an Android developer, but the API reference suggests this is possible by calling setAllowedAuthenticators in the prompt builder, specifically just before .authenticate() here:

https://github.com/termux/termux-api/blob/v0.52.0/app/src/main/java/com/termux/api/apis/FingerprintAPI.java#L192-L203

            BiometricPrompt.PromptInfo.Builder builder = new BiometricPrompt.PromptInfo.Builder();
            builder.setTitle(intent.hasExtra("title") ? intent.getStringExtra("title") : "Authenticate");
            builder.setNegativeButtonText(intent.hasExtra("cancel") ? intent.getStringExtra("cancel") : "Cancel");
            if (intent.hasExtra("description")) {
                builder.setDescription(intent.getStringExtra("description"));
            }
            if (intent.hasExtra("subtitle")) {
                builder.setSubtitle(intent.getStringExtra("subtitle"));
            }

            // Allow fallback to device credentials
            builder.setAllowedAuthenticators(
                Authenticators.BIOMETRIC_WEAK | Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL
            )

            // listen to fingerprint sensor
            biometricPrompt.authenticate(builder.build());

This call is from API level 30 (Android 11). The equivalent in API level 29 is setDeviceCredentialAllowed(boolean). I'm not aware what API level Termux-API targets, or if this means I'm out of luck here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions