Remove BiometricPromptCompat library and limit feature to API 28

parent c5d374af
......@@ -33,7 +33,6 @@ dependencies {
implementation 'com.google.zxing:core:3.3.0'
implementation 'uk.co.samuelwall:material-tap-target-prompt:2.8.0'
implementation 'com.vanniktech:emoji-google:0.5.1'
implementation 'moe.feng.support.biometricprompt:library:1.0.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'
......
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="moe.feng.support.biometricprompt"/>
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
......@@ -20,7 +17,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission-sdk-23 android:name="android.permission.USE_FINGERPRINT" />
<uses-permission-sdk-23 android:name="android.permission.USE_BIOMETRIC" />
<application
......
......@@ -2,9 +2,12 @@ package org.briarproject.briar.android.login;
import android.app.KeyguardManager;
import android.content.Intent;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.biometrics.BiometricPrompt.AuthenticationCallback;
import android.hardware.biometrics.BiometricPrompt.AuthenticationResult;
import android.hardware.biometrics.BiometricPrompt.Builder;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.widget.Button;
......@@ -21,16 +24,11 @@ import java.util.logging.Logger;
import javax.inject.Inject;
import moe.feng.support.biometricprompt.BiometricPromptCompat;
import moe.feng.support.biometricprompt.BiometricPromptCompat.Builder;
import moe.feng.support.biometricprompt.BiometricPromptCompat.IAuthenticationCallback;
import moe.feng.support.biometricprompt.BiometricPromptCompat.IAuthenticationResult;
import static android.hardware.biometrics.BiometricPrompt.BIOMETRIC_ERROR_CANCELED;
import static android.hardware.biometrics.BiometricPrompt.BIOMETRIC_ERROR_LOCKOUT;
import static android.hardware.biometrics.BiometricPrompt.BIOMETRIC_ERROR_LOCKOUT_PERMANENT;
import static android.hardware.biometrics.BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED;
import static android.os.Build.VERSION.SDK_INT;
import static moe.feng.support.biometricprompt.BiometricPromptCompat.BIOMETRIC_ERROR_CANCELED;
import static moe.feng.support.biometricprompt.BiometricPromptCompat.BIOMETRIC_ERROR_LOCKOUT;
import static moe.feng.support.biometricprompt.BiometricPromptCompat.BIOMETRIC_ERROR_LOCKOUT_PERMANENT;
import static moe.feng.support.biometricprompt.BiometricPromptCompat.BIOMETRIC_ERROR_USER_CANCELED;
import static org.briarproject.briar.android.activity.RequestCodes.REQUEST_KEYGUARD_UNLOCK;
import static org.briarproject.briar.android.util.UiUtils.hasKeyguardLock;
import static org.briarproject.briar.android.util.UiUtils.hasUsableFingerprint;
......@@ -105,7 +103,7 @@ public class UnlockActivity extends BaseActivity {
}
private void requestUnlock() {
if (hasUsableFingerprint(this)) {
if (SDK_INT >= 28 && hasUsableFingerprint(this)) {
requestFingerprintUnlock();
} else {
requestKeyguardUnlock();
......@@ -117,17 +115,18 @@ public class UnlockActivity extends BaseActivity {
moveTaskToBack(true);
}
@RequiresApi(api = 28)
private void requestFingerprintUnlock() {
BiometricPromptCompat biometricPrompt = new Builder(this)
.setTitle(R.string.lock_unlock)
.setDescription(R.string.lock_unlock_fingerprint_description)
.setNegativeButton(R.string.lock_unlock_password,
(dialog, which) -> {
requestKeyguardUnlock();
})
BiometricPrompt biometricPrompt = new Builder(this)
.setTitle(getString(R.string.lock_unlock))
.setDescription(
getString(R.string.lock_unlock_fingerprint_description))
.setNegativeButton(getString(R.string.lock_unlock_password),
getMainExecutor(),
(dialog, which) -> requestKeyguardUnlock())
.build();
CancellationSignal signal = new CancellationSignal();
biometricPrompt.authenticate(signal, new IAuthenticationCallback() {
AuthenticationCallback callback = new AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode,
@Nullable CharSequence errString) {
......@@ -160,15 +159,15 @@ public class UnlockActivity extends BaseActivity {
}
@Override
public void onAuthenticationSucceeded(
@NonNull IAuthenticationResult result) {
public void onAuthenticationSucceeded(AuthenticationResult result) {
unlock();
}
@Override
public void onAuthenticationFailed() {
}
});
};
biometricPrompt.authenticate(signal, getMainExecutor(), callback);
}
private void requestKeyguardUnlock() {
......
......@@ -14,6 +14,7 @@ import android.support.annotation.ColorRes;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.text.Spannable;
......@@ -59,8 +60,6 @@ import static android.text.format.DateUtils.FORMAT_ABBREV_TIME;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.DateUtils.WEEK_IN_MILLIS;
import static moe.feng.support.biometricprompt.BiometricPromptCompat.hasEnrolledFingerprints;
import static moe.feng.support.biometricprompt.BiometricPromptCompat.isHardwareDetected;
import static org.briarproject.briar.BuildConfig.APPLICATION_ID;
import static org.briarproject.briar.android.TestingConstants.EXPIRY_DATE;
......@@ -278,8 +277,9 @@ public class UiUtils {
}
public static boolean hasUsableFingerprint(Context ctx) {
return SDK_INT >= 23 && isHardwareDetected(ctx) &&
hasEnrolledFingerprints(ctx);
if (SDK_INT < 28) return false;
FingerprintManagerCompat fm = FingerprintManagerCompat.from(ctx);
return fm.hasEnrolledFingerprints() && fm.isHardwareDetected();
}
public static void triggerFeedback(AndroidExecutor androidExecutor) {
......
......@@ -100,7 +100,6 @@ dependencyVerification {
'javax.inject:javax.inject:1:javax.inject-1.jar:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
'javax.xml.bind:jaxb-api:2.2.12-b140109.1041:jaxb-api-2.2.12-b140109.1041.jar:b5e60cd8b7b5ff01ce4a74c5dd008f4fbd14ced3495d0b47b85cfedc182211f2',
'junit:junit:4.12:junit-4.12.jar:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a',
'moe.feng.support.biometricprompt:library:1.0.1:library-1.0.1.aar:2cf011abdc9c51a505b35f421197b4fbeba79af792e9ea1ca973f1aef087dacd',
'nekohtml:nekohtml:1.9.6.2:nekohtml-1.9.6.2.jar:fdff6cfa9ed9cc911c842a5d2395f209ec621ef1239d46810e9e495809d3ae09',
'nekohtml:xercesMinimal:1.9.6.2:xercesMinimal-1.9.6.2.jar:95b8b357d19f63797dd7d67622fd3f18374d64acbc6584faba1c7759a31e8438',
'net.bytebuddy:byte-buddy-agent:1.7.9:byte-buddy-agent-1.7.9.jar:ac1a993befb528c3271a83a9ad9c42d363d399e9deb26e0470e3c4962066c550',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment