Fixed
Status Update
Comments
vi...@google.com <vi...@google.com>
vi...@google.com <vi...@google.com>
em...@gmail.com <em...@gmail.com> #2
Sorry to bother you. I was wondering if there is an update on this?
cu...@google.com <cu...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 154532c6c4b276252b6d0846eb96e758ffb9348c
Author: Curtis Belmonte <curtislb@google.com>
Date: Thu Sep 17 18:11:44 2020
Handle error with no fingerprint hardware on API 28
The BiometricPrompt implementation on Android 9.0 (API level 28)
internally calls FingerprintManager#getErrorString() when handling an
authentication error. On a device with no fingerprint sensor, however,
FingerprintManager will be null, causing a crash.
This commit works around the issue by requiring fingerprint hardware to
use biometric authentication on API 28. Otherwise,
BiometricManager#canAuthenticate() will report ERROR_NO_HARDWARE and
BiometricPrompt#authenticate() will invoke FingerprintManagerCompat to
gracefully handle the error.
Test: Biometric integration test app on API 28 device w/o fingerprint.
Test: ./gradlew biometric:biometric:test
Test: ./gradlew biometric:biometric:connectedAndroidTest
Test: ./gradlew biometric:integration-tests:testapp:connectedAndroidTest
Fixes: 151443237
Change-Id: Ic6d2ee76a5b59023e3152cc3b986a10cc9422c28
M biometric/biometric/proguard-rules.pro
M biometric/biometric/src/main/java/androidx/biometric/BiometricFragment.java
M biometric/biometric/src/main/java/androidx/biometric/BiometricManager.java
A biometric/biometric/src/main/java/androidx/biometric/PackageUtils.java
M biometric/biometric/src/test/java/androidx/biometric/BiometricManagerTest.java
A biometric/biometric/src/test/java/androidx/biometric/PackageUtilsTest.java
https://android-review.googlesource.com/1430815
Branch: androidx-master-dev
commit 154532c6c4b276252b6d0846eb96e758ffb9348c
Author: Curtis Belmonte <curtislb@google.com>
Date: Thu Sep 17 18:11:44 2020
Handle error with no fingerprint hardware on API 28
The BiometricPrompt implementation on Android 9.0 (API level 28)
internally calls FingerprintManager#getErrorString() when handling an
authentication error. On a device with no fingerprint sensor, however,
FingerprintManager will be null, causing a crash.
This commit works around the issue by requiring fingerprint hardware to
use biometric authentication on API 28. Otherwise,
BiometricManager#canAuthenticate() will report ERROR_NO_HARDWARE and
BiometricPrompt#authenticate() will invoke FingerprintManagerCompat to
gracefully handle the error.
Test: Biometric integration test app on API 28 device w/o fingerprint.
Test: ./gradlew biometric:biometric:test
Test: ./gradlew biometric:biometric:connectedAndroidTest
Test: ./gradlew biometric:integration-tests:testapp:connectedAndroidTest
Fixes: 151443237
Change-Id: Ic6d2ee76a5b59023e3152cc3b986a10cc9422c28
M biometric/biometric/proguard-rules.pro
M biometric/biometric/src/main/java/androidx/biometric/BiometricFragment.java
M biometric/biometric/src/main/java/androidx/biometric/BiometricManager.java
A biometric/biometric/src/main/java/androidx/biometric/PackageUtils.java
M biometric/biometric/src/test/java/androidx/biometric/BiometricManagerTest.java
A biometric/biometric/src/test/java/androidx/biometric/PackageUtilsTest.java
ob...@gmail.com <ob...@gmail.com> #4
Bvc
Description
Here is the if statement where the decision is made (line 716 of BiometricPrompt)
if (!shouldForceFingerprint && canUseBiometricFragment())
canUseBiometricFragment() only checks if the device is running API 28+ and shouldForceFingerprint is calculated mainly by shouldUseFingerprintforCrypto() . That method iterates through a list of devices that are considered not safe for crypto, all of them seem to be Samsung devices. The issue is that the code goes down the path of “I am running API 28 or grater so I am good to go” . This in turn tries to use the FingerprintManager class to get a string for the error during getErrorString(). This is null for our device since the hardware is not there. Devices that do not pass the if check from above (my Nexus 5 running API 23 for example) use the FingerprintHelperFragment and FingerprintDialogFragment classes to correctly handle not having a hardware sensor.
Here is the stacktrace of the issue:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.hardware.fingerprint.FingerprintManager.getErrorString(int, int)' on a null object reference
at android.hardware.biometrics.BiometricPrompt.lambda$sendError$0(BiometricPrompt.java:490)
at android.hardware.biometrics.-$$Lambda$BiometricPrompt$HqBGXtBUWNc-v8NoHYsj2gLfaRw.run(-.java:6)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6725)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
The code should not use BiometricFragment for this scenario or if it does, BiometricFragment should check internally before using the FingerprintManager. Probably, the best solution is to have the code handle this case to use FingerprintHelperFragment and FingerprintDialogFragment.
library version: androidx.biometric:biometric:1.0.1
device: ATT Radiant (running Android 9.0 Go)