Merge changes I653cc165,Icd0be731
* changes: Use new context HAL methods for all biometric operations. Remove useless type.
This commit is contained in:
@@ -29,6 +29,8 @@ import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Abstract {@link HalClientMonitor} subclass that operations eligible/interested in acquisition
|
||||
* messages should extend.
|
||||
@@ -52,12 +54,7 @@ public abstract class AcquisitionClient<T> extends HalClientMonitor<T> implement
|
||||
private boolean mShouldSendErrorToClient = true;
|
||||
private boolean mAlreadyCancelled;
|
||||
|
||||
/**
|
||||
* Stops the HAL operation specific to the ClientMonitor subclass.
|
||||
*/
|
||||
protected abstract void stopHalOperation();
|
||||
|
||||
public AcquisitionClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public AcquisitionClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int cookie, int sensorId, boolean shouldVibrate,
|
||||
int statsModality, int statsAction, int statsClient) {
|
||||
@@ -67,6 +64,11 @@ public abstract class AcquisitionClient<T> extends HalClientMonitor<T> implement
|
||||
mShouldVibrate = shouldVibrate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the HAL operation specific to the ClientMonitor subclass.
|
||||
*/
|
||||
protected abstract void stopHalOperation();
|
||||
|
||||
@Override
|
||||
public void unableToStart() {
|
||||
try {
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.android.server.biometrics.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A class to keep track of the authentication state for a given client.
|
||||
@@ -89,23 +90,7 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T>
|
||||
// the state. We should think of a way to improve this in the future.
|
||||
protected @State int mState = STATE_NEW;
|
||||
|
||||
/**
|
||||
* Handles lifecycle, e.g. {@link BiometricScheduler},
|
||||
* {@link ClientMonitorCallback} after authentication
|
||||
* results are known. Note that this happens asynchronously from (but shortly after)
|
||||
* {@link #onAuthenticated(BiometricAuthenticator.Identifier, boolean, ArrayList)} and allows
|
||||
* {@link CoexCoordinator} a chance to invoke/delay this event.
|
||||
* @param authenticated
|
||||
*/
|
||||
protected abstract void handleLifecycleAfterAuth(boolean authenticated);
|
||||
|
||||
/**
|
||||
* @return true if a user was detected (i.e. face was found, fingerprint sensor was touched.
|
||||
* etc)
|
||||
*/
|
||||
public abstract boolean wasUserDetected();
|
||||
|
||||
public AuthenticationClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public AuthenticationClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
|
||||
int targetUserId, long operationId, boolean restricted, @NonNull String owner,
|
||||
int cookie, boolean requireConfirmation, int sensorId, boolean isStrongBiometric,
|
||||
@@ -474,6 +459,22 @@ public abstract class AuthenticationClient<T> extends AcquisitionClient<T>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles lifecycle, e.g. {@link BiometricScheduler},
|
||||
* {@link com.android.server.biometrics.sensors.BaseClientMonitor.Callback} after authentication
|
||||
* results are known. Note that this happens asynchronously from (but shortly after)
|
||||
* {@link #onAuthenticated(BiometricAuthenticator.Identifier, boolean, ArrayList)} and allows
|
||||
* {@link CoexCoordinator} a chance to invoke/delay this event.
|
||||
* @param authenticated
|
||||
*/
|
||||
protected abstract void handleLifecycleAfterAuth(boolean authenticated);
|
||||
|
||||
/**
|
||||
* @return true if a user was detected (i.e. face was found, fingerprint sensor was touched.
|
||||
* etc)
|
||||
*/
|
||||
public abstract boolean wasUserDetected();
|
||||
|
||||
public @State int getState() {
|
||||
return mState;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A class to keep track of the enrollment state for a given client.
|
||||
@@ -49,7 +50,7 @@ public abstract class EnrollClient<T> extends AcquisitionClient<T> implements En
|
||||
*/
|
||||
protected abstract boolean hasReachedEnrollmentLimit();
|
||||
|
||||
public EnrollClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public EnrollClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull String owner, @NonNull BiometricUtils utils,
|
||||
int timeoutSec, int statsModality, int sensorId, boolean shouldVibrate) {
|
||||
|
||||
@@ -25,11 +25,13 @@ import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class GenerateChallengeClient<T> extends HalClientMonitor<T> {
|
||||
|
||||
private static final String TAG = "GenerateChallengeClient";
|
||||
|
||||
public GenerateChallengeClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public GenerateChallengeClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
|
||||
int userId, @NonNull String owner, int sensorId) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
||||
|
||||
@@ -22,35 +22,16 @@ import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.os.IBinder;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Abstract {@link BaseClientMonitor} implementation that supports HAL operations.
|
||||
* @param <T> HAL template
|
||||
*/
|
||||
public abstract class HalClientMonitor<T> extends BaseClientMonitor {
|
||||
/**
|
||||
* Interface that allows ClientMonitor subclasses to retrieve a fresh instance to the HAL.
|
||||
*/
|
||||
public interface LazyDaemon<T> {
|
||||
/**
|
||||
* @return A fresh instance to the biometric HAL
|
||||
*/
|
||||
T getDaemon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the HAL operation specific to the ClientMonitor subclass.
|
||||
*/
|
||||
protected abstract void startHalOperation();
|
||||
|
||||
/**
|
||||
* Invoked if the scheduler is unable to start the ClientMonitor (for example the HAL is null).
|
||||
* If such a problem is detected, the scheduler will not invoke
|
||||
* {@link #start(ClientMonitorCallback)}.
|
||||
*/
|
||||
public abstract void unableToStart();
|
||||
|
||||
|
||||
@NonNull
|
||||
protected final LazyDaemon<T> mLazyDaemon;
|
||||
protected final Supplier<T> mLazyDaemon;
|
||||
|
||||
/**
|
||||
* @param context system_server context
|
||||
@@ -65,7 +46,7 @@ public abstract class HalClientMonitor<T> extends BaseClientMonitor {
|
||||
* @param statsAction One of {@link BiometricsProtoEnums} ACTION_* constants
|
||||
* @param statsClient One of {@link BiometricsProtoEnums} CLIENT_* constants
|
||||
*/
|
||||
public HalClientMonitor(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public HalClientMonitor(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@Nullable IBinder token, @Nullable ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int cookie, int sensorId, int statsModality, int statsAction,
|
||||
int statsClient) {
|
||||
@@ -76,6 +57,18 @@ public abstract class HalClientMonitor<T> extends BaseClientMonitor {
|
||||
|
||||
@Nullable
|
||||
public T getFreshDaemon() {
|
||||
return mLazyDaemon.getDaemon();
|
||||
return mLazyDaemon.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the HAL operation specific to the ClientMonitor subclass.
|
||||
*/
|
||||
protected abstract void startHalOperation();
|
||||
|
||||
/**
|
||||
* Invoked if the scheduler is unable to start the ClientMonitor (for example the HAL is null).
|
||||
* If such a problem is detected, the scheduler will not invoke
|
||||
* {@link #start(ClientMonitorCallback)}.
|
||||
*/
|
||||
public abstract void unableToStart();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.android.server.biometrics.BiometricsProto;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Wraps {@link InternalEnumerateClient} and {@link RemovalClient}. Keeps track of all the
|
||||
@@ -99,14 +100,14 @@ public abstract class InternalCleanupClient<S extends BiometricAuthenticator.Ide
|
||||
};
|
||||
|
||||
protected abstract InternalEnumerateClient<T> getEnumerateClient(Context context,
|
||||
LazyDaemon<T> lazyDaemon, IBinder token, int userId, String owner,
|
||||
Supplier<T> lazyDaemon, IBinder token, int userId, String owner,
|
||||
List<S> enrolledList, BiometricUtils<S> utils, int sensorId);
|
||||
|
||||
protected abstract RemovalClient<S, T> getRemovalClient(Context context,
|
||||
LazyDaemon<T> lazyDaemon, IBinder token, int biometricId, int userId, String owner,
|
||||
Supplier<T> lazyDaemon, IBinder token, int biometricId, int userId, String owner,
|
||||
BiometricUtils<S> utils, int sensorId, Map<Integer, Long> authenticatorIds);
|
||||
|
||||
protected InternalCleanupClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
protected InternalCleanupClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
int userId, @NonNull String owner, int sensorId, int statsModality,
|
||||
@NonNull List<S> enrolledList, @NonNull BiometricUtils<S> utils,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Internal class to help clean up unknown templates in the HAL and Framework
|
||||
@@ -43,7 +44,7 @@ public abstract class InternalEnumerateClient<T> extends HalClientMonitor<T>
|
||||
// List of templates to remove from the HAL
|
||||
private List<BiometricAuthenticator.Identifier> mUnknownHALTemplates = new ArrayList<>();
|
||||
|
||||
protected InternalEnumerateClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
protected InternalEnumerateClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, int userId, @NonNull String owner,
|
||||
@NonNull List<? extends BiometricAuthenticator.Identifier> enrolledList,
|
||||
@NonNull BiometricUtils utils, int sensorId, int statsModality) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* ClientMonitor subclass for requesting authenticatorId invalidation. See
|
||||
@@ -40,7 +41,7 @@ public abstract class InvalidationClient<S extends BiometricAuthenticator.Identi
|
||||
@NonNull private final Map<Integer, Long> mAuthenticatorIds;
|
||||
@NonNull private final IInvalidationCallback mInvalidationCallback;
|
||||
|
||||
public InvalidationClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public InvalidationClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
int userId, int sensorId, @NonNull Map<Integer, Long> authenticatorIds,
|
||||
@NonNull IInvalidationCallback callback) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId,
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A class to keep track of the remove state for a given client.
|
||||
@@ -40,7 +41,7 @@ public abstract class RemovalClient<S extends BiometricAuthenticator.Identifier,
|
||||
private final Map<Integer, Long> mAuthenticatorIds;
|
||||
private final boolean mHasEnrollmentsBeforeStarting;
|
||||
|
||||
public RemovalClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public RemovalClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
|
||||
int userId, @NonNull String owner, @NonNull BiometricUtils<S> utils, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds, int statsModality) {
|
||||
|
||||
@@ -23,9 +23,11 @@ import android.os.IBinder;
|
||||
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class RevokeChallengeClient<T> extends HalClientMonitor<T> {
|
||||
|
||||
public RevokeChallengeClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public RevokeChallengeClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@NonNull IBinder token, int userId, @NonNull String owner, int sensorId) {
|
||||
super(context, lazyDaemon, token, null /* listener */, userId, owner,
|
||||
0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_UNKNOWN,
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.os.IBinder;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Abstract class for starting a new user.
|
||||
* @param <T> Interface to request a new user.
|
||||
@@ -37,13 +39,13 @@ public abstract class StartUserClient<T, U> extends HalClientMonitor<T> {
|
||||
* @param <U> New user object.
|
||||
*/
|
||||
public interface UserStartedCallback<U> {
|
||||
void onUserStarted(int newUserId, U newUser);
|
||||
void onUserStarted(int newUserId, U newUser, int halInterfaceVersion);
|
||||
}
|
||||
|
||||
@NonNull @VisibleForTesting
|
||||
protected final UserStartedCallback<U> mUserStartedCallback;
|
||||
|
||||
public StartUserClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public StartUserClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@Nullable IBinder token, int userId, int sensorId,
|
||||
@NonNull UserStartedCallback<U> callback) {
|
||||
super(context, lazyDaemon, token, null /* listener */, userId, context.getOpPackageName(),
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.os.IBinder;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.biometrics.BiometricsProto;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Abstract class for stopping a user.
|
||||
* @param <T> Interface for stopping the user.
|
||||
@@ -43,7 +45,7 @@ public abstract class StopUserClient<T> extends HalClientMonitor<T> {
|
||||
getCallback().onClientFinished(this, true /* success */);
|
||||
}
|
||||
|
||||
public StopUserClient(@NonNull Context context, @NonNull LazyDaemon<T> lazyDaemon,
|
||||
public StopUserClient(@NonNull Context context, @NonNull Supplier<T> lazyDaemon,
|
||||
@Nullable IBinder token, int userId, int sensorId,
|
||||
@NonNull UserStoppedCallback callback) {
|
||||
super(context, lazyDaemon, token, null /* listener */, userId, context.getOpPackageName(),
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.biometrics.sensors.face.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
|
||||
import static com.android.server.biometrics.sensors.face.aidl.Sensor.HalSessionCallback;
|
||||
|
||||
/**
|
||||
* A holder for an AIDL {@link ISession} with additional metadata about the current user
|
||||
* and the backend.
|
||||
*/
|
||||
public class AidlSession {
|
||||
|
||||
private final int mHalInterfaceVersion;
|
||||
@NonNull
|
||||
private final ISession mSession;
|
||||
private final int mUserId;
|
||||
@NonNull private final HalSessionCallback mHalSessionCallback;
|
||||
|
||||
public AidlSession(int halInterfaceVersion, @NonNull ISession session, int userId,
|
||||
HalSessionCallback halSessionCallback) {
|
||||
mHalInterfaceVersion = halInterfaceVersion;
|
||||
mSession = session;
|
||||
mUserId = userId;
|
||||
mHalSessionCallback = halSessionCallback;
|
||||
}
|
||||
|
||||
/** The underlying {@link ISession}. */
|
||||
@NonNull public ISession getSession() {
|
||||
return mSession;
|
||||
}
|
||||
|
||||
/** The user id associated with the session. */
|
||||
public int getUserId() {
|
||||
return mUserId;
|
||||
}
|
||||
|
||||
/** The HAL callback, which should only be used in tests {@See BiometricTestSessionImpl}. */
|
||||
HalSessionCallback getHalSessionCallback() {
|
||||
return mHalSessionCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this backend implements the *WithContext methods for enroll, authenticate, and
|
||||
* detectInteraction. These variants should always be called if they are available.
|
||||
*/
|
||||
public boolean hasContextMethods() {
|
||||
return mHalInterfaceVersion >= 2;
|
||||
}
|
||||
}
|
||||
@@ -165,7 +165,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
}
|
||||
|
||||
mEnrollmentIds.add(nextRandomId);
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback()
|
||||
.onEnrollmentProgress(nextRandomId, 0 /* remaining */);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
return;
|
||||
}
|
||||
final int fid = faces.get(0).getBiometricId();
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationSucceeded(fid,
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onAuthenticationSucceeded(fid,
|
||||
HardwareAuthTokenUtils.toHardwareAuthToken(new byte[69]));
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void rejectAuthentication(int userId) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationFailed();
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onAuthenticationFailed();
|
||||
}
|
||||
|
||||
// TODO(b/178414967): replace with notifyAuthenticationFrame and notifyEnrollmentFrame.
|
||||
@@ -205,7 +205,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
// TODO(b/178414967): Currently onAuthenticationFrame and onEnrollmentFrame are the same.
|
||||
// This will need to call the correct callback once the onAcquired callback is removed.
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationFrame(
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onAuthenticationFrame(
|
||||
authenticationFrame);
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void notifyError(int userId, int errorCode) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onError((byte) errorCode,
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onError((byte) errorCode,
|
||||
0 /* vendorCode */);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,9 @@ import android.hardware.biometrics.BiometricConstants;
|
||||
import android.hardware.biometrics.BiometricFaceConstants;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.common.OperationContext;
|
||||
import android.hardware.biometrics.common.OperationReason;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.face.FaceAuthenticationFrame;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.os.IBinder;
|
||||
@@ -48,11 +49,13 @@ import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
import com.android.server.biometrics.sensors.face.UsageStats;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific authentication client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
class FaceAuthenticationClient extends AuthenticationClient<ISession> implements LockoutConsumer {
|
||||
class FaceAuthenticationClient extends AuthenticationClient<AidlSession>
|
||||
implements LockoutConsumer {
|
||||
private static final String TAG = "FaceAuthenticationClient";
|
||||
|
||||
@NonNull private final UsageStats mUsageStats;
|
||||
@@ -69,7 +72,7 @@ class FaceAuthenticationClient extends AuthenticationClient<ISession> implements
|
||||
@FaceManager.FaceAcquired private int mLastAcquire = FaceManager.FACE_ACQUIRED_UNKNOWN;
|
||||
|
||||
FaceAuthenticationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int targetUserId, long operationId,
|
||||
boolean restricted, String owner, int cookie, boolean requireConfirmation, int sensorId,
|
||||
@@ -122,7 +125,7 @@ class FaceAuthenticationClient extends AuthenticationClient<ISession> implements
|
||||
0 /* vendorCode */);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
} else {
|
||||
mCancellationSignal = getFreshDaemon().authenticate(mOperationId);
|
||||
mCancellationSignal = doAuthenticate();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting auth", e);
|
||||
@@ -131,6 +134,22 @@ class FaceAuthenticationClient extends AuthenticationClient<ISession> implements
|
||||
}
|
||||
}
|
||||
|
||||
private ICancellationSignal doAuthenticate() throws RemoteException {
|
||||
final AidlSession session = getFreshDaemon();
|
||||
|
||||
if (session.hasContextMethods()) {
|
||||
final OperationContext context = new OperationContext();
|
||||
// TODO: add reason, id, and isAoD
|
||||
context.id = 0;
|
||||
context.reason = OperationReason.UNKNOWN;
|
||||
context.isAoD = false;
|
||||
context.isCrypto = isCryptoOperation();
|
||||
return session.getSession().authenticateWithContext(mOperationId, context);
|
||||
} else {
|
||||
return session.getSession().authenticate(mOperationId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopHalOperation() {
|
||||
if (mCancellationSignal != null) {
|
||||
|
||||
@@ -23,7 +23,8 @@ import android.hardware.SensorPrivacyManager;
|
||||
import android.hardware.biometrics.BiometricConstants;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.biometrics.common.OperationContext;
|
||||
import android.hardware.biometrics.common.OperationReason;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -34,11 +35,13 @@ import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.DetectionConsumer;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Performs face detection without exposing any matching information (e.g. accept/reject have the
|
||||
* same haptic, lockout counter is not increased).
|
||||
*/
|
||||
public class FaceDetectClient extends AcquisitionClient<ISession> implements DetectionConsumer {
|
||||
public class FaceDetectClient extends AcquisitionClient<AidlSession> implements DetectionConsumer {
|
||||
|
||||
private static final String TAG = "FaceDetectClient";
|
||||
|
||||
@@ -46,7 +49,7 @@ public class FaceDetectClient extends AcquisitionClient<ISession> implements Det
|
||||
@Nullable private ICancellationSignal mCancellationSignal;
|
||||
@Nullable private SensorPrivacyManager mSensorPrivacyManager;
|
||||
|
||||
public FaceDetectClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FaceDetectClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId, boolean isStrongBiometric, int statsClient) {
|
||||
@@ -87,13 +90,29 @@ public class FaceDetectClient extends AcquisitionClient<ISession> implements Det
|
||||
}
|
||||
|
||||
try {
|
||||
mCancellationSignal = getFreshDaemon().detectInteraction();
|
||||
mCancellationSignal = doDetectInteraction();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting face detect", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
}
|
||||
}
|
||||
|
||||
private ICancellationSignal doDetectInteraction() throws RemoteException {
|
||||
final AidlSession session = getFreshDaemon();
|
||||
|
||||
if (session.hasContextMethods()) {
|
||||
final OperationContext context = new OperationContext();
|
||||
// TODO: add reason, id, and isAoD
|
||||
context.id = 0;
|
||||
context.reason = OperationReason.UNKNOWN;
|
||||
context.isAoD = false;
|
||||
context.isCrypto = isCryptoOperation();
|
||||
return session.getSession().detectInteractionWithContext(context);
|
||||
} else {
|
||||
return session.getSession().detectInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteractionDetected() {
|
||||
vibrateSuccess();
|
||||
|
||||
@@ -22,14 +22,16 @@ import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricFaceConstants;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.common.OperationContext;
|
||||
import android.hardware.biometrics.common.OperationReason;
|
||||
import android.hardware.biometrics.face.EnrollmentType;
|
||||
import android.hardware.biometrics.face.Feature;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.common.NativeHandle;
|
||||
import android.hardware.face.Face;
|
||||
import android.hardware.face.FaceEnrollFrame;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.keymaster.HardwareAuthToken;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -51,11 +53,12 @@ import com.android.server.biometrics.sensors.face.FaceUtils;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific enroll client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
public class FaceEnrollClient extends EnrollClient<ISession> {
|
||||
public class FaceEnrollClient extends EnrollClient<AidlSession> {
|
||||
|
||||
private static final String TAG = "FaceEnrollClient";
|
||||
|
||||
@@ -82,7 +85,7 @@ public class FaceEnrollClient extends EnrollClient<ISession> {
|
||||
}
|
||||
};
|
||||
|
||||
FaceEnrollClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FaceEnrollClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull String opPackageName, long requestId,
|
||||
@NonNull BiometricUtils<Face> utils, @NonNull int[] disabledFeatures, int timeoutSec,
|
||||
@@ -177,14 +180,12 @@ public class FaceEnrollClient extends EnrollClient<ISession> {
|
||||
featureList.add(Feature.REQUIRE_DIVERSE_POSES);
|
||||
}
|
||||
|
||||
byte[] features = new byte[featureList.size()];
|
||||
final byte[] features = new byte[featureList.size()];
|
||||
for (int i = 0; i < featureList.size(); i++) {
|
||||
features[i] = featureList.get(i);
|
||||
}
|
||||
|
||||
mCancellationSignal = getFreshDaemon().enroll(
|
||||
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken),
|
||||
EnrollmentType.DEFAULT, features, mHwPreviewHandle);
|
||||
mCancellationSignal = doEnroll(features);
|
||||
} catch (RemoteException | IllegalArgumentException e) {
|
||||
Slog.e(TAG, "Exception when requesting enroll", e);
|
||||
onError(BiometricFaceConstants.FACE_ERROR_UNABLE_TO_PROCESS, 0 /* vendorCode */);
|
||||
@@ -192,6 +193,26 @@ public class FaceEnrollClient extends EnrollClient<ISession> {
|
||||
}
|
||||
}
|
||||
|
||||
private ICancellationSignal doEnroll(byte[] features) throws RemoteException {
|
||||
final AidlSession session = getFreshDaemon();
|
||||
final HardwareAuthToken hat =
|
||||
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken);
|
||||
|
||||
if (session.hasContextMethods()) {
|
||||
final OperationContext context = new OperationContext();
|
||||
// TODO: add reason, id, and isAoD
|
||||
context.id = 0;
|
||||
context.reason = OperationReason.UNKNOWN;
|
||||
context.isAoD = false;
|
||||
context.isCrypto = isCryptoOperation();
|
||||
return session.getSession().enrollWithContext(
|
||||
hat, EnrollmentType.DEFAULT, features, mHwPreviewHandle, context);
|
||||
} else {
|
||||
return session.getSession().enroll(hat, EnrollmentType.DEFAULT, features,
|
||||
mHwPreviewHandle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopHalOperation() {
|
||||
if (mCancellationSignal != null) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.face.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -27,14 +26,16 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.GenerateChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific generateChallenge client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
public class FaceGenerateChallengeClient extends GenerateChallengeClient<ISession> {
|
||||
public class FaceGenerateChallengeClient extends GenerateChallengeClient<AidlSession> {
|
||||
private static final String TAG = "FaceGenerateChallengeClient";
|
||||
|
||||
FaceGenerateChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId, @NonNull String owner,
|
||||
int sensorId) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, sensorId);
|
||||
@@ -43,7 +44,7 @@ public class FaceGenerateChallengeClient extends GenerateChallengeClient<ISessio
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().generateChallenge();
|
||||
getFreshDaemon().getSession().generateChallenge();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to generateChallenge", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.face.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
@@ -28,14 +27,16 @@ import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class FaceGetAuthenticatorIdClient extends HalClientMonitor<ISession> {
|
||||
class FaceGetAuthenticatorIdClient extends HalClientMonitor<AidlSession> {
|
||||
|
||||
private static final String TAG = "FaceGetAuthenticatorIdClient";
|
||||
|
||||
private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
FaceGetAuthenticatorIdClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FaceGetAuthenticatorIdClient(@NonNull Context context,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon,
|
||||
int userId, @NonNull String opPackageName, int sensorId,
|
||||
Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, opPackageName,
|
||||
@@ -57,7 +58,7 @@ class FaceGetAuthenticatorIdClient extends HalClientMonitor<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().getAuthenticatorId();
|
||||
getFreshDaemon().getSession().getAuthenticatorId();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricFaceConstants;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.Settings;
|
||||
@@ -36,17 +35,18 @@ import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific get feature client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
public class FaceGetFeatureClient extends HalClientMonitor<ISession> implements ErrorConsumer {
|
||||
public class FaceGetFeatureClient extends HalClientMonitor<AidlSession> implements ErrorConsumer {
|
||||
|
||||
private static final String TAG = "FaceGetFeatureClient";
|
||||
|
||||
private final int mUserId;
|
||||
|
||||
FaceGetFeatureClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FaceGetFeatureClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, @Nullable ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
||||
@@ -69,7 +69,7 @@ public class FaceGetFeatureClient extends HalClientMonitor<ISession> implements
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().getFeatures();
|
||||
getFreshDaemon().getSession().getFeatures();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to getFeature", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.face.Face;
|
||||
import android.os.IBinder;
|
||||
|
||||
@@ -31,14 +30,15 @@ import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific internal cleanup client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
class FaceInternalCleanupClient extends InternalCleanupClient<Face, ISession> {
|
||||
class FaceInternalCleanupClient extends InternalCleanupClient<Face, AidlSession> {
|
||||
|
||||
FaceInternalCleanupClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, @NonNull String owner,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId, @NonNull List<Face> enrolledList, @NonNull BiometricUtils<Face> utils,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, userId, owner, sensorId, BiometricsProtoEnums.MODALITY_FACE,
|
||||
@@ -46,16 +46,16 @@ class FaceInternalCleanupClient extends InternalCleanupClient<Face, ISession> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InternalEnumerateClient<ISession> getEnumerateClient(Context context,
|
||||
LazyDaemon<ISession> lazyDaemon, IBinder token, int userId, String owner,
|
||||
protected InternalEnumerateClient<AidlSession> getEnumerateClient(Context context,
|
||||
Supplier<AidlSession> lazyDaemon, IBinder token, int userId, String owner,
|
||||
List<Face> enrolledList, BiometricUtils<Face> utils, int sensorId) {
|
||||
return new FaceInternalEnumerateClient(context, lazyDaemon, token, userId, owner,
|
||||
enrolledList, utils, sensorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemovalClient<Face, ISession> getRemovalClient(Context context,
|
||||
LazyDaemon<ISession> lazyDaemon, IBinder token,
|
||||
protected RemovalClient<Face, AidlSession> getRemovalClient(Context context,
|
||||
Supplier<AidlSession> lazyDaemon, IBinder token,
|
||||
int biometricId, int userId, String owner, BiometricUtils<Face> utils, int sensorId,
|
||||
Map<Integer, Long> authenticatorIds) {
|
||||
// Internal remove does not need to send results to anyone. Cleanup (enumerate + remove)
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.face.Face;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -30,15 +29,16 @@ import com.android.server.biometrics.sensors.BiometricUtils;
|
||||
import com.android.server.biometrics.sensors.InternalEnumerateClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific internal enumerate client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
class FaceInternalEnumerateClient extends InternalEnumerateClient<ISession> {
|
||||
class FaceInternalEnumerateClient extends InternalEnumerateClient<AidlSession> {
|
||||
private static final String TAG = "FaceInternalEnumerateClient";
|
||||
|
||||
FaceInternalEnumerateClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull String owner, @NonNull List<Face> enrolledList,
|
||||
@NonNull BiometricUtils<Face> utils, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, enrolledList, utils, sensorId,
|
||||
@@ -48,7 +48,7 @@ class FaceInternalEnumerateClient extends InternalEnumerateClient<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().enumerateEnrollments();
|
||||
getFreshDaemon().getSession().enumerateEnrollments();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting enumerate", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.face.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.face.Face;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -27,12 +26,13 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.InvalidationClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FaceInvalidationClient extends InvalidationClient<Face, ISession> {
|
||||
public class FaceInvalidationClient extends InvalidationClient<Face, AidlSession> {
|
||||
private static final String TAG = "FaceInvalidationClient";
|
||||
|
||||
public FaceInvalidationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, int sensorId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds, @NonNull IInvalidationCallback callback) {
|
||||
super(context, lazyDaemon, userId, sensorId, authenticatorIds, callback);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class FaceInvalidationClient extends InvalidationClient<Face, ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().invalidateAuthenticatorId();
|
||||
getFreshDaemon().getSession().invalidateAuthenticatorId();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.face.Face;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -31,16 +30,17 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific removal client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
class FaceRemovalClient extends RemovalClient<Face, ISession> {
|
||||
class FaceRemovalClient extends RemovalClient<Face, AidlSession> {
|
||||
private static final String TAG = "FaceRemovalClient";
|
||||
|
||||
final int[] mBiometricIds;
|
||||
|
||||
FaceRemovalClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FaceRemovalClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
|
||||
int[] biometricIds, int userId, @NonNull String owner,
|
||||
@NonNull BiometricUtils<Face> utils, int sensorId,
|
||||
@@ -53,7 +53,7 @@ class FaceRemovalClient extends RemovalClient<Face, ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().removeEnrollments(mBiometricIds);
|
||||
getFreshDaemon().getSession().removeEnrollments(mBiometricIds);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting remove", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.keymaster.HardwareAuthToken;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -34,12 +33,14 @@ import com.android.server.biometrics.sensors.LockoutCache;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific resetLockout client for the {@link IFace} AIDL HAL interface.
|
||||
* Updates the framework's lockout cache and notifies clients such as Keyguard when lockout is
|
||||
* cleared.
|
||||
*/
|
||||
public class FaceResetLockoutClient extends HalClientMonitor<ISession> implements ErrorConsumer {
|
||||
public class FaceResetLockoutClient extends HalClientMonitor<AidlSession> implements ErrorConsumer {
|
||||
|
||||
private static final String TAG = "FaceResetLockoutClient";
|
||||
|
||||
@@ -48,7 +49,7 @@ public class FaceResetLockoutClient extends HalClientMonitor<ISession> implement
|
||||
private final LockoutResetDispatcher mLockoutResetDispatcher;
|
||||
|
||||
FaceResetLockoutClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull LockoutCache lockoutTracker,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||
@@ -73,7 +74,7 @@ public class FaceResetLockoutClient extends HalClientMonitor<ISession> implement
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().resetLockout(mHardwareAuthToken);
|
||||
getFreshDaemon().getSession().resetLockout(mHardwareAuthToken);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to reset lockout", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -19,24 +19,25 @@ package com.android.server.biometrics.sensors.face.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.RevokeChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific revokeChallenge client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
public class FaceRevokeChallengeClient extends RevokeChallengeClient<ISession> {
|
||||
public class FaceRevokeChallengeClient extends RevokeChallengeClient<AidlSession> {
|
||||
|
||||
private static final String TAG = "FaceRevokeChallengeClient";
|
||||
|
||||
private final long mChallenge;
|
||||
|
||||
FaceRevokeChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token,
|
||||
int userId, @NonNull String owner, int sensorId, long challenge) {
|
||||
super(context, lazyDaemon, token, userId, owner, sensorId);
|
||||
mChallenge = challenge;
|
||||
@@ -45,7 +46,7 @@ public class FaceRevokeChallengeClient extends RevokeChallengeClient<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().revokeChallenge(mChallenge);
|
||||
getFreshDaemon().getSession().revokeChallenge(mChallenge);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to revokeChallenge", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.hardware.keymaster.HardwareAuthToken;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -33,10 +32,12 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.ErrorConsumer;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific get feature client for the {@link IFace} AIDL HAL interface.
|
||||
*/
|
||||
public class FaceSetFeatureClient extends HalClientMonitor<ISession> implements ErrorConsumer {
|
||||
public class FaceSetFeatureClient extends HalClientMonitor<AidlSession> implements ErrorConsumer {
|
||||
|
||||
private static final String TAG = "FaceSetFeatureClient";
|
||||
|
||||
@@ -44,7 +45,7 @@ public class FaceSetFeatureClient extends HalClientMonitor<ISession> implements
|
||||
private final boolean mEnabled;
|
||||
private final HardwareAuthToken mHardwareAuthToken;
|
||||
|
||||
FaceSetFeatureClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FaceSetFeatureClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId, int feature, boolean enabled,
|
||||
byte[] hardwareAuthToken) {
|
||||
@@ -74,8 +75,7 @@ public class FaceSetFeatureClient extends HalClientMonitor<ISession> implements
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon()
|
||||
.setFeature(mHardwareAuthToken,
|
||||
getFreshDaemon().getSession().setFeature(mHardwareAuthToken,
|
||||
AidlConversionUtils.convertFrameworkToAidlFeature(mFeature), mEnabled);
|
||||
} catch (RemoteException | IllegalArgumentException e) {
|
||||
Slog.e(TAG, "Unable to set feature: " + mFeature + " to enabled: " + mEnabled, e);
|
||||
|
||||
@@ -30,12 +30,15 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.StartUserClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FaceStartUserClient extends StartUserClient<IFace, ISession> {
|
||||
private static final String TAG = "FaceStartUserClient";
|
||||
|
||||
@NonNull private final ISessionCallback mSessionCallback;
|
||||
|
||||
public FaceStartUserClient(@NonNull Context context, @NonNull LazyDaemon<IFace> lazyDaemon,
|
||||
public FaceStartUserClient(@NonNull Context context,
|
||||
@NonNull Supplier<IFace> lazyDaemon,
|
||||
@Nullable IBinder token, int userId, int sensorId,
|
||||
@NonNull ISessionCallback sessionCallback,
|
||||
@NonNull UserStartedCallback<ISession> callback) {
|
||||
@@ -52,10 +55,12 @@ public class FaceStartUserClient extends StartUserClient<IFace, ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
final ISession newSession = getFreshDaemon().createSession(getSensorId(),
|
||||
final IFace hal = getFreshDaemon();
|
||||
final int version = hal.getInterfaceVersion();
|
||||
final ISession newSession = hal.createSession(getSensorId(),
|
||||
getTargetUserId(), mSessionCallback);
|
||||
Binder.allowBlocking(newSession.asBinder());
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), newSession);
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), newSession, version);
|
||||
getCallback().onClientFinished(this, true /* success */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
@@ -65,6 +70,5 @@ public class FaceStartUserClient extends StartUserClient<IFace, ISession> {
|
||||
|
||||
@Override
|
||||
public void unableToStart() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.face.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.face.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -27,10 +26,12 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.StopUserClient;
|
||||
|
||||
public class FaceStopUserClient extends StopUserClient<ISession> {
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FaceStopUserClient extends StopUserClient<AidlSession> {
|
||||
private static final String TAG = "FaceStopUserClient";
|
||||
|
||||
public FaceStopUserClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
public FaceStopUserClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@Nullable IBinder token, int userId, int sensorId,
|
||||
@NonNull UserStoppedCallback callback) {
|
||||
super(context, lazyDaemon, token, userId, sensorId, callback);
|
||||
@@ -45,7 +46,7 @@ public class FaceStopUserClient extends StopUserClient<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().close();
|
||||
getFreshDaemon().getSession().close();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
getCallback().onClientFinished(this, false /* success */);
|
||||
@@ -54,6 +55,5 @@ public class FaceStopUserClient extends StopUserClient<ISession> {
|
||||
|
||||
@Override
|
||||
public void unableToStart() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.EnumerateConsumer;
|
||||
import com.android.server.biometrics.sensors.ErrorConsumer;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
import com.android.server.biometrics.sensors.Interruptable;
|
||||
import com.android.server.biometrics.sensors.LockoutCache;
|
||||
import com.android.server.biometrics.sensors.LockoutConsumer;
|
||||
@@ -67,6 +66,7 @@ import com.android.server.biometrics.sensors.face.FaceUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Maintains the state of a single sensor within an instance of the {@link IFace} HAL.
|
||||
@@ -84,24 +84,9 @@ public class Sensor {
|
||||
@NonNull private final UserAwareBiometricScheduler mScheduler;
|
||||
@NonNull private final LockoutCache mLockoutCache;
|
||||
@NonNull private final Map<Integer, Long> mAuthenticatorIds;
|
||||
@NonNull private final HalClientMonitor.LazyDaemon<ISession> mLazySession;
|
||||
@Nullable private Session mCurrentSession;
|
||||
|
||||
static class Session {
|
||||
@NonNull final HalSessionCallback mHalSessionCallback;
|
||||
@NonNull private final String mTag;
|
||||
@NonNull private final ISession mSession;
|
||||
private final int mUserId;
|
||||
|
||||
Session(@NonNull String tag, @NonNull ISession session, int userId,
|
||||
@NonNull HalSessionCallback halSessionCallback) {
|
||||
mTag = tag;
|
||||
mSession = session;
|
||||
mUserId = userId;
|
||||
mHalSessionCallback = halSessionCallback;
|
||||
Slog.d(mTag, "New session created for user: " + userId);
|
||||
}
|
||||
}
|
||||
@NonNull private final Supplier<AidlSession> mLazySession;
|
||||
@Nullable private AidlSession mCurrentSession;
|
||||
|
||||
static class HalSessionCallback extends ISessionCallback.Stub {
|
||||
/**
|
||||
@@ -496,7 +481,7 @@ public class Sensor {
|
||||
mSensorProperties = sensorProperties;
|
||||
mScheduler = new UserAwareBiometricScheduler(tag,
|
||||
BiometricScheduler.SENSOR_TYPE_FACE, null /* gestureAvailabilityDispatcher */,
|
||||
() -> mCurrentSession != null ? mCurrentSession.mUserId : UserHandle.USER_NULL,
|
||||
() -> mCurrentSession != null ? mCurrentSession.getUserId() : UserHandle.USER_NULL,
|
||||
new UserAwareBiometricScheduler.UserSwitchCallback() {
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -508,21 +493,22 @@ public class Sensor {
|
||||
@NonNull
|
||||
@Override
|
||||
public StartUserClient<?, ?> getStartUserClient(int newUserId) {
|
||||
final HalSessionCallback.Callback callback = () -> {
|
||||
Slog.e(mTag, "Got ERROR_HW_UNAVAILABLE");
|
||||
mCurrentSession = null;
|
||||
};
|
||||
|
||||
final int sensorId = mSensorProperties.sensorId;
|
||||
|
||||
final HalSessionCallback resultController = new HalSessionCallback(mContext,
|
||||
mHandler, mTag, mScheduler, sensorId, newUserId, mLockoutCache,
|
||||
lockoutResetDispatcher, callback);
|
||||
lockoutResetDispatcher, () -> {
|
||||
Slog.e(mTag, "Got ERROR_HW_UNAVAILABLE");
|
||||
mCurrentSession = null;
|
||||
});
|
||||
|
||||
final StartUserClient.UserStartedCallback<ISession> userStartedCallback =
|
||||
(userIdStarted, newSession) -> {
|
||||
mCurrentSession = new Session(mTag, newSession, userIdStarted,
|
||||
resultController);
|
||||
(userIdStarted, newSession, halInterfaceVersion) -> {
|
||||
Slog.d(mTag, "New session created for user: "
|
||||
+ userIdStarted + " with hal version: "
|
||||
+ halInterfaceVersion);
|
||||
mCurrentSession = new AidlSession(halInterfaceVersion,
|
||||
newSession, userIdStarted, resultController);
|
||||
if (FaceUtils.getLegacyInstance(sensorId)
|
||||
.isInvalidationInProgress(mContext, userIdStarted)) {
|
||||
Slog.w(mTag,
|
||||
@@ -542,10 +528,10 @@ public class Sensor {
|
||||
});
|
||||
mLockoutCache = new LockoutCache();
|
||||
mAuthenticatorIds = new HashMap<>();
|
||||
mLazySession = () -> mCurrentSession != null ? mCurrentSession.mSession : null;
|
||||
mLazySession = () -> mCurrentSession != null ? mCurrentSession : null;
|
||||
}
|
||||
|
||||
@NonNull HalClientMonitor.LazyDaemon<ISession> getLazySession() {
|
||||
@NonNull Supplier<AidlSession> getLazySession() {
|
||||
return mLazySession;
|
||||
}
|
||||
|
||||
@@ -553,8 +539,8 @@ public class Sensor {
|
||||
return mSensorProperties;
|
||||
}
|
||||
|
||||
@Nullable Session getSessionForUser(int userId) {
|
||||
if (mCurrentSession != null && mCurrentSession.mUserId == userId) {
|
||||
@Nullable AidlSession getSessionForUser(int userId) {
|
||||
if (mCurrentSession != null && mCurrentSession.getUserId() == userId) {
|
||||
return mCurrentSession;
|
||||
} else {
|
||||
return null;
|
||||
@@ -583,10 +569,10 @@ public class Sensor {
|
||||
if (enabled != mTestHalEnabled) {
|
||||
// The framework should retrieve a new session from the HAL.
|
||||
try {
|
||||
if (mCurrentSession != null && mCurrentSession.mSession != null) {
|
||||
if (mCurrentSession != null) {
|
||||
// TODO(181984005): This should be scheduled instead of directly invoked
|
||||
Slog.d(mTag, "Closing old session");
|
||||
mCurrentSession.mSession.close();
|
||||
mCurrentSession.getSession().close();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(mTag, "RemoteException", e);
|
||||
|
||||
@@ -64,7 +64,6 @@ import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.EnumerateConsumer;
|
||||
import com.android.server.biometrics.sensors.ErrorConsumer;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
import com.android.server.biometrics.sensors.PerformanceTracker;
|
||||
@@ -89,6 +88,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Supports a single instance of the {@link android.hardware.biometrics.face.V1_0} or its extended
|
||||
@@ -111,7 +111,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
@NonNull private final Context mContext;
|
||||
@NonNull private final BiometricScheduler mScheduler;
|
||||
@NonNull private final Handler mHandler;
|
||||
@NonNull private final HalClientMonitor.LazyDaemon<IBiometricsFace> mLazyDaemon;
|
||||
@NonNull private final Supplier<IBiometricsFace> mLazyDaemon;
|
||||
@NonNull private final LockoutHalImpl mLockoutTracker;
|
||||
@NonNull private final UsageStats mUsageStats;
|
||||
@NonNull private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
import com.android.server.biometrics.sensors.face.UsageStats;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific authentication client supporting the {@link android.hardware.biometrics.face.V1_0}
|
||||
@@ -61,7 +62,7 @@ class FaceAuthenticationClient extends AuthenticationClient<IBiometricsFace> {
|
||||
private SensorPrivacyManager mSensorPrivacyManager;
|
||||
|
||||
FaceAuthenticationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int targetUserId, long operationId,
|
||||
boolean restricted, String owner, int cookie, boolean requireConfirmation, int sensorId,
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.android.server.biometrics.sensors.EnrollClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific enroll client supporting the {@link android.hardware.biometrics.face.V1_0} HIDL
|
||||
@@ -53,7 +54,7 @@ public class FaceEnrollClient extends EnrollClient<IBiometricsFace> {
|
||||
@NonNull private final int[] mEnrollIgnoreList;
|
||||
@NonNull private final int[] mEnrollIgnoreListVendor;
|
||||
|
||||
FaceEnrollClient(@NonNull Context context, @NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
||||
FaceEnrollClient(@NonNull Context context, @NonNull Supplier<IBiometricsFace> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull String owner, long requestId,
|
||||
@NonNull BiometricUtils<Face> utils, @NonNull int[] disabledFeatures, int timeoutSec,
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.android.server.biometrics.sensors.GenerateChallengeClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific generateChallenge client supporting the
|
||||
@@ -48,7 +49,7 @@ public class FaceGenerateChallengeClient extends GenerateChallengeClient<IBiomet
|
||||
private Long mChallengeResult;
|
||||
|
||||
FaceGenerateChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId, @NonNull String owner,
|
||||
int sensorId, long now) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, sensorId);
|
||||
|
||||
@@ -32,6 +32,8 @@ import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific getFeature client supporting the {@link android.hardware.biometrics.face.V1_0}
|
||||
* HIDL interface.
|
||||
@@ -44,7 +46,7 @@ public class FaceGetFeatureClient extends HalClientMonitor<IBiometricsFace> {
|
||||
private final int mFaceId;
|
||||
private boolean mValue;
|
||||
|
||||
FaceGetFeatureClient(@NonNull Context context, @NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
||||
FaceGetFeatureClient(@NonNull Context context, @NonNull Supplier<IBiometricsFace> lazyDaemon,
|
||||
@NonNull IBinder token, @Nullable ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId, int feature, int faceId) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific internal cleanup client supporting the
|
||||
@@ -38,7 +39,7 @@ import java.util.Map;
|
||||
class FaceInternalCleanupClient extends InternalCleanupClient<Face, IBiometricsFace> {
|
||||
|
||||
FaceInternalCleanupClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId, @NonNull List<Face> enrolledList, @NonNull BiometricUtils<Face> utils,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, userId, owner, sensorId, BiometricsProtoEnums.MODALITY_FACE,
|
||||
@@ -47,7 +48,7 @@ class FaceInternalCleanupClient extends InternalCleanupClient<Face, IBiometricsF
|
||||
|
||||
@Override
|
||||
protected InternalEnumerateClient<IBiometricsFace> getEnumerateClient(Context context,
|
||||
LazyDaemon<IBiometricsFace> lazyDaemon, IBinder token, int userId, String owner,
|
||||
Supplier<IBiometricsFace> lazyDaemon, IBinder token, int userId, String owner,
|
||||
List<Face> enrolledList, BiometricUtils<Face> utils, int sensorId) {
|
||||
return new FaceInternalEnumerateClient(context, lazyDaemon, token, userId, owner,
|
||||
enrolledList, utils, sensorId);
|
||||
@@ -55,7 +56,7 @@ class FaceInternalCleanupClient extends InternalCleanupClient<Face, IBiometricsF
|
||||
|
||||
@Override
|
||||
protected RemovalClient<Face, IBiometricsFace> getRemovalClient(Context context,
|
||||
LazyDaemon<IBiometricsFace> lazyDaemon, IBinder token,
|
||||
Supplier<IBiometricsFace> lazyDaemon, IBinder token,
|
||||
int biometricId, int userId, String owner, BiometricUtils<Face> utils, int sensorId,
|
||||
Map<Integer, Long> authenticatorIds) {
|
||||
// Internal remove does not need to send results to anyone. Cleanup (enumerate + remove)
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.android.server.biometrics.sensors.BiometricUtils;
|
||||
import com.android.server.biometrics.sensors.InternalEnumerateClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific internal enumerate client supporting the
|
||||
@@ -38,7 +39,7 @@ class FaceInternalEnumerateClient extends InternalEnumerateClient<IBiometricsFac
|
||||
private static final String TAG = "FaceInternalEnumerateClient";
|
||||
|
||||
FaceInternalEnumerateClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull String owner, @NonNull List<Face> enrolledList,
|
||||
@NonNull BiometricUtils<Face> utils, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, enrolledList, utils, sensorId,
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific removal client supporting the {@link android.hardware.biometrics.face.V1_0}
|
||||
@@ -40,7 +41,7 @@ class FaceRemovalClient extends RemovalClient<Face, IBiometricsFace> {
|
||||
|
||||
private final int mBiometricId;
|
||||
|
||||
FaceRemovalClient(@NonNull Context context, @NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
||||
FaceRemovalClient(@NonNull Context context, @NonNull Supplier<IBiometricsFace> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
|
||||
int biometricId, int userId, @NonNull String owner, @NonNull BiometricUtils<Face> utils,
|
||||
int sensorId, @NonNull Map<Integer, Long> authenticatorIds) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific resetLockout client supporting the {@link android.hardware.biometrics.face.V1_0}
|
||||
@@ -40,7 +41,7 @@ public class FaceResetLockoutClient extends HalClientMonitor<IBiometricsFace> {
|
||||
private final ArrayList<Byte> mHardwareAuthToken;
|
||||
|
||||
FaceResetLockoutClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull byte[] hardwareAuthToken) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||
0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_UNKNOWN,
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.RevokeChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific revokeChallenge client supporting the {@link android.hardware.biometrics.face.V1_0}
|
||||
* HIDL interface.
|
||||
@@ -34,7 +36,7 @@ public class FaceRevokeChallengeClient extends RevokeChallengeClient<IBiometrics
|
||||
private static final String TAG = "FaceRevokeChallengeClient";
|
||||
|
||||
FaceRevokeChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon, @NonNull IBinder token,
|
||||
int userId, @NonNull String owner, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, sensorId);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Face-specific setFeature client supporting the {@link android.hardware.biometrics.face.V1_0}
|
||||
@@ -45,7 +46,7 @@ public class FaceSetFeatureClient extends HalClientMonitor<IBiometricsFace> {
|
||||
private final ArrayList<Byte> mHardwareAuthToken;
|
||||
private final int mFaceId;
|
||||
|
||||
FaceSetFeatureClient(@NonNull Context context, @NonNull LazyDaemon<IBiometricsFace> lazyDaemon,
|
||||
FaceSetFeatureClient(@NonNull Context context, @NonNull Supplier<IBiometricsFace> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId, int feature, boolean enabled,
|
||||
byte[] hardwareAuthToken, int faceId) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FaceUpdateActiveUserClient extends HalClientMonitor<IBiometricsFace> {
|
||||
private static final String TAG = "FaceUpdateActiveUserClient";
|
||||
@@ -39,7 +40,7 @@ public class FaceUpdateActiveUserClient extends HalClientMonitor<IBiometricsFace
|
||||
@NonNull private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
FaceUpdateActiveUserClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
|
||||
@NonNull Supplier<IBiometricsFace> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId, boolean hasEnrolledBiometrics,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
|
||||
import static com.android.server.biometrics.sensors.fingerprint.aidl.Sensor.HalSessionCallback;
|
||||
|
||||
/**
|
||||
* A holder for an AIDL {@link ISession} with additional metadata about the current user
|
||||
* and the backend.
|
||||
*/
|
||||
public class AidlSession {
|
||||
|
||||
private final int mHalInterfaceVersion;
|
||||
@NonNull private final ISession mSession;
|
||||
private final int mUserId;
|
||||
@NonNull private final HalSessionCallback mHalSessionCallback;
|
||||
|
||||
public AidlSession(int halInterfaceVersion, @NonNull ISession session, int userId,
|
||||
HalSessionCallback halSessionCallback) {
|
||||
mHalInterfaceVersion = halInterfaceVersion;
|
||||
mSession = session;
|
||||
mUserId = userId;
|
||||
mHalSessionCallback = halSessionCallback;
|
||||
}
|
||||
|
||||
/** The underlying {@link ISession}. */
|
||||
@NonNull public ISession getSession() {
|
||||
return mSession;
|
||||
}
|
||||
|
||||
/** The user id associated with the session. */
|
||||
public int getUserId() {
|
||||
return mUserId;
|
||||
}
|
||||
|
||||
/** The HAL callback, which should only be used in tests {@See BiometricTestSessionImpl}. */
|
||||
HalSessionCallback getHalSessionCallback() {
|
||||
return mHalSessionCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this backend implements the *WithContext methods for enroll, authenticate, and
|
||||
* detectInteraction. These variants should always be called if they are available.
|
||||
*/
|
||||
public boolean hasContextMethods() {
|
||||
return mHalInterfaceVersion >= 2;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
}
|
||||
|
||||
mEnrollmentIds.add(nextRandomId);
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback()
|
||||
.onEnrollmentProgress(nextRandomId, 0 /* remaining */);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
return;
|
||||
}
|
||||
final int fid = fingerprints.get(0).getBiometricId();
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationSucceeded(fid,
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onAuthenticationSucceeded(fid,
|
||||
HardwareAuthTokenUtils.toHardwareAuthToken(new byte[69]));
|
||||
}
|
||||
|
||||
@@ -181,14 +181,14 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void rejectAuthentication(int userId) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onAuthenticationFailed();
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onAuthenticationFailed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAcquired(int userId, int acquireInfo) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback()
|
||||
.onAcquired((byte) acquireInfo, 0 /* vendorCode */);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void notifyError(int userId, int errorCode) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mSensor.getSessionForUser(userId).mHalSessionCallback.onError((byte) errorCode,
|
||||
mSensor.getSessionForUser(userId).getHalSessionCallback().onError((byte) errorCode,
|
||||
0 /* vendorCode */);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ import android.hardware.biometrics.BiometricFingerprintConstants;
|
||||
import android.hardware.biometrics.BiometricFingerprintConstants.FingerprintAcquired;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.biometrics.common.OperationContext;
|
||||
import android.hardware.biometrics.common.OperationReason;
|
||||
import android.hardware.biometrics.fingerprint.PointerContext;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
@@ -47,12 +49,13 @@ import com.android.server.biometrics.sensors.SensorOverlays;
|
||||
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific authentication client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} AIDL interface.
|
||||
*/
|
||||
class FingerprintAuthenticationClient extends AuthenticationClient<ISession> implements
|
||||
class FingerprintAuthenticationClient extends AuthenticationClient<AidlSession> implements
|
||||
Udfps, LockoutConsumer {
|
||||
private static final String TAG = "FingerprintAuthenticationClient";
|
||||
|
||||
@@ -65,7 +68,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
|
||||
private boolean mIsPointerDown;
|
||||
|
||||
FingerprintAuthenticationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int targetUserId, long operationId,
|
||||
boolean restricted, @NonNull String owner, int cookie, boolean requireConfirmation,
|
||||
@@ -158,7 +161,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
|
||||
mSensorOverlays.show(getSensorId(), getShowOverlayReason(), this);
|
||||
|
||||
try {
|
||||
mCancellationSignal = getFreshDaemon().authenticate(mOperationId);
|
||||
mCancellationSignal = doAuthenticate();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
onError(BiometricFingerprintConstants.FINGERPRINT_ERROR_HW_UNAVAILABLE,
|
||||
@@ -168,6 +171,22 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
|
||||
}
|
||||
}
|
||||
|
||||
private ICancellationSignal doAuthenticate() throws RemoteException {
|
||||
final AidlSession session = getFreshDaemon();
|
||||
|
||||
if (session.hasContextMethods()) {
|
||||
final OperationContext context = new OperationContext();
|
||||
// TODO: add reason, id, and isAoD
|
||||
context.id = 0;
|
||||
context.reason = OperationReason.UNKNOWN;
|
||||
context.isAoD = false;
|
||||
context.isCrypto = isCryptoOperation();
|
||||
return session.getSession().authenticateWithContext(mOperationId, context);
|
||||
} else {
|
||||
return session.getSession().authenticate(mOperationId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stopHalOperation() {
|
||||
mSensorOverlays.hide(getSensorId());
|
||||
@@ -191,7 +210,20 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
|
||||
mIsPointerDown = true;
|
||||
mState = STATE_STARTED;
|
||||
mALSProbeCallback.getProbe().enable();
|
||||
getFreshDaemon().onPointerDown(0 /* pointerId */, x, y, minor, major);
|
||||
|
||||
final AidlSession session = getFreshDaemon();
|
||||
if (session.hasContextMethods()) {
|
||||
final PointerContext context = new PointerContext();
|
||||
context.pointerId = 0;
|
||||
context.x = x;
|
||||
context.y = y;
|
||||
context.minor = minor;
|
||||
context.major = major;
|
||||
context.isAoD = false; // TODO; get value
|
||||
session.getSession().onPointerDownWithContext(context);
|
||||
} else {
|
||||
session.getSession().onPointerDown(0 /* pointerId */, x, y, minor, major);
|
||||
}
|
||||
|
||||
if (getListener() != null) {
|
||||
getListener().onUdfpsPointerDown(getSensorId());
|
||||
@@ -207,7 +239,15 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
|
||||
mIsPointerDown = false;
|
||||
mState = STATE_STARTED_PAUSED_ATTEMPTED;
|
||||
mALSProbeCallback.getProbe().disable();
|
||||
getFreshDaemon().onPointerUp(0 /* pointerId */);
|
||||
|
||||
final AidlSession session = getFreshDaemon();
|
||||
if (session.hasContextMethods()) {
|
||||
final PointerContext context = new PointerContext();
|
||||
context.pointerId = 0;
|
||||
session.getSession().onPointerUpWithContext(context);
|
||||
} else {
|
||||
session.getSession().onPointerUp(0 /* pointerId */);
|
||||
}
|
||||
|
||||
if (getListener() != null) {
|
||||
getListener().onUdfpsPointerUp(getSensorId());
|
||||
@@ -225,7 +265,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<ISession> imp
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
try {
|
||||
getFreshDaemon().onUiReady();
|
||||
getFreshDaemon().getSession().onUiReady();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricOverlayConstants;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.biometrics.common.OperationContext;
|
||||
import android.hardware.biometrics.common.OperationReason;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -35,11 +36,13 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.DetectionConsumer;
|
||||
import com.android.server.biometrics.sensors.SensorOverlays;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Performs fingerprint detection without exposing any matching information (e.g. accept/reject
|
||||
* have the same haptic, lockout counter is not increased).
|
||||
*/
|
||||
class FingerprintDetectClient extends AcquisitionClient<ISession> implements DetectionConsumer {
|
||||
class FingerprintDetectClient extends AcquisitionClient<AidlSession> implements DetectionConsumer {
|
||||
|
||||
private static final String TAG = "FingerprintDetectClient";
|
||||
|
||||
@@ -47,7 +50,7 @@ class FingerprintDetectClient extends AcquisitionClient<ISession> implements Det
|
||||
@NonNull private final SensorOverlays mSensorOverlays;
|
||||
@Nullable private ICancellationSignal mCancellationSignal;
|
||||
|
||||
FingerprintDetectClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
FingerprintDetectClient(@NonNull Context context, @NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull String owner, int sensorId,
|
||||
@@ -84,7 +87,7 @@ class FingerprintDetectClient extends AcquisitionClient<ISession> implements Det
|
||||
mSensorOverlays.show(getSensorId(), BiometricOverlayConstants.REASON_AUTH_KEYGUARD, this);
|
||||
|
||||
try {
|
||||
mCancellationSignal = getFreshDaemon().detectInteraction();
|
||||
mCancellationSignal = doDetectInteraction();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting finger detect", e);
|
||||
mSensorOverlays.hide(getSensorId());
|
||||
@@ -92,6 +95,22 @@ class FingerprintDetectClient extends AcquisitionClient<ISession> implements Det
|
||||
}
|
||||
}
|
||||
|
||||
private ICancellationSignal doDetectInteraction() throws RemoteException {
|
||||
final AidlSession session = getFreshDaemon();
|
||||
|
||||
if (session.hasContextMethods()) {
|
||||
final OperationContext context = new OperationContext();
|
||||
// TODO: add reason, id, and isAoD
|
||||
context.id = 0;
|
||||
context.reason = OperationReason.UNKNOWN;
|
||||
context.isAoD = false;
|
||||
context.isCrypto = isCryptoOperation();
|
||||
return session.getSession().detectInteractionWithContext(context);
|
||||
} else {
|
||||
return session.getSession().detectInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteractionDetected() {
|
||||
vibrateSuccess();
|
||||
|
||||
@@ -24,12 +24,15 @@ import android.hardware.biometrics.BiometricFingerprintConstants;
|
||||
import android.hardware.biometrics.BiometricFingerprintConstants.FingerprintAcquired;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.common.ICancellationSignal;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.biometrics.common.OperationContext;
|
||||
import android.hardware.biometrics.common.OperationReason;
|
||||
import android.hardware.biometrics.fingerprint.PointerContext;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.ISidefpsController;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.hardware.keymaster.HardwareAuthToken;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -46,7 +49,9 @@ import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
import com.android.server.biometrics.sensors.fingerprint.UdfpsHelper;
|
||||
|
||||
class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class FingerprintEnrollClient extends EnrollClient<AidlSession> implements Udfps {
|
||||
|
||||
private static final String TAG = "FingerprintEnrollClient";
|
||||
|
||||
@@ -59,7 +64,7 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
private boolean mIsPointerDown;
|
||||
|
||||
FingerprintEnrollClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token, long requestId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull String owner,
|
||||
@NonNull BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
@@ -156,8 +161,7 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
|
||||
BiometricNotificationUtils.cancelBadCalibrationNotification(getContext());
|
||||
try {
|
||||
mCancellationSignal = getFreshDaemon().enroll(
|
||||
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken));
|
||||
mCancellationSignal = doEnroll();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting enroll", e);
|
||||
onError(BiometricFingerprintConstants.FINGERPRINT_ERROR_UNABLE_TO_PROCESS,
|
||||
@@ -166,11 +170,42 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
}
|
||||
}
|
||||
|
||||
private ICancellationSignal doEnroll() throws RemoteException {
|
||||
final AidlSession session = getFreshDaemon();
|
||||
final HardwareAuthToken hat =
|
||||
HardwareAuthTokenUtils.toHardwareAuthToken(mHardwareAuthToken);
|
||||
|
||||
if (session.hasContextMethods()) {
|
||||
final OperationContext context = new OperationContext();
|
||||
// TODO: add reason, id, and isAoD
|
||||
context.id = 0;
|
||||
context.reason = OperationReason.UNKNOWN;
|
||||
context.isAoD = false;
|
||||
context.isCrypto = isCryptoOperation();
|
||||
return session.getSession().enrollWithContext(hat, context);
|
||||
} else {
|
||||
return session.getSession().enroll(hat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerDown(int x, int y, float minor, float major) {
|
||||
try {
|
||||
mIsPointerDown = true;
|
||||
getFreshDaemon().onPointerDown(0 /* pointerId */, x, y, minor, major);
|
||||
|
||||
final AidlSession session = getFreshDaemon();
|
||||
if (session.hasContextMethods()) {
|
||||
final PointerContext context = new PointerContext();
|
||||
context.pointerId = 0;
|
||||
context.x = x;
|
||||
context.y = y;
|
||||
context.minor = minor;
|
||||
context.major = major;
|
||||
context.isAoD = false;
|
||||
session.getSession().onPointerDownWithContext(context);
|
||||
} else {
|
||||
session.getSession().onPointerDown(0 /* pointerId */, x, y, minor, major);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to send pointer down", e);
|
||||
}
|
||||
@@ -180,7 +215,15 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
public void onPointerUp() {
|
||||
try {
|
||||
mIsPointerDown = false;
|
||||
getFreshDaemon().onPointerUp(0 /* pointerId */);
|
||||
|
||||
final AidlSession session = getFreshDaemon();
|
||||
if (session.hasContextMethods()) {
|
||||
final PointerContext context = new PointerContext();
|
||||
context.pointerId = 0;
|
||||
session.getSession().onPointerUpWithContext(context);
|
||||
} else {
|
||||
session.getSession().onPointerUp(0 /* pointerId */);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to send pointer up", e);
|
||||
}
|
||||
@@ -194,7 +237,7 @@ class FingerprintEnrollClient extends EnrollClient<ISession> implements Udfps {
|
||||
@Override
|
||||
public void onUiReady() {
|
||||
try {
|
||||
getFreshDaemon().onUiReady();
|
||||
getFreshDaemon().getSession().onUiReady();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to send UI ready", e);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -27,14 +26,16 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.GenerateChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific generateChallenge client for the {@link IFingerprint} AIDL HAL interface.
|
||||
*/
|
||||
class FingerprintGenerateChallengeClient extends GenerateChallengeClient<ISession> {
|
||||
class FingerprintGenerateChallengeClient extends GenerateChallengeClient<AidlSession> {
|
||||
private static final String TAG = "FingerprintGenerateChallengeClient";
|
||||
|
||||
FingerprintGenerateChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon,
|
||||
@NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener,
|
||||
int userId, @NonNull String owner, int sensorId) {
|
||||
@@ -44,7 +45,7 @@ class FingerprintGenerateChallengeClient extends GenerateChallengeClient<ISessio
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().generateChallenge();
|
||||
getFreshDaemon().getSession().generateChallenge();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to generateChallenge", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
@@ -28,15 +27,16 @@ import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class FingerprintGetAuthenticatorIdClient extends HalClientMonitor<ISession> {
|
||||
class FingerprintGetAuthenticatorIdClient extends HalClientMonitor<AidlSession> {
|
||||
|
||||
private static final String TAG = "FingerprintGetAuthenticatorIdClient";
|
||||
|
||||
private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
FingerprintGetAuthenticatorIdClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, @NonNull String owner,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId, Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||
0 /* cookie */, sensorId, BiometricsProtoEnums.MODALITY_FINGERPRINT,
|
||||
@@ -57,7 +57,7 @@ class FingerprintGetAuthenticatorIdClient extends HalClientMonitor<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().getAuthenticatorId();
|
||||
getFreshDaemon().getSession().getAuthenticatorId();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.IBinder;
|
||||
|
||||
@@ -31,15 +30,16 @@ import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific internal cleanup client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} AIDL interface.
|
||||
*/
|
||||
class FingerprintInternalCleanupClient extends InternalCleanupClient<Fingerprint, ISession> {
|
||||
class FingerprintInternalCleanupClient extends InternalCleanupClient<Fingerprint, AidlSession> {
|
||||
|
||||
FingerprintInternalCleanupClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, @NonNull String owner,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, @NonNull String owner,
|
||||
int sensorId, @NonNull List<Fingerprint> enrolledList,
|
||||
@NonNull FingerprintUtils utils, @NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, userId, owner, sensorId,
|
||||
@@ -47,16 +47,16 @@ class FingerprintInternalCleanupClient extends InternalCleanupClient<Fingerprint
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InternalEnumerateClient<ISession> getEnumerateClient(Context context,
|
||||
LazyDaemon<ISession> lazyDaemon, IBinder token, int userId, String owner,
|
||||
protected InternalEnumerateClient<AidlSession> getEnumerateClient(Context context,
|
||||
Supplier<AidlSession> lazyDaemon, IBinder token, int userId, String owner,
|
||||
List<Fingerprint> enrolledList, BiometricUtils<Fingerprint> utils, int sensorId) {
|
||||
return new FingerprintInternalEnumerateClient(context, lazyDaemon, token, userId, owner,
|
||||
enrolledList, utils, sensorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemovalClient<Fingerprint, ISession> getRemovalClient(Context context,
|
||||
LazyDaemon<ISession> lazyDaemon, IBinder token, int biometricId, int userId,
|
||||
protected RemovalClient<Fingerprint, AidlSession> getRemovalClient(Context context,
|
||||
Supplier<AidlSession> lazyDaemon, IBinder token, int biometricId, int userId,
|
||||
String owner, BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
Map<Integer, Long> authenticatorIds) {
|
||||
return new FingerprintRemovalClient(context, lazyDaemon, token,
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -29,16 +28,17 @@ import com.android.server.biometrics.sensors.BiometricUtils;
|
||||
import com.android.server.biometrics.sensors.InternalEnumerateClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific internal client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} AIDL interface.
|
||||
*/
|
||||
class FingerprintInternalEnumerateClient extends InternalEnumerateClient<ISession> {
|
||||
class FingerprintInternalEnumerateClient extends InternalEnumerateClient<AidlSession> {
|
||||
private static final String TAG = "FingerprintInternalEnumerateClient";
|
||||
|
||||
protected FingerprintInternalEnumerateClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token, int userId,
|
||||
@NonNull String owner, @NonNull List<Fingerprint> enrolledList,
|
||||
@NonNull BiometricUtils<Fingerprint> utils, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, enrolledList, utils, sensorId,
|
||||
@@ -48,7 +48,7 @@ class FingerprintInternalEnumerateClient extends InternalEnumerateClient<ISessio
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().enumerateEnrollments();
|
||||
getFreshDaemon().getSession().enumerateEnrollments();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting enumerate", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -27,12 +26,13 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.InvalidationClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FingerprintInvalidationClient extends InvalidationClient<Fingerprint, ISession> {
|
||||
public class FingerprintInvalidationClient extends InvalidationClient<Fingerprint, AidlSession> {
|
||||
private static final String TAG = "FingerprintInvalidationClient";
|
||||
|
||||
public FingerprintInvalidationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, int sensorId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds, @NonNull IInvalidationCallback callback) {
|
||||
super(context, lazyDaemon, userId, sensorId, authenticatorIds, callback);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class FingerprintInvalidationClient extends InvalidationClient<Fingerprin
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().invalidateAuthenticatorId();
|
||||
getFreshDaemon().getSession().invalidateAuthenticatorId();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
@@ -31,18 +30,19 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific removal client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.IFingerprint} interface.
|
||||
*/
|
||||
class FingerprintRemovalClient extends RemovalClient<Fingerprint, ISession> {
|
||||
class FingerprintRemovalClient extends RemovalClient<Fingerprint, AidlSession> {
|
||||
private static final String TAG = "FingerprintRemovalClient";
|
||||
|
||||
private final int[] mBiometricIds;
|
||||
|
||||
FingerprintRemovalClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token,
|
||||
@Nullable ClientMonitorCallbackConverter listener, int[] biometricIds, int userId,
|
||||
@NonNull String owner, @NonNull BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
@@ -54,7 +54,7 @@ class FingerprintRemovalClient extends RemovalClient<Fingerprint, ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().removeEnrollments(mBiometricIds);
|
||||
getFreshDaemon().getSession().removeEnrollments(mBiometricIds);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting remove", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.hardware.keymaster.HardwareAuthToken;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -34,12 +33,14 @@ import com.android.server.biometrics.sensors.LockoutCache;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific resetLockout client for the {@link IFingerprint} AIDL HAL interface.
|
||||
* Updates the framework's lockout cache and notifies clients such as Keyguard when lockout is
|
||||
* cleared.
|
||||
*/
|
||||
class FingerprintResetLockoutClient extends HalClientMonitor<ISession> implements ErrorConsumer {
|
||||
class FingerprintResetLockoutClient extends HalClientMonitor<AidlSession> implements ErrorConsumer {
|
||||
|
||||
private static final String TAG = "FingerprintResetLockoutClient";
|
||||
|
||||
@@ -48,7 +49,7 @@ class FingerprintResetLockoutClient extends HalClientMonitor<ISession> implement
|
||||
private final LockoutResetDispatcher mLockoutResetDispatcher;
|
||||
|
||||
FingerprintResetLockoutClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, int userId, String owner, int sensorId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull LockoutCache lockoutTracker,
|
||||
@NonNull LockoutResetDispatcher lockoutResetDispatcher) {
|
||||
super(context, lazyDaemon, null /* token */, null /* listener */, userId, owner,
|
||||
@@ -73,7 +74,7 @@ class FingerprintResetLockoutClient extends HalClientMonitor<ISession> implement
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().resetLockout(mHardwareAuthToken);
|
||||
getFreshDaemon().getSession().resetLockout(mHardwareAuthToken);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to reset lockout", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -19,24 +19,25 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.RevokeChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific revokeChallenge client for the {@link IFingerprint} AIDL HAL interface.
|
||||
*/
|
||||
class FingerprintRevokeChallengeClient extends RevokeChallengeClient<ISession> {
|
||||
class FingerprintRevokeChallengeClient extends RevokeChallengeClient<AidlSession> {
|
||||
|
||||
private static final String TAG = "FingerpirntRevokeChallengeClient";
|
||||
|
||||
private final long mChallenge;
|
||||
|
||||
FingerprintRevokeChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @NonNull IBinder token,
|
||||
int userId, @NonNull String owner, int sensorId, long challenge) {
|
||||
super(context, lazyDaemon, token, userId, owner, sensorId);
|
||||
mChallenge = challenge;
|
||||
@@ -45,7 +46,7 @@ class FingerprintRevokeChallengeClient extends RevokeChallengeClient<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().revokeChallenge(mChallenge);
|
||||
getFreshDaemon().getSession().revokeChallenge(mChallenge);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Unable to revokeChallenge", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -30,13 +30,15 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.StartUserClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FingerprintStartUserClient extends StartUserClient<IFingerprint, ISession> {
|
||||
private static final String TAG = "FingerprintStartUserClient";
|
||||
|
||||
@NonNull private final ISessionCallback mSessionCallback;
|
||||
|
||||
public FingerprintStartUserClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IFingerprint> lazyDaemon,
|
||||
@NonNull Supplier<IFingerprint> lazyDaemon,
|
||||
@Nullable IBinder token, int userId, int sensorId,
|
||||
@NonNull ISessionCallback sessionCallback,
|
||||
@NonNull UserStartedCallback<ISession> callback) {
|
||||
@@ -53,10 +55,12 @@ public class FingerprintStartUserClient extends StartUserClient<IFingerprint, IS
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
final ISession newSession = getFreshDaemon().createSession(getSensorId(),
|
||||
final IFingerprint hal = getFreshDaemon();
|
||||
final int version = hal.getInterfaceVersion();
|
||||
final ISession newSession = hal.createSession(getSensorId(),
|
||||
getTargetUserId(), mSessionCallback);
|
||||
Binder.allowBlocking(newSession.asBinder());
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), newSession);
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), newSession, version);
|
||||
getCallback().onClientFinished(this, true /* success */);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
@@ -66,6 +70,5 @@ public class FingerprintStartUserClient extends StartUserClient<IFingerprint, IS
|
||||
|
||||
@Override
|
||||
public void unableToStart() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.biometrics.sensors.fingerprint.aidl;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
@@ -27,11 +26,13 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.StopUserClient;
|
||||
|
||||
public class FingerprintStopUserClient extends StopUserClient<ISession> {
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FingerprintStopUserClient extends StopUserClient<AidlSession> {
|
||||
private static final String TAG = "FingerprintStopUserClient";
|
||||
|
||||
public FingerprintStopUserClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @Nullable IBinder token, int userId,
|
||||
@NonNull Supplier<AidlSession> lazyDaemon, @Nullable IBinder token, int userId,
|
||||
int sensorId, @NonNull UserStoppedCallback callback) {
|
||||
super(context, lazyDaemon, token, userId, sensorId, callback);
|
||||
}
|
||||
@@ -45,7 +46,7 @@ public class FingerprintStopUserClient extends StopUserClient<ISession> {
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().close();
|
||||
getFreshDaemon().getSession().close();
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
getCallback().onClientFinished(this, false /* success */);
|
||||
@@ -54,6 +55,5 @@ public class FingerprintStopUserClient extends StopUserClient<ISession> {
|
||||
|
||||
@Override
|
||||
public void unableToStart() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricScheduler;
|
||||
import com.android.server.biometrics.sensors.EnumerateConsumer;
|
||||
import com.android.server.biometrics.sensors.ErrorConsumer;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
import com.android.server.biometrics.sensors.LockoutCache;
|
||||
import com.android.server.biometrics.sensors.LockoutConsumer;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
@@ -66,6 +65,7 @@ import com.android.server.biometrics.sensors.fingerprint.GestureAvailabilityDisp
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Maintains the state of a single sensor within an instance of the
|
||||
@@ -86,24 +86,8 @@ class Sensor {
|
||||
@NonNull private final LockoutCache mLockoutCache;
|
||||
@NonNull private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
@Nullable private Session mCurrentSession;
|
||||
@NonNull private final HalClientMonitor.LazyDaemon<ISession> mLazySession;
|
||||
|
||||
static class Session {
|
||||
@NonNull private final String mTag;
|
||||
@NonNull private final ISession mSession;
|
||||
private final int mUserId;
|
||||
@NonNull final HalSessionCallback mHalSessionCallback;
|
||||
|
||||
Session(@NonNull String tag, @NonNull ISession session, int userId,
|
||||
@NonNull HalSessionCallback halSessionCallback) {
|
||||
mTag = tag;
|
||||
mSession = session;
|
||||
mUserId = userId;
|
||||
mHalSessionCallback = halSessionCallback;
|
||||
Slog.d(mTag, "New session created for user: " + userId);
|
||||
}
|
||||
}
|
||||
@Nullable private AidlSession mCurrentSession;
|
||||
@NonNull private final Supplier<AidlSession> mLazySession;
|
||||
|
||||
static class HalSessionCallback extends ISessionCallback.Stub {
|
||||
|
||||
@@ -452,7 +436,7 @@ class Sensor {
|
||||
mScheduler = new UserAwareBiometricScheduler(tag,
|
||||
BiometricScheduler.sensorTypeFromFingerprintProperties(mSensorProperties),
|
||||
gestureAvailabilityDispatcher,
|
||||
() -> mCurrentSession != null ? mCurrentSession.mUserId : UserHandle.USER_NULL,
|
||||
() -> mCurrentSession != null ? mCurrentSession.getUserId() : UserHandle.USER_NULL,
|
||||
new UserAwareBiometricScheduler.UserSwitchCallback() {
|
||||
@NonNull
|
||||
@Override
|
||||
@@ -464,20 +448,21 @@ class Sensor {
|
||||
@NonNull
|
||||
@Override
|
||||
public StartUserClient<?, ?> getStartUserClient(int newUserId) {
|
||||
final HalSessionCallback.Callback callback = () -> {
|
||||
Slog.e(mTag, "Got ERROR_HW_UNAVAILABLE");
|
||||
mCurrentSession = null;
|
||||
};
|
||||
|
||||
final int sensorId = mSensorProperties.sensorId;
|
||||
|
||||
final HalSessionCallback resultController = new HalSessionCallback(mContext,
|
||||
mHandler, mTag, mScheduler, sensorId, newUserId, mLockoutCache,
|
||||
lockoutResetDispatcher, callback);
|
||||
lockoutResetDispatcher, () -> {
|
||||
Slog.e(mTag, "Got ERROR_HW_UNAVAILABLE");
|
||||
mCurrentSession = null;
|
||||
});
|
||||
|
||||
final StartUserClient.UserStartedCallback<ISession> userStartedCallback =
|
||||
(userIdStarted, newSession) -> {
|
||||
mCurrentSession = new Session(mTag,
|
||||
(userIdStarted, newSession, halInterfaceVersion) -> {
|
||||
Slog.d(mTag, "New session created for user: "
|
||||
+ userIdStarted + " with hal version: "
|
||||
+ halInterfaceVersion);
|
||||
mCurrentSession = new AidlSession(halInterfaceVersion,
|
||||
newSession, userIdStarted, resultController);
|
||||
if (FingerprintUtils.getInstance(sensorId)
|
||||
.isInvalidationInProgress(mContext, userIdStarted)) {
|
||||
@@ -497,10 +482,10 @@ class Sensor {
|
||||
}
|
||||
});
|
||||
mAuthenticatorIds = new HashMap<>();
|
||||
mLazySession = () -> mCurrentSession != null ? mCurrentSession.mSession : null;
|
||||
mLazySession = () -> mCurrentSession != null ? mCurrentSession : null;
|
||||
}
|
||||
|
||||
@NonNull HalClientMonitor.LazyDaemon<ISession> getLazySession() {
|
||||
@NonNull Supplier<AidlSession> getLazySession() {
|
||||
return mLazySession;
|
||||
}
|
||||
|
||||
@@ -508,8 +493,8 @@ class Sensor {
|
||||
return mSensorProperties;
|
||||
}
|
||||
|
||||
@Nullable Session getSessionForUser(int userId) {
|
||||
if (mCurrentSession != null && mCurrentSession.mUserId == userId) {
|
||||
@Nullable AidlSession getSessionForUser(int userId) {
|
||||
if (mCurrentSession != null && mCurrentSession.getUserId() == userId) {
|
||||
return mCurrentSession;
|
||||
} else {
|
||||
return null;
|
||||
@@ -539,10 +524,10 @@ class Sensor {
|
||||
if (enabled != mTestHalEnabled) {
|
||||
// The framework should retrieve a new session from the HAL.
|
||||
try {
|
||||
if (mCurrentSession != null && mCurrentSession.mSession != null) {
|
||||
if (mCurrentSession != null) {
|
||||
// TODO(181984005): This should be scheduled instead of directly invoked
|
||||
Slog.d(mTag, "Closing old session");
|
||||
mCurrentSession.mSession.close();
|
||||
mCurrentSession.getSession().close();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(mTag, "RemoteException", e);
|
||||
|
||||
@@ -67,7 +67,6 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCompositeCallback;
|
||||
import com.android.server.biometrics.sensors.EnumerateConsumer;
|
||||
import com.android.server.biometrics.sensors.ErrorConsumer;
|
||||
import com.android.server.biometrics.sensors.HalClientMonitor;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
import com.android.server.biometrics.sensors.PerformanceTracker;
|
||||
@@ -90,6 +89,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Supports a single instance of the {@link android.hardware.biometrics.fingerprint.V2_1} or
|
||||
@@ -111,7 +111,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
private final LockoutResetDispatcher mLockoutResetDispatcher;
|
||||
private final LockoutFrameworkImpl mLockoutTracker;
|
||||
private final BiometricTaskStackListener mTaskStackListener;
|
||||
private final HalClientMonitor.LazyDaemon<IBiometricsFingerprint> mLazyDaemon;
|
||||
private final Supplier<IBiometricsFingerprint> mLazyDaemon;
|
||||
private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
@Nullable private IBiometricsFingerprint mDaemon;
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
import com.android.server.biometrics.sensors.fingerprint.UdfpsHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific authentication client supporting the
|
||||
@@ -64,7 +65,7 @@ class FingerprintAuthenticationClient extends AuthenticationClient<IBiometricsFi
|
||||
private boolean mIsPointerDown;
|
||||
|
||||
FingerprintAuthenticationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int targetUserId, long operationId,
|
||||
boolean restricted, @NonNull String owner, int cookie, boolean requireConfirmation,
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
import com.android.server.biometrics.sensors.fingerprint.UdfpsHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Performs fingerprint detection without exposing any matching information (e.g. accept/reject
|
||||
@@ -55,7 +56,7 @@ class FingerprintDetectClient extends AcquisitionClient<IBiometricsFingerprint>
|
||||
private boolean mIsPointerDown;
|
||||
|
||||
public FingerprintDetectClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon,
|
||||
@NonNull IBinder token, long requestId,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId, @NonNull String owner,
|
||||
int sensorId, @Nullable IUdfpsOverlayController udfpsOverlayController,
|
||||
|
||||
@@ -41,6 +41,8 @@ import com.android.server.biometrics.sensors.SensorOverlays;
|
||||
import com.android.server.biometrics.sensors.fingerprint.Udfps;
|
||||
import com.android.server.biometrics.sensors.fingerprint.UdfpsHelper;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific enroll client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.V2_1} and
|
||||
@@ -56,7 +58,7 @@ public class FingerprintEnrollClient extends EnrollClient<IBiometricsFingerprint
|
||||
private boolean mIsPointerDown;
|
||||
|
||||
FingerprintEnrollClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
long requestId, @NonNull ClientMonitorCallbackConverter listener, int userId,
|
||||
@NonNull byte[] hardwareAuthToken, @NonNull String owner,
|
||||
@NonNull BiometricUtils<Fingerprint> utils, int timeoutSec, int sensorId,
|
||||
|
||||
@@ -26,6 +26,8 @@ import android.util.Slog;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.GenerateChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific generateChallenge/preEnroll client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.V2_1} and
|
||||
@@ -37,7 +39,7 @@ public class FingerprintGenerateChallengeClient
|
||||
private static final String TAG = "FingerprintGenerateChallengeClient";
|
||||
|
||||
FingerprintGenerateChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int userId, @NonNull String owner,
|
||||
int sensorId) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, sensorId);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific internal cleanup client supporting the
|
||||
@@ -40,7 +41,7 @@ class FingerprintInternalCleanupClient
|
||||
extends InternalCleanupClient<Fingerprint, IBiometricsFingerprint> {
|
||||
|
||||
FingerprintInternalCleanupClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, int userId,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, int userId,
|
||||
@NonNull String owner, int sensorId, @NonNull List<Fingerprint> enrolledList,
|
||||
@NonNull BiometricUtils<Fingerprint> utils,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
@@ -50,7 +51,7 @@ class FingerprintInternalCleanupClient
|
||||
|
||||
@Override
|
||||
protected InternalEnumerateClient<IBiometricsFingerprint> getEnumerateClient(
|
||||
Context context, LazyDaemon<IBiometricsFingerprint> lazyDaemon, IBinder token,
|
||||
Context context, Supplier<IBiometricsFingerprint> lazyDaemon, IBinder token,
|
||||
int userId, String owner, List<Fingerprint> enrolledList,
|
||||
BiometricUtils<Fingerprint> utils, int sensorId) {
|
||||
return new FingerprintInternalEnumerateClient(context, lazyDaemon, token, userId, owner,
|
||||
@@ -59,7 +60,7 @@ class FingerprintInternalCleanupClient
|
||||
|
||||
@Override
|
||||
protected RemovalClient<Fingerprint, IBiometricsFingerprint> getRemovalClient(Context context,
|
||||
LazyDaemon<IBiometricsFingerprint> lazyDaemon, IBinder token,
|
||||
Supplier<IBiometricsFingerprint> lazyDaemon, IBinder token,
|
||||
int biometricId, int userId, String owner, BiometricUtils<Fingerprint> utils,
|
||||
int sensorId, Map<Integer, Long> authenticatorIds) {
|
||||
// Internal remove does not need to send results to anyone. Cleanup (enumerate + remove)
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.android.server.biometrics.sensors.BiometricUtils;
|
||||
import com.android.server.biometrics.sensors.InternalEnumerateClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific internal enumerate client supporting the
|
||||
@@ -39,7 +40,7 @@ class FingerprintInternalEnumerateClient extends InternalEnumerateClient<IBiomet
|
||||
private static final String TAG = "FingerprintInternalEnumerateClient";
|
||||
|
||||
FingerprintInternalEnumerateClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
int userId, @NonNull String owner, @NonNull List<Fingerprint> enrolledList,
|
||||
@NonNull BiometricUtils<Fingerprint> utils, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, enrolledList, utils, sensorId,
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.RemovalClient;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific removal client supporting the
|
||||
@@ -42,7 +43,7 @@ class FingerprintRemovalClient extends RemovalClient<Fingerprint, IBiometricsFin
|
||||
private final int mBiometricId;
|
||||
|
||||
FingerprintRemovalClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener, int biometricId, int userId,
|
||||
@NonNull String owner, @NonNull BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
|
||||
@@ -25,6 +25,8 @@ import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.RevokeChallengeClient;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Fingerprint-specific revokeChallenge client supporting the
|
||||
* {@link android.hardware.biometrics.fingerprint.V2_1} and
|
||||
@@ -36,7 +38,7 @@ public class FingerprintRevokeChallengeClient
|
||||
private static final String TAG = "FingerprintRevokeChallengeClient";
|
||||
|
||||
FingerprintRevokeChallengeClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, @NonNull IBinder token,
|
||||
int userId, @NonNull String owner, int sensorId) {
|
||||
super(context, lazyDaemon, token, userId, owner, sensorId);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FingerprintUpdateActiveUserClient extends HalClientMonitor<IBiometr
|
||||
private File mDirectory;
|
||||
|
||||
FingerprintUpdateActiveUserClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<IBiometricsFingerprint> lazyDaemon, int userId,
|
||||
@NonNull Supplier<IBiometricsFingerprint> lazyDaemon, int userId,
|
||||
@NonNull String owner, int sensorId, Supplier<Integer> currentUserId,
|
||||
boolean hasEnrolledBiometrics, @NonNull Map<Integer, Long> authenticatorIds,
|
||||
boolean forceUpdateAuthenticatorId) {
|
||||
|
||||
@@ -39,6 +39,8 @@ import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
public class AcquisitionClientTest {
|
||||
@@ -87,7 +89,7 @@ public class AcquisitionClientTest {
|
||||
boolean mHalOperationRunning;
|
||||
|
||||
public TestAcquisitionClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<Object> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter callback) {
|
||||
super(context, lazyDaemon, token, callback, 0 /* userId */, "Test", 0 /* cookie */,
|
||||
TEST_SENSOR_ID /* sensorId */, true /* shouldVibrate */, 0 /* statsModality */,
|
||||
|
||||
@@ -61,6 +61,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Presubmit
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@@ -93,7 +95,7 @@ public class BiometricSchedulerTest {
|
||||
|
||||
@Test
|
||||
public void testClientDuplicateFinish_ignoredBySchedulerAndDoesNotCrash() {
|
||||
final HalClientMonitor.LazyDaemon<Object> nonNullDaemon = () -> mock(Object.class);
|
||||
final Supplier<Object> nonNullDaemon = () -> mock(Object.class);
|
||||
|
||||
final HalClientMonitor<Object> client1 =
|
||||
new TestHalClientMonitor(mContext, mToken, nonNullDaemon);
|
||||
@@ -184,7 +186,7 @@ public class BiometricSchedulerTest {
|
||||
|
||||
@Test
|
||||
public void testCancelNotInvoked_whenOperationWaitingForCookie() {
|
||||
final HalClientMonitor.LazyDaemon<Object> lazyDaemon1 = () -> mock(Object.class);
|
||||
final Supplier<Object> lazyDaemon1 = () -> mock(Object.class);
|
||||
final TestAuthenticationClient client1 = new TestAuthenticationClient(mContext,
|
||||
lazyDaemon1, mToken, mock(ClientMonitorCallbackConverter.class));
|
||||
final ClientMonitorCallback callback1 = mock(ClientMonitorCallback.class);
|
||||
@@ -296,7 +298,7 @@ public class BiometricSchedulerTest {
|
||||
|
||||
@Test
|
||||
public void testCancelPendingAuth() throws RemoteException {
|
||||
final HalClientMonitor.LazyDaemon<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final TestHalClientMonitor client1 = new TestHalClientMonitor(mContext, mToken, lazyDaemon);
|
||||
final ClientMonitorCallbackConverter callback = mock(ClientMonitorCallbackConverter.class);
|
||||
final TestAuthenticationClient client2 = new TestAuthenticationClient(mContext, lazyDaemon,
|
||||
@@ -360,7 +362,7 @@ public class BiometricSchedulerTest {
|
||||
|
||||
private void testCancelsAuthDetectWhenRequestId(@Nullable Long requestId, long cancelRequestId,
|
||||
boolean started) {
|
||||
final HalClientMonitor.LazyDaemon<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final ClientMonitorCallbackConverter callback = mock(ClientMonitorCallbackConverter.class);
|
||||
testCancelsWhenRequestId(requestId, cancelRequestId, started,
|
||||
new TestAuthenticationClient(mContext, lazyDaemon, mToken, callback));
|
||||
@@ -383,7 +385,7 @@ public class BiometricSchedulerTest {
|
||||
|
||||
private void testCancelsEnrollWhenRequestId(@Nullable Long requestId, long cancelRequestId,
|
||||
boolean started) {
|
||||
final HalClientMonitor.LazyDaemon<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final ClientMonitorCallbackConverter callback = mock(ClientMonitorCallbackConverter.class);
|
||||
testCancelsWhenRequestId(requestId, cancelRequestId, started,
|
||||
new TestEnrollClient(mContext, lazyDaemon, mToken, callback));
|
||||
@@ -441,7 +443,7 @@ public class BiometricSchedulerTest {
|
||||
public void testCancelsPending_whenAuthRequestIdsSet() {
|
||||
final long requestId1 = 10;
|
||||
final long requestId2 = 20;
|
||||
final HalClientMonitor.LazyDaemon<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final Supplier<Object> lazyDaemon = () -> mock(Object.class);
|
||||
final ClientMonitorCallbackConverter callback = mock(ClientMonitorCallbackConverter.class);
|
||||
final TestAuthenticationClient client1 = new TestAuthenticationClient(
|
||||
mContext, lazyDaemon, mToken, callback);
|
||||
@@ -500,7 +502,7 @@ public class BiometricSchedulerTest {
|
||||
|
||||
@Test
|
||||
public void testClientDestroyed_afterFinish() {
|
||||
final HalClientMonitor.LazyDaemon<Object> nonNullDaemon = () -> mock(Object.class);
|
||||
final Supplier<Object> nonNullDaemon = () -> mock(Object.class);
|
||||
final TestHalClientMonitor client =
|
||||
new TestHalClientMonitor(mContext, mToken, nonNullDaemon);
|
||||
mScheduler.scheduleClientMonitor(client);
|
||||
@@ -520,7 +522,7 @@ public class BiometricSchedulerTest {
|
||||
int mNumCancels = 0;
|
||||
|
||||
public TestAuthenticationClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<Object> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener) {
|
||||
super(context, lazyDaemon, token, listener, 0 /* targetUserId */, 0 /* operationId */,
|
||||
false /* restricted */, TAG, 1 /* cookie */, false /* requireConfirmation */,
|
||||
@@ -567,7 +569,7 @@ public class BiometricSchedulerTest {
|
||||
int mNumCancels = 0;
|
||||
|
||||
TestEnrollClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull Supplier<Object> lazyDaemon, @NonNull IBinder token,
|
||||
@NonNull ClientMonitorCallbackConverter listener) {
|
||||
super(context, lazyDaemon, token, listener, 0 /* userId */, new byte[69],
|
||||
"test" /* owner */, mock(BiometricUtils.class),
|
||||
@@ -604,12 +606,12 @@ public class BiometricSchedulerTest {
|
||||
private boolean mDestroyed;
|
||||
|
||||
TestHalClientMonitor(@NonNull Context context, @NonNull IBinder token,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon) {
|
||||
@NonNull Supplier<Object> lazyDaemon) {
|
||||
this(context, token, lazyDaemon, 0 /* cookie */, BiometricsProto.CM_UPDATE_ACTIVE_USER);
|
||||
}
|
||||
|
||||
TestHalClientMonitor(@NonNull Context context, @NonNull IBinder token,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon, int cookie, int protoEnum) {
|
||||
@NonNull Supplier<Object> lazyDaemon, int cookie, int protoEnum) {
|
||||
super(context, lazyDaemon, token /* token */, null /* listener */, 0 /* userId */,
|
||||
TAG, cookie, TEST_SENSOR_ID, 0 /* statsModality */,
|
||||
0 /* statsAction */, 0 /* statsClient */);
|
||||
|
||||
@@ -47,6 +47,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Presubmit
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@RunWithLooper
|
||||
@@ -215,7 +217,7 @@ public class UserAwareBiometricSchedulerTest {
|
||||
int numInvocations;
|
||||
|
||||
@Override
|
||||
public void onUserStarted(int newUserId, Object newObject) {
|
||||
public void onUserStarted(int newUserId, Object newObject, int halInterfaceVersion) {
|
||||
numInvocations++;
|
||||
mCurrentUserId = newUserId;
|
||||
}
|
||||
@@ -223,7 +225,7 @@ public class UserAwareBiometricSchedulerTest {
|
||||
|
||||
private static class TestStopUserClient extends StopUserClient<Object> {
|
||||
public TestStopUserClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon, @Nullable IBinder token, int userId,
|
||||
@NonNull Supplier<Object> lazyDaemon, @Nullable IBinder token, int userId,
|
||||
int sensorId, @NonNull UserStoppedCallback callback) {
|
||||
super(context, lazyDaemon, token, userId, sensorId, callback);
|
||||
}
|
||||
@@ -251,7 +253,7 @@ public class UserAwareBiometricSchedulerTest {
|
||||
ClientMonitorCallback mCallback;
|
||||
|
||||
public TestStartUserClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<Object> lazyDaemon, @Nullable IBinder token, int userId,
|
||||
@NonNull Supplier<Object> lazyDaemon, @Nullable IBinder token, int userId,
|
||||
int sensorId, @NonNull UserStartedCallback<Object> callback, boolean shouldFinish) {
|
||||
super(context, lazyDaemon, token, userId, sensorId, callback);
|
||||
mShouldFinish = shouldFinish;
|
||||
@@ -268,7 +270,8 @@ public class UserAwareBiometricSchedulerTest {
|
||||
|
||||
mCallback = callback;
|
||||
if (mShouldFinish) {
|
||||
mUserStartedCallback.onUserStarted(getTargetUserId(), new Object());
|
||||
mUserStartedCallback.onUserStarted(
|
||||
getTargetUserId(), new Object(), 1 /* halInterfaceVersion */);
|
||||
callback.onClientFinished(this, true /* success */);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ public class SensorTest {
|
||||
mLockoutCache.setLockoutModeForUser(USER_ID, LockoutTracker.LOCKOUT_TIMED);
|
||||
|
||||
mScheduler.scheduleClientMonitor(new FaceResetLockoutClient(mContext,
|
||||
() -> mSession, USER_ID, TAG, SENSOR_ID, HAT, mLockoutCache,
|
||||
mLockoutResetDispatcher));
|
||||
() -> new AidlSession(1, mSession, USER_ID, mHalCallback),
|
||||
USER_ID, TAG, SENSOR_ID, HAT, mLockoutCache, mLockoutResetDispatcher));
|
||||
mLooper.dispatchAll();
|
||||
|
||||
verifyNotLocked();
|
||||
|
||||
@@ -101,8 +101,8 @@ public class SensorTest {
|
||||
mLockoutCache.setLockoutModeForUser(USER_ID, LockoutTracker.LOCKOUT_TIMED);
|
||||
|
||||
mScheduler.scheduleClientMonitor(new FingerprintResetLockoutClient(mContext,
|
||||
() -> mSession, USER_ID, TAG, SENSOR_ID, HAT, mLockoutCache,
|
||||
mLockoutResetDispatcher));
|
||||
() -> new AidlSession(1, mSession, USER_ID, mHalCallback),
|
||||
USER_ID, TAG, SENSOR_ID, HAT, mLockoutCache, mLockoutResetDispatcher));
|
||||
mLooper.dispatchAll();
|
||||
|
||||
verifyNotLocked();
|
||||
|
||||
Reference in New Issue
Block a user