summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Chyn <kchyn@google.com> 2019-07-18 13:37:23 -0700
committer Kevin Chyn <kchyn@google.com> 2019-07-18 13:44:21 -0700
commit2e312791d6a4da2bb543f7dbbc98a37a32029717 (patch)
tree5b014598d5570900ddaf4cf6b240fd5aae1537db
parent53496f6fb35ab0c9b1ebedace2c05e92ca86dc66 (diff)
Biometric HAL death should invoke handleError on the handler
All client lifecycle is modified on the handler. When the HAL dies, serviceDied comes in on the main thread and will race with the rest of client lifecycle manipulation. We need to guarantee this is in order, otherwise it's possible for BiometricService to receive the following order of events 1) BiometricService requests auth 2) Face/FingerprintService is ready to start auth 3) HAL dies in the middle of 2), and sends onError to BiometricService 4) onReadyForAuthentication is sent to BiometricService, causing NPE With this change, it will guarantee that 3) occurs after 4), which will avoid A) BiometricService receiving events out of order, and more importantly B) allow BiometricPrompt to show the HW_UNAVAILABLE error instead of crashing system server. Fixes: 137800315 Test: Authentication with BiometricPromptDemo while killing the HAL Change-Id: Iae2d5b39dd494123f274b47edcc44c3afc1fff8c
-rw-r--r--services/core/java/com/android/server/biometrics/BiometricServiceBase.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
index f08423eb2016..20eb6180832c 100644
--- a/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
+++ b/services/core/java/com/android/server/biometrics/BiometricServiceBase.java
@@ -665,8 +665,12 @@ public abstract class BiometricServiceBase extends SystemService
mMetricsLogger.count(getConstants().tagHalDied(), 1);
mHALDeathCount++;
mCurrentUserId = UserHandle.USER_NULL;
- handleError(getHalDeviceId(), BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE,
- 0 /*vendorCode */);
+
+ // All client lifecycle must be managed on the handler.
+ mHandler.post(() -> {
+ handleError(getHalDeviceId(), BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE,
+ 0 /*vendorCode */);
+ });
StatsLog.write(StatsLog.BIOMETRIC_SYSTEM_HEALTH_ISSUE_DETECTED, statsModality(),
BiometricsProtoEnums.ISSUE_HAL_DEATH);