Remove SessionState and cookie from biometrics

Bug: 183570051
Test: atest CtsBiometricsTestCases
Change-Id: Ic10601faa6355a9ec32fb67b208df90383144480
This commit is contained in:
Ilya Matyukhin
2021-03-23 21:57:36 -07:00
parent 98ffa1355d
commit 36c96ccfde
26 changed files with 76 additions and 86 deletions

View File

@@ -52,7 +52,8 @@ public abstract class BaseClientMonitor extends LoggableMonitor
*
* @param clientMonitor Reference of the ClientMonitor that is starting.
*/
default void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {}
default void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
}
/**
* Invoked when the ClientMonitor operation is complete. This abstracts away asynchronous
@@ -63,10 +64,11 @@ public abstract class BaseClientMonitor extends LoggableMonitor
* @param clientMonitor Reference of the ClientMonitor that finished.
* @param success True if the operation completed successfully.
*/
default void onClientFinished(@NonNull BaseClientMonitor clientMonitor, boolean success) {}
default void onClientFinished(@NonNull BaseClientMonitor clientMonitor, boolean success) {
}
}
protected final int mSequentialId;
private final int mSequentialId;
@NonNull private final Context mContext;
private final int mTargetUserId;
@NonNull private final String mOwner;

View File

@@ -92,7 +92,7 @@ class FaceAuthenticationClient extends AuthenticationClient<ISession> implements
@Override
protected void startHalOperation() {
try {
mCancellationSignal = getFreshDaemon().authenticate(mSequentialId, mOperationId);
mCancellationSignal = getFreshDaemon().authenticate(mOperationId);
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting auth", e);
onError(BiometricFaceConstants.FACE_ERROR_HW_UNAVAILABLE, 0 /* vendorCode */);

View File

@@ -160,7 +160,7 @@ public class FaceEnrollClient extends EnrollClient<ISession> {
features = new byte[0];
}
mCancellationSignal = getFreshDaemon().enroll(mSequentialId,
mCancellationSignal = getFreshDaemon().enroll(
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken),
EnrollmentType.DEFAULT, features, mPreviewSurface);
} catch (RemoteException e) {

View File

@@ -42,7 +42,7 @@ public class FaceGenerateChallengeClient extends GenerateChallengeClient<ISessio
@Override
protected void startHalOperation() {
try {
getFreshDaemon().generateChallenge(mSequentialId);
getFreshDaemon().generateChallenge();
} catch (RemoteException e) {
Slog.e(TAG, "Unable to generateChallenge", e);
}

View File

@@ -56,7 +56,7 @@ class FaceGetAuthenticatorIdClient extends HalClientMonitor<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().getAuthenticatorId(mSequentialId);
getFreshDaemon().getAuthenticatorId();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}

View File

@@ -48,7 +48,7 @@ class FaceInternalEnumerateClient extends InternalEnumerateClient<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().enumerateEnrollments(mSequentialId);
getFreshDaemon().enumerateEnrollments();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting enumerate", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -40,7 +40,7 @@ public class FaceInvalidationClient extends InvalidationClient<Face, ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().invalidateAuthenticatorId(mSequentialId);
getFreshDaemon().invalidateAuthenticatorId();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -53,7 +53,7 @@ class FaceRemovalClient extends RemovalClient<Face, ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().removeEnrollments(mSequentialId, mBiometricIds);
getFreshDaemon().removeEnrollments(mBiometricIds);
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting remove", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -71,7 +71,7 @@ public class FaceResetLockoutClient extends HalClientMonitor<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().resetLockout(mSequentialId, mHardwareAuthToken);
getFreshDaemon().resetLockout(mHardwareAuthToken);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to reset lockout", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -45,7 +45,7 @@ public class FaceRevokeChallengeClient extends RevokeChallengeClient<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().revokeChallenge(mSequentialId, mChallenge);
getFreshDaemon().revokeChallenge(mChallenge);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to revokeChallenge", e);
}

View File

@@ -44,7 +44,7 @@ public class FaceStopUserClient extends StopUserClient<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().close(mSequentialId);
getFreshDaemon().close();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
getCallback().onClientFinished(this, false /* success */);

View File

@@ -137,11 +137,6 @@ public class Sensor {
mCallback = callback;
}
@Override
public void onStateChanged(int cookie, byte state) {
// TODO(b/162973174)
}
@Override
public void onChallengeGenerated(long challenge) {
mHandler.post(() -> {
@@ -535,7 +530,7 @@ public class Sensor {
if (mCurrentSession != null && mCurrentSession.mSession != null) {
// TODO(181984005): This should be scheduled instead of directly invoked
Slog.d(mTag, "Closing old session");
mCurrentSession.mSession.close(888 /* cookie */);
mCurrentSession.mSession.close();
}
} catch (RemoteException e) {
Slog.e(mTag, "RemoteException", e);

View File

@@ -22,7 +22,6 @@ import android.hardware.biometrics.face.IFace;
import android.hardware.biometrics.face.ISession;
import android.hardware.biometrics.face.ISessionCallback;
import android.hardware.biometrics.face.SensorProps;
import android.hardware.biometrics.face.SessionState;
import android.hardware.common.NativeHandle;
import android.hardware.keymaster.HardwareAuthToken;
import android.os.RemoteException;
@@ -45,21 +44,21 @@ public class TestHal extends IFace.Stub {
return new ISession.Stub() {
@Override
public void generateChallenge(int cookie) throws RemoteException {
Slog.w(TAG, "generateChallenge, cookie: " + cookie);
public void generateChallenge() throws RemoteException {
Slog.w(TAG, "generateChallenge");
cb.onChallengeGenerated(0L);
}
@Override
public void revokeChallenge(int cookie, long challenge) throws RemoteException {
Slog.w(TAG, "revokeChallenge: " + challenge + ", cookie: " + cookie);
public void revokeChallenge(long challenge) throws RemoteException {
Slog.w(TAG, "revokeChallenge: " + challenge);
cb.onChallengeRevoked(challenge);
}
@Override
public ICancellationSignal enroll(int cookie, HardwareAuthToken hat,
public ICancellationSignal enroll(HardwareAuthToken hat,
byte enrollmentType, byte[] features, NativeHandle previewSurface) {
Slog.w(TAG, "enroll, cookie: " + cookie);
Slog.w(TAG, "enroll");
return new ICancellationSignal.Stub() {
@Override
public void cancel() throws RemoteException {
@@ -69,8 +68,8 @@ public class TestHal extends IFace.Stub {
}
@Override
public ICancellationSignal authenticate(int cookie, long operationId) {
Slog.w(TAG, "authenticate, cookie: " + cookie);
public ICancellationSignal authenticate(long operationId) {
Slog.w(TAG, "authenticate");
return new ICancellationSignal.Stub() {
@Override
public void cancel() throws RemoteException {
@@ -80,8 +79,8 @@ public class TestHal extends IFace.Stub {
}
@Override
public ICancellationSignal detectInteraction(int cookie) {
Slog.w(TAG, "detectInteraction, cookie: " + cookie);
public ICancellationSignal detectInteraction() {
Slog.w(TAG, "detectInteraction");
return new ICancellationSignal.Stub() {
@Override
public void cancel() throws RemoteException {
@@ -91,51 +90,51 @@ public class TestHal extends IFace.Stub {
}
@Override
public void enumerateEnrollments(int cookie) throws RemoteException {
Slog.w(TAG, "enumerateEnrollments, cookie: " + cookie);
public void enumerateEnrollments() throws RemoteException {
Slog.w(TAG, "enumerateEnrollments");
cb.onEnrollmentsEnumerated(new int[0]);
}
@Override
public void removeEnrollments(int cookie, int[] enrollmentIds) throws RemoteException {
Slog.w(TAG, "removeEnrollments, cookie: " + cookie);
public void removeEnrollments(int[] enrollmentIds) throws RemoteException {
Slog.w(TAG, "removeEnrollments");
cb.onEnrollmentsRemoved(enrollmentIds);
}
@Override
public void getFeatures(int cookie, int enrollmentId) throws RemoteException {
Slog.w(TAG, "getFeatures, cookie: " + cookie);
public void getFeatures(int enrollmentId) throws RemoteException {
Slog.w(TAG, "getFeatures");
cb.onFeaturesRetrieved(new byte[0], enrollmentId);
}
@Override
public void setFeature(int cookie, HardwareAuthToken hat, int enrollmentId,
public void setFeature(HardwareAuthToken hat, int enrollmentId,
byte feature, boolean enabled) throws RemoteException {
Slog.w(TAG, "setFeature, cookie: " + cookie);
Slog.w(TAG, "setFeature");
cb.onFeatureSet(enrollmentId, feature);
}
@Override
public void getAuthenticatorId(int cookie) throws RemoteException {
Slog.w(TAG, "getAuthenticatorId, cookie: " + cookie);
public void getAuthenticatorId() throws RemoteException {
Slog.w(TAG, "getAuthenticatorId");
cb.onAuthenticatorIdRetrieved(0L);
}
@Override
public void invalidateAuthenticatorId(int cookie) throws RemoteException {
Slog.w(TAG, "invalidateAuthenticatorId, cookie: " + cookie);
public void invalidateAuthenticatorId() throws RemoteException {
Slog.w(TAG, "invalidateAuthenticatorId");
cb.onAuthenticatorIdInvalidated(0L);
}
@Override
public void resetLockout(int cookie, HardwareAuthToken hat) throws RemoteException {
Slog.w(TAG, "resetLockout, cookie: " + cookie);
public void resetLockout(HardwareAuthToken hat) throws RemoteException {
Slog.w(TAG, "resetLockout");
cb.onLockoutCleared();
}
@Override
public void close(int cookie) throws RemoteException {
Slog.w(TAG, "close, cookie: " + cookie);
public void close() throws RemoteException {
Slog.w(TAG, "close");
cb.onSessionClosed();
}
};

View File

@@ -92,7 +92,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
UdfpsHelper.showUdfpsOverlay(getSensorId(), Utils.getUdfpsAuthReason(this),
mUdfpsOverlayController, this);
try {
mCancellationSignal = getFreshDaemon().authenticate(mSequentialId, mOperationId);
mCancellationSignal = getFreshDaemon().authenticate(mOperationId);
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
onError(BiometricFingerprintConstants.FINGERPRINT_ERROR_HW_UNAVAILABLE,

View File

@@ -74,7 +74,7 @@ class FingerprintDetectClient extends AcquisitionClient<ISession> {
IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD,
mUdfpsOverlayController, this);
try {
mCancellationSignal = getFreshDaemon().detectInteraction(mSequentialId);
mCancellationSignal = getFreshDaemon().detectInteraction();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting finger detect", e);
UdfpsHelper.hideUdfpsOverlay(getSensorId(), mUdfpsOverlayController);

View File

@@ -123,7 +123,7 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
UdfpsHelper.getReasonFromEnrollReason(mEnrollReason),
mUdfpsOverlayController, this);
try {
mCancellationSignal = getFreshDaemon().enroll(mSequentialId,
mCancellationSignal = getFreshDaemon().enroll(
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken));
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting enroll", e);

View File

@@ -44,7 +44,7 @@ class FingerprintGenerateChallengeClient extends GenerateChallengeClient<ISessio
@Override
protected void startHalOperation() {
try {
getFreshDaemon().generateChallenge(mSequentialId);
getFreshDaemon().generateChallenge();
} catch (RemoteException e) {
Slog.e(TAG, "Unable to generateChallenge", e);
}

View File

@@ -56,7 +56,7 @@ class FingerprintGetAuthenticatorIdClient extends HalClientMonitor<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().getAuthenticatorId(mSequentialId);
getFreshDaemon().getAuthenticatorId();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
}

View File

@@ -48,7 +48,7 @@ class FingerprintInternalEnumerateClient extends InternalEnumerateClient<ISessio
@Override
protected void startHalOperation() {
try {
getFreshDaemon().enumerateEnrollments(mSequentialId);
getFreshDaemon().enumerateEnrollments();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting enumerate", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -40,7 +40,7 @@ public class FingerprintInvalidationClient extends InvalidationClient<Fingerprin
@Override
protected void startHalOperation() {
try {
getFreshDaemon().invalidateAuthenticatorId(mSequentialId);
getFreshDaemon().invalidateAuthenticatorId();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -54,7 +54,7 @@ class FingerprintRemovalClient extends RemovalClient<Fingerprint, ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().removeEnrollments(mSequentialId, mBiometricIds);
getFreshDaemon().removeEnrollments(mBiometricIds);
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception when requesting remove", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -71,7 +71,7 @@ class FingerprintResetLockoutClient extends HalClientMonitor<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().resetLockout(mSequentialId, mHardwareAuthToken);
getFreshDaemon().resetLockout(mHardwareAuthToken);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to reset lockout", e);
mCallback.onClientFinished(this, false /* success */);

View File

@@ -45,7 +45,7 @@ class FingerprintRevokeChallengeClient extends RevokeChallengeClient<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().revokeChallenge(mSequentialId, mChallenge);
getFreshDaemon().revokeChallenge(mChallenge);
} catch (RemoteException e) {
Slog.e(TAG, "Unable to revokeChallenge", e);
}

View File

@@ -44,7 +44,7 @@ public class FingerprintStopUserClient extends StopUserClient<ISession> {
@Override
protected void startHalOperation() {
try {
getFreshDaemon().close(mSequentialId);
getFreshDaemon().close();
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
getCallback().onClientFinished(this, false /* success */);

View File

@@ -135,11 +135,6 @@ class Sensor {
mCallback = callback;
}
@Override
public void onStateChanged(int cookie, byte state) {
// TODO(b/162973174)
}
@Override
public void onChallengeGenerated(long challenge) {
mHandler.post(() -> {
@@ -515,7 +510,7 @@ class Sensor {
if (mCurrentSession != null && mCurrentSession.mSession != null) {
// TODO(181984005): This should be scheduled instead of directly invoked
Slog.d(mTag, "Closing old session");
mCurrentSession.mSession.close(999 /* cookie */);
mCurrentSession.mSession.close();
}
} catch (RemoteException e) {
Slog.e(mTag, "RemoteException", e);

View File

@@ -22,7 +22,6 @@ import android.hardware.biometrics.fingerprint.IFingerprint;
import android.hardware.biometrics.fingerprint.ISession;
import android.hardware.biometrics.fingerprint.ISessionCallback;
import android.hardware.biometrics.fingerprint.SensorProps;
import android.hardware.biometrics.fingerprint.SessionState;
import android.hardware.keymaster.HardwareAuthToken;
import android.os.RemoteException;
import android.util.Slog;
@@ -45,20 +44,20 @@ public class TestHal extends IFingerprint.Stub {
return new ISession.Stub() {
@Override
public void generateChallenge(int cookie) throws RemoteException {
Slog.w(TAG, "generateChallenge, cookie: " + cookie);
public void generateChallenge() throws RemoteException {
Slog.w(TAG, "generateChallenge");
cb.onChallengeGenerated(0L);
}
@Override
public void revokeChallenge(int cookie, long challenge) throws RemoteException {
Slog.w(TAG, "revokeChallenge: " + challenge + ", cookie: " + cookie);
public void revokeChallenge(long challenge) throws RemoteException {
Slog.w(TAG, "revokeChallenge: " + challenge);
cb.onChallengeRevoked(challenge);
}
@Override
public ICancellationSignal enroll(int cookie, HardwareAuthToken hat) {
Slog.w(TAG, "enroll, cookie: " + cookie);
public ICancellationSignal enroll(HardwareAuthToken hat) {
Slog.w(TAG, "enroll");
return new ICancellationSignal.Stub() {
@Override
public void cancel() throws RemoteException {
@@ -68,8 +67,8 @@ public class TestHal extends IFingerprint.Stub {
}
@Override
public ICancellationSignal authenticate(int cookie, long operationId) {
Slog.w(TAG, "authenticate, cookie: " + cookie);
public ICancellationSignal authenticate(long operationId) {
Slog.w(TAG, "authenticate");
return new ICancellationSignal.Stub() {
@Override
public void cancel() throws RemoteException {
@@ -79,8 +78,8 @@ public class TestHal extends IFingerprint.Stub {
}
@Override
public ICancellationSignal detectInteraction(int cookie) {
Slog.w(TAG, "detectInteraction, cookie: " + cookie);
public ICancellationSignal detectInteraction() {
Slog.w(TAG, "detectInteraction");
return new ICancellationSignal.Stub() {
@Override
public void cancel() throws RemoteException {
@@ -90,38 +89,38 @@ public class TestHal extends IFingerprint.Stub {
}
@Override
public void enumerateEnrollments(int cookie) throws RemoteException {
Slog.w(TAG, "enumerateEnrollments, cookie: " + cookie);
public void enumerateEnrollments() throws RemoteException {
Slog.w(TAG, "enumerateEnrollments");
cb.onEnrollmentsEnumerated(new int[0]);
}
@Override
public void removeEnrollments(int cookie, int[] enrollmentIds) throws RemoteException {
Slog.w(TAG, "removeEnrollments, cookie: " + cookie);
public void removeEnrollments(int[] enrollmentIds) throws RemoteException {
Slog.w(TAG, "removeEnrollments");
cb.onEnrollmentsRemoved(enrollmentIds);
}
@Override
public void getAuthenticatorId(int cookie) throws RemoteException {
Slog.w(TAG, "getAuthenticatorId, cookie: " + cookie);
public void getAuthenticatorId() throws RemoteException {
Slog.w(TAG, "getAuthenticatorId");
cb.onAuthenticatorIdRetrieved(0L);
}
@Override
public void invalidateAuthenticatorId(int cookie) throws RemoteException {
Slog.w(TAG, "invalidateAuthenticatorId, cookie: " + cookie);
public void invalidateAuthenticatorId() throws RemoteException {
Slog.w(TAG, "invalidateAuthenticatorId");
cb.onAuthenticatorIdInvalidated(0L);
}
@Override
public void resetLockout(int cookie, HardwareAuthToken hat) throws RemoteException {
Slog.w(TAG, "resetLockout, cookie: " + cookie);
public void resetLockout(HardwareAuthToken hat) throws RemoteException {
Slog.w(TAG, "resetLockout");
cb.onLockoutCleared();
}
@Override
public void close(int cookie) throws RemoteException {
Slog.w(TAG, "close, cookie: " + cookie);
public void close() throws RemoteException {
Slog.w(TAG, "close");
cb.onSessionClosed();
}