Update DeviceAvailability to work with Android < 6 (#109)

Validate that the build version supports FingerprintManager before using it. Return false when not supported
This commit is contained in:
shofman 2018-02-28 14:14:36 +01:00 committed by Joel Arvidsson
parent 009f7566a8
commit 61b6626f34

View File

@ -7,12 +7,13 @@ import android.hardware.fingerprint.FingerprintManager;
public class DeviceAvailability { public class DeviceAvailability {
public static boolean isFingerprintAuthAvailable(Context context) { public static boolean isFingerprintAuthAvailable(Context context) {
FingerprintManager fingerprintManager = if (android.os.Build.VERSION.SDK_INT >= 23) {
FingerprintManager fingerprintManager =
(FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE); (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
return fingerprintManager.isHardwareDetected() &&
return android.os.Build.VERSION.SDK_INT >= 23 && fingerprintManager.hasEnrolledFingerprints();
fingerprintManager.isHardwareDetected() && }
fingerprintManager.hasEnrolledFingerprints(); return false;
} }
public static boolean isSecure(Context context) { public static boolean isSecure(Context context) {