Merge changes from topic "IFingerprint-explicit-close" into sc-dev
* changes:
Update default HAL with close and reset methods
Add IFingerprint#reset and ISession#close methods
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 c5a5422..2d44528 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 @@
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 be0029c..b583006 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 @@
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 44323ff..05dd85b 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 @@
@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 3675aa4..37062ba 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 @@
* 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 @@
* @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 f9c3732..ab7930d 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 @@
*/
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 @@
*/
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 1de01ad..19a6ce3 100644
--- a/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SessionState.aidl
+++ b/biometrics/fingerprint/aidl/android/hardware/biometrics/fingerprint/SessionState.aidl
@@ -25,6 +25,11 @@
IDLING,
/**
+ * The session has been closed by the client.
+ */
+ CLOSED,
+
+ /**
* The HAL is processing the ISession#generateChallenge request.
*/
GENERATING_CHALLENGE,
@@ -74,4 +79,3 @@
*/
RESETTING_LOCKOUT
}
-
diff --git a/biometrics/fingerprint/aidl/default/Fingerprint.cpp b/biometrics/fingerprint/aidl/default/Fingerprint.cpp
index fa3171f..6f89346 100644
--- a/biometrics/fingerprint/aidl/default/Fingerprint.cpp
+++ b/biometrics/fingerprint/aidl/default/Fingerprint.cpp
@@ -58,4 +58,9 @@
*out = SharedRefBase::make<Session>(cb);
return ndk::ScopedAStatus::ok();
}
+
+ndk::ScopedAStatus Fingerprint::reset() {
+ return ndk::ScopedAStatus::ok();
+}
+
} // namespace aidl::android::hardware::biometrics::fingerprint
diff --git a/biometrics/fingerprint/aidl/default/Session.cpp b/biometrics/fingerprint/aidl/default/Session.cpp
index 52dddb6..c928df4 100644
--- a/biometrics/fingerprint/aidl/default/Session.cpp
+++ b/biometrics/fingerprint/aidl/default/Session.cpp
@@ -99,6 +99,11 @@
return ndk::ScopedAStatus::ok();
}
+ndk::ScopedAStatus Session::close(int32_t /*cookie*/) {
+ LOG(INFO) << "close";
+ return ndk::ScopedAStatus::ok();
+}
+
ndk::ScopedAStatus Session::onPointerDown(int32_t /*pointerId*/, int32_t /*x*/, int32_t /*y*/,
float /*minor*/, float /*major*/) {
LOG(INFO) << "onPointerDown";
diff --git a/biometrics/fingerprint/aidl/default/include/Fingerprint.h b/biometrics/fingerprint/aidl/default/include/Fingerprint.h
index 867e5fa..ce1366c 100644
--- a/biometrics/fingerprint/aidl/default/include/Fingerprint.h
+++ b/biometrics/fingerprint/aidl/default/include/Fingerprint.h
@@ -29,6 +29,8 @@
ndk::ScopedAStatus createSession(int32_t sensorId, int32_t userId,
const std::shared_ptr<ISessionCallback>& cb,
std::shared_ptr<ISession>* out) override;
+
+ ndk::ScopedAStatus reset() override;
};
} // namespace aidl::android::hardware::biometrics::fingerprint
diff --git a/biometrics/fingerprint/aidl/default/include/Session.h b/biometrics/fingerprint/aidl/default/include/Session.h
index b9befef..99d806b 100644
--- a/biometrics/fingerprint/aidl/default/include/Session.h
+++ b/biometrics/fingerprint/aidl/default/include/Session.h
@@ -53,6 +53,8 @@
ndk::ScopedAStatus resetLockout(int32_t cookie,
const keymaster::HardwareAuthToken& hat) override;
+ ndk::ScopedAStatus close(int32_t cookie) override;
+
ndk::ScopedAStatus onPointerDown(int32_t pointerId, int32_t x, int32_t y, float minor,
float major) override;