termux / termux/termux-api

termux-fingerprint without biometric hardware

Open
#801 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
4.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in app/src/main/java/com/termux/api/apis/FingerprintAPI.java around lines 192-203 and compare the Android API-level alternatives described in the issue. Determine how device-credential authentication should work when biometric hardware is absent, then verify that termux-fingerprint can invoke the credential unlock flow on the supported Android versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
authentication, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.