-
Notifications
You must be signed in to change notification settings - Fork 650
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:
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.