From 742a9b9f67e4bb9037086fdf524930b458a5cbed Mon Sep 17 00:00:00 2001 From: MrRare2 Date: Wed, 26 Mar 2025 10:57:50 +0800 Subject: [PATCH] Added: PasswordAPI this is an alternate to termux-fingerprint that let's you to use your PIN/Pattern/Password instead of hardware fingerprint sensor --- app/src/main/AndroidManifest.xml | 7 +- .../com/termux/api/TermuxApiReceiver.java | 4 + .../java/com/termux/api/apis/PasswordAPI.java | 200 ++++++++++++++++++ 3 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/termux/api/apis/PasswordAPI.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index beb27e832..e96561949 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -127,7 +127,12 @@ - + + + { + if (!postedResult) { + appendPasswordError(ERROR_TIMEOUT); + setAuthResult(AUTH_RESULT_FAILURE); + postPasswordResult(PasswordActivity.this, getIntent(), passwordResult); + finish(); + } + }, PROMPT_TIMEOUT); + } + } + + /** + * Clear out previous password authentication result. + */ + protected static void resetPasswordResult() { + passwordResult = new PasswordResult(); + postedResult = false; + } + + /** + * Add an error to our password result. + */ + protected static void appendPasswordError(String error) { + passwordResult.errors.add(error); + } + + /** + * Set the final result of our authentication. + */ + protected static void setAuthResult(String authResult) { + passwordResult.authResult = authResult; + } + + /** + * Simple class to encapsulate information about the result of a password authentication attempt. + */ + static class PasswordResult { + public String authResult = AUTH_RESULT_UNKNOWN; + public List errors = new ArrayList<>(); + } +}