Add IFace#reset and ISession#close methods
Bug: 180625923
Test: m android.hardware.biometrics.face-update-api
Test: build
Change-Id: I6ec2436ff4ae4c11a177ab911aebe4e80a591089
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl
index 37345ec..bfaf90d 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/IFace.aidl
@@ -35,4 +35,5 @@
interface IFace {
android.hardware.biometrics.face.SensorProps[] getSensorProps();
android.hardware.biometrics.face.ISession createSession(in int sensorId, in int userId, in android.hardware.biometrics.face.ISessionCallback cb);
+ void reset();
}
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl
index b855a9e..c9165e1 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/ISession.aidl
@@ -45,4 +45,5 @@
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);
}
diff --git a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SessionState.aidl b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SessionState.aidl
index 46751d0..3792eae 100644
--- a/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SessionState.aidl
+++ b/biometrics/face/aidl/aidl_api/android.hardware.biometrics.face/current/android/hardware/biometrics/face/SessionState.aidl
@@ -34,7 +34,7 @@
@Backing(type="byte") @VintfStability
enum SessionState {
IDLING = 0,
- TERMINATED = 1,
+ CLOSED = 1,
GENERATING_CHALLENGE = 2,
REVOKING_CHALLENGE = 3,
ENROLLING = 4,
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl
index f9ed4b1..afb7c8d 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/IFace.aidl
@@ -35,6 +35,10 @@
* Creates a session that can 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.
+ *
* Implementations must store user-specific state or metadata in /data/vendor_de/<user>/facedata
* as specified by the SELinux policy. The directory /data/vendor_de is managed by vold (see
* vold_prepare_subdirs.cpp). Implementations may store additional user-specific data, such as
@@ -47,4 +51,13 @@
*/
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/face/aidl/android/hardware/biometrics/face/ISession.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl
index f540502..6f2014a 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/ISession.aidl
@@ -17,19 +17,20 @@
package android.hardware.biometrics.face;
import android.hardware.biometrics.common.ICancellationSignal;
-import android.hardware.biometrics.face.Feature;
import android.hardware.biometrics.face.EnrollmentType;
-import android.hardware.keymaster.HardwareAuthToken;
+import android.hardware.biometrics.face.Feature;
import android.hardware.common.NativeHandle;
+import android.hardware.keymaster.HardwareAuthToken;
-/** * A session is a collection of immutable state (sensorId, userId), mutable state (SessionState),
+/**
+ * A session is a collection of immutable state (sensorId, userId), mutable state (SessionState),
* methods available for the framework to call, and a callback (ISessionCallback) to notify the
* framework about the events and results. A session is used to establish communication between
* the framework and the HAL.
*/
@VintfStability
interface ISession {
- /**
+ /**
* generateChallenge:
*
* Begins a secure transaction request. Note that the challenge by itself is not useful. It only
@@ -134,9 +135,9 @@
* @param hat See above documentation.
* @param enrollmentType See the EnrollmentType enum.
* @param features See the Feature enum.
- * @param previewSurface A surface provided by the framework if SensorProps#halControlsPreview is
- * set to true. The HAL must send the preview frames to previewSurface if
- * it's not null.
+ * @param previewSurface A surface provided by the framework if SensorProps#halControlsPreview
+ * is set to true. The HAL must send the preview frames to previewSurface
+ * if it's not null.
* @return ICancellationSignal An object that can be used by the framework to cancel this
* operation.
*/
@@ -420,5 +421,22 @@
* @param hat HardwareAuthToken See above documentation.
*/
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,
+ * IFace#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 IFace#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);
+}
diff --git a/biometrics/face/aidl/android/hardware/biometrics/face/SessionState.aidl b/biometrics/face/aidl/android/hardware/biometrics/face/SessionState.aidl
index 7675564..afde4eb 100644
--- a/biometrics/face/aidl/android/hardware/biometrics/face/SessionState.aidl
+++ b/biometrics/face/aidl/android/hardware/biometrics/face/SessionState.aidl
@@ -25,9 +25,9 @@
IDLING,
/**
- * The session has been terminated by the HAL.
+ * The session has been closed by the client.
*/
- TERMINATED,
+ CLOSED,
/**
* The HAL is processing the ISession#generateChallenge request.
@@ -89,4 +89,3 @@
*/
RESETTING_LOCKOUT
}
-