From 4ae95d73ebbb6e1d569aa4e6232f29c829c68ad7 Mon Sep 17 00:00:00 2001 From: Ilya Matyukhin Date: Tue, 16 Feb 2021 16:03:48 -0800 Subject: [PATCH] Add IFingerprint#reset and ISession#close methods Bug: 180521746 Test: m android.hardware.biometrics.fingerprint-update-api Test: build Change-Id: Ie69ea596dbbaefd4ee360facb2b57a21c8c0a46f --- .../biometrics/fingerprint/IFingerprint.aidl | 1 + .../biometrics/fingerprint/ISession.aidl | 1 + .../biometrics/fingerprint/SessionState.aidl | 21 ++++++++++--------- .../biometrics/fingerprint/IFingerprint.aidl | 14 +++++++++++++ .../biometrics/fingerprint/ISession.aidl | 19 ++++++++++++++++- .../biometrics/fingerprint/SessionState.aidl | 6 +++++- 6 files changed, 50 insertions(+), 12 deletions(-) diff --git a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/IFingerprint.aidl b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/IFingerprint.aidl index c5a5422d24..2d44528f2e 100644 --- a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/IFingerprint.aidl +++ b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/IFingerprint.aidl @@ -35,4 +35,5 @@ package android.hardware.biometrics.fingerprint; interface IFingerprint { android.hardware.biometrics.fingerprint.SensorProps[] getSensorProps(); android.hardware.biometrics.fingerprint.ISession createSession(in int sensorId, in int userId, in android.hardware.biometrics.fingerprint.ISessionCallback cb); + void reset(); } diff --git a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/ISession.aidl b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/ISession.aidl index be0029c53b..b583006d46 100644 --- a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/ISession.aidl +++ b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/ISession.aidl @@ -43,6 +43,7 @@ interface ISession { void getAuthenticatorId(in int cookie); void invalidateAuthenticatorId(in int cookie); void resetLockout(in int cookie, in android.hardware.keymaster.HardwareAuthToken hat); + void close(in int cookie); void onPointerDown(in int pointerId, in int x, in int y, in float minor, in float major); void onPointerUp(in int pointerId); void onUiReady(); diff --git a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SessionState.aidl b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SessionState.aidl index 44323ffb1d..05dd85bbfd 100644 --- a/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SessionState.aidl +++ b/biometrics/fingerprint/aidl/aidl_api/android.hardware.biometrics.fingerprint/current/android/hardware/biometrics/fingerprint/SessionState.aidl @@ -34,14 +34,15 @@ package android.hardware.biometrics.fingerprint; @Backing(type="byte") @VintfStability enum SessionState { IDLING = 0, - GENERATING_CHALLENGE = 1, - REVOKING_CHALLENGE = 2, - ENROLLING = 3, - AUTHENTICATING = 4, - DETECTING_INTERACTION = 5, - ENUMERATING_ENROLLMENTS = 6, - REMOVING_ENROLLMENTS = 7, - GETTING_AUTHENTICATOR_ID = 8, - INVALIDATING_AUTHENTICATOR_ID = 9, - RESETTING_LOCKOUT = 10, + CLOSED = 1, + GENERATING_CHALLENGE = 2, + REVOKING_CHALLENGE = 3, + ENROLLING = 4, + AUTHENTICATING = 5, + DETECTING_INTERACTION = 6, + ENUMERATING_ENROLLMENTS = 7, + REMOVING_ENROLLMENTS = 8, + GETTING_AUTHENTICATOR_ID = 9, + INVALIDATING_AUTHENTICATOR_ID = 10, + RESETTING_LOCKOUT = 11, } diff --git a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/IFingerprint.aidl b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/IFingerprint.aidl index 3675aa4019..37062badae 100644 --- a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/IFingerprint.aidl +++ b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/IFingerprint.aidl @@ -35,6 +35,10 @@ interface IFingerprint { * Creates a session which can then be used by the framework to perform operations such as * enroll, authenticate, etc for the given sensorId and userId. * + * Calling this method while there is an active session is considered an error. If the + * framework is in a bad state and for some reason cannot close its session, it should use + * the reset method below. + * * A physical sensor identified by sensorId typically supports only a single in-flight session * at a time. As such, if a session is currently in a state other than SessionState::IDLING, the * HAL MUST finish or cancel the current operation and return to SessionState::IDLING before the @@ -61,4 +65,14 @@ interface IFingerprint { * @return A new session */ ISession createSession(in int sensorId, in int userId, in ISessionCallback cb); + + /** + * Resets the HAL into a clean state, forcing it to cancel all of the pending operations, close + * its current session, and release all of the acquired resources. + * + * This should be used as a last resort to recover the HAL if the current session becomes + * unresponsive. The implementation might choose to restart the HAL process to get back into a + * good state. + */ + void reset(); } diff --git a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/ISession.aidl b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/ISession.aidl index f9c3732ac4..ab7930d81b 100644 --- a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/ISession.aidl +++ b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/ISession.aidl @@ -366,6 +366,24 @@ interface ISession { */ void resetLockout(in int cookie, in HardwareAuthToken hat); + /* + * Close this session and allow the HAL to release the resources associated with this session. + * + * A session can only be closed when it's in SessionState::IDLING. Closing a session will + * result in a ISessionCallback#onStateChanged call with SessionState::CLOSED. + * + * If a session is unresponsive or stuck in a state other than SessionState::CLOSED, + * IFingerprint#reset could be used as a last resort to terminate the session and recover the + * HAL from a bad state. + * + * All sessions must be explicitly closed. Calling IFingerprint#createSession while there is an + * active session is considered an error. + * + * @param cookie An identifier used to track subsystem operations related to this call path. The + * client must guarantee that it is unique per ISession. + */ + void close(in int cookie); + /** * Methods for notifying the under-display fingerprint sensor about external events. */ @@ -420,4 +438,3 @@ interface ISession { */ void onUiReady(); } - diff --git a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SessionState.aidl b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SessionState.aidl index 1de01ad73c..19a6ce3682 100644 --- a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SessionState.aidl +++ b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SessionState.aidl @@ -24,6 +24,11 @@ enum SessionState { */ IDLING, + /** + * The session has been closed by the client. + */ + CLOSED, + /** * The HAL is processing the ISession#generateChallenge request. */ @@ -74,4 +79,3 @@ enum SessionState { */ RESETTING_LOCKOUT } -