mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Move fingerprint APIs over to support library
This commit is contained in:
@@ -190,5 +190,8 @@
|
||||
<orderEntry type="library" scope="TEST" name="__local_aars__:/home/bpellin/workspace/KeePassDroid/app/libs/junit4.jar:unspecified@jar" level="project" />
|
||||
<orderEntry type="library" name="junit:junit:4.12@jar" level="project" />
|
||||
<orderEntry type="library" name="joda-time:joda-time:2.9.4@jar" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-annotations:23.0.0@jar" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-v4-23.0.0" level="project" />
|
||||
<orderEntry type="library" name="android-android-22" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -32,6 +32,7 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
@@ -295,7 +296,7 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
});
|
||||
|
||||
// callback for fingerprint findings
|
||||
fingerPrintHelper.setAuthenticationCallback(new FingerprintManager.AuthenticationCallback() {
|
||||
fingerPrintHelper.setAuthenticationCallback(new FingerprintManagerCompat.AuthenticationCallback() {
|
||||
@Override
|
||||
public void onAuthenticationError(
|
||||
final int errorCode,
|
||||
@@ -319,7 +320,7 @@ public class PasswordActivity extends LockingActivity implements FingerPrintHelp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSucceeded(final FingerprintManager.AuthenticationResult result) {
|
||||
public void onAuthenticationSucceeded(final FingerprintManagerCompat.AuthenticationResult result) {
|
||||
|
||||
if (mode == Cipher.ENCRYPT_MODE) {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 Brian Pellin.
|
||||
* Copyright 2014-2017 Brian Pellin.
|
||||
*
|
||||
* This file is part of KeePassDroid.
|
||||
*
|
||||
@@ -32,6 +32,7 @@ public class BuildCompat {
|
||||
public static final int VERSION_CODE_JELLY_BEAN = 16;
|
||||
public static final int VERSION_CODE_JELLY_BEAN_MR2 = 18;
|
||||
public static final int VERSION_KITKAT = 19;
|
||||
public static final int VERSION_CODE_M = 23;
|
||||
|
||||
private static Field versionSDK;
|
||||
private static int versionInt;
|
||||
|
||||
@@ -4,14 +4,16 @@ import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.os.Build;
|
||||
import android.os.CancellationSignal;
|
||||
import android.support.v4.os.CancellationSignal;
|
||||
import android.security.keystore.KeyGenParameterSpec;
|
||||
import android.security.keystore.KeyPermanentlyInvalidatedException;
|
||||
import android.security.keystore.KeyProperties;
|
||||
import android.support.v4.hardware.fingerprint.FingerprintManagerCompat;
|
||||
import android.util.Base64;
|
||||
|
||||
import com.keepassdroid.compat.BuildCompat;
|
||||
|
||||
import java.security.KeyStore;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
@@ -23,19 +25,19 @@ public class FingerPrintHelper {
|
||||
|
||||
private static final String ALIAS_KEY = "example-key";
|
||||
|
||||
private FingerprintManager fingerprintManager;
|
||||
private FingerprintManagerCompat fingerprintManager;
|
||||
private KeyStore keyStore = null;
|
||||
private KeyGenerator keyGenerator = null;
|
||||
private Cipher cipher = null;
|
||||
private KeyguardManager keyguardManager = null;
|
||||
private FingerprintManager.CryptoObject cryptoObject = null;
|
||||
private FingerprintManagerCompat.CryptoObject cryptoObject = null;
|
||||
|
||||
private boolean initOk = false;
|
||||
private FingerPrintCallback fingerPrintCallback;
|
||||
private CancellationSignal cancellationSignal;
|
||||
private FingerprintManager.AuthenticationCallback authenticationCallback;
|
||||
private FingerprintManagerCompat.AuthenticationCallback authenticationCallback;
|
||||
|
||||
public void setAuthenticationCallback(final FingerprintManager.AuthenticationCallback authenticationCallback) {
|
||||
public void setAuthenticationCallback(final FingerprintManagerCompat.AuthenticationCallback authenticationCallback) {
|
||||
this.authenticationCallback = authenticationCallback;
|
||||
}
|
||||
|
||||
@@ -52,8 +54,8 @@ public class FingerPrintHelper {
|
||||
cancellationSignal = new CancellationSignal();
|
||||
fingerprintManager.authenticate(
|
||||
cryptoObject,
|
||||
cancellationSignal,
|
||||
0 /* flags */,
|
||||
cancellationSignal,
|
||||
authenticationCallback,
|
||||
null);
|
||||
}
|
||||
@@ -81,7 +83,7 @@ public class FingerPrintHelper {
|
||||
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
@TargetApi(BuildCompat.VERSION_CODE_M)
|
||||
public FingerPrintHelper(
|
||||
final Context context,
|
||||
final FingerPrintCallback fingerPrintCallback) {
|
||||
@@ -91,8 +93,8 @@ public class FingerPrintHelper {
|
||||
setInitOk(false);
|
||||
return;
|
||||
}
|
||||
this.fingerprintManager = context.getSystemService(FingerprintManager.class);
|
||||
this.keyguardManager = context.getSystemService(KeyguardManager.class);
|
||||
this.fingerprintManager = FingerprintManagerCompat.from(context);
|
||||
this.keyguardManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
this.fingerPrintCallback = fingerPrintCallback;
|
||||
|
||||
if (hasEnrolledFingerprints()) {
|
||||
@@ -105,7 +107,7 @@ public class FingerPrintHelper {
|
||||
KeyProperties.KEY_ALGORITHM_AES + "/"
|
||||
+ KeyProperties.BLOCK_MODE_CBC + "/"
|
||||
+ KeyProperties.ENCRYPTION_PADDING_PKCS7);
|
||||
this.cryptoObject = new FingerprintManager.CryptoObject(cipher);
|
||||
this.cryptoObject = new FingerprintManagerCompat.CryptoObject(cipher);
|
||||
setInitOk(true);
|
||||
} catch (final Exception e) {
|
||||
setInitOk(false);
|
||||
@@ -278,7 +280,7 @@ public class FingerPrintHelper {
|
||||
}
|
||||
|
||||
public boolean isFingerprintSupported() {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
|
||||
return Build.VERSION.SDK_INT >= BuildCompat.VERSION_CODE_M;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user