Merge changes from topic "revert-13593269-QAPPBSWOVZ" into sc-dev
* changes: Revert "Update RemovalClient to support new biometric AIDL" Revert "Try to ensure tests run sequentially"
This commit is contained in:
committed by
Android (Google) Code Review
commit
4d4817a9b3
@@ -237,8 +237,7 @@ public class BiometricManager {
|
||||
public BiometricTestSession createTestSession(int sensorId) {
|
||||
try {
|
||||
return new BiometricTestSession(mContext, sensorId,
|
||||
(context, sensorId1, callback) -> mService
|
||||
.createTestSession(sensorId1, callback, context.getOpPackageName()));
|
||||
mService.createTestSession(sensorId, mContext.getOpPackageName()));
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package android.hardware.biometrics;
|
||||
import static android.Manifest.permission.TEST_BIOMETRIC;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.TestApi;
|
||||
import android.content.Context;
|
||||
@@ -28,9 +27,6 @@ import android.os.RemoteException;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Common set of interfaces to test biometric-related APIs, including {@link BiometricPrompt} and
|
||||
* {@link android.hardware.fingerprint.FingerprintManager}.
|
||||
@@ -40,58 +36,22 @@ import java.util.concurrent.TimeUnit;
|
||||
public class BiometricTestSession implements AutoCloseable {
|
||||
private static final String TAG = "BiometricTestSession";
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public interface TestSessionProvider {
|
||||
@NonNull
|
||||
ITestSession createTestSession(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback) throws RemoteException;
|
||||
}
|
||||
|
||||
private final Context mContext;
|
||||
private final int mSensorId;
|
||||
private final ITestSession mTestSession;
|
||||
|
||||
// Keep track of users that were tested, which need to be cleaned up when finishing.
|
||||
@NonNull private final ArraySet<Integer> mTestedUsers;
|
||||
|
||||
// Track the users currently cleaning up, and provide a latch that gets notified when all
|
||||
// users have finished cleaning up. This is an imperfect system, as there can technically be
|
||||
// multiple cleanups per user. Theoretically we should track the cleanup's BaseClientMonitor's
|
||||
// unique ID, but it's complicated to plumb it through. This should be fine for now.
|
||||
@Nullable private CountDownLatch mCloseLatch;
|
||||
@NonNull private final ArraySet<Integer> mUsersCleaningUp;
|
||||
|
||||
private final ITestSessionCallback mCallback = new ITestSessionCallback.Stub() {
|
||||
@Override
|
||||
public void onCleanupStarted(int userId) {
|
||||
Log.d(TAG, "onCleanupStarted, sensor: " + mSensorId + ", userId: " + userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCleanupFinished(int userId) {
|
||||
Log.d(TAG, "onCleanupFinished, sensor: " + mSensorId
|
||||
+ ", userId: " + userId
|
||||
+ ", remaining users: " + mUsersCleaningUp.size());
|
||||
mUsersCleaningUp.remove(userId);
|
||||
|
||||
if (mUsersCleaningUp.isEmpty() && mCloseLatch != null) {
|
||||
mCloseLatch.countDown();
|
||||
}
|
||||
}
|
||||
};
|
||||
private final ArraySet<Integer> mTestedUsers;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public BiometricTestSession(@NonNull Context context, int sensorId,
|
||||
@NonNull TestSessionProvider testSessionProvider) throws RemoteException {
|
||||
@NonNull ITestSession testSession) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mTestSession = testSessionProvider.createTestSession(context, sensorId, mCallback);
|
||||
mTestSession = testSession;
|
||||
mTestedUsers = new ArraySet<>();
|
||||
mUsersCleaningUp = new ArraySet<>();
|
||||
setTestHalEnabled(true);
|
||||
}
|
||||
|
||||
@@ -216,11 +176,6 @@ public class BiometricTestSession implements AutoCloseable {
|
||||
@RequiresPermission(TEST_BIOMETRIC)
|
||||
public void cleanupInternalState(int userId) {
|
||||
try {
|
||||
if (mUsersCleaningUp.contains(userId)) {
|
||||
Log.w(TAG, "Cleanup already in progress for user: " + userId);
|
||||
}
|
||||
|
||||
mUsersCleaningUp.add(userId);
|
||||
mTestSession.cleanupInternalState(userId);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
@@ -230,24 +185,12 @@ public class BiometricTestSession implements AutoCloseable {
|
||||
@Override
|
||||
@RequiresPermission(TEST_BIOMETRIC)
|
||||
public void close() {
|
||||
// Cleanup can be performed using the test HAL, since it always responds to enumerate with
|
||||
// zero enrollments.
|
||||
if (!mTestedUsers.isEmpty()) {
|
||||
mCloseLatch = new CountDownLatch(1);
|
||||
for (int user : mTestedUsers) {
|
||||
cleanupInternalState(user);
|
||||
}
|
||||
|
||||
try {
|
||||
Log.d(TAG, "Awaiting latch...");
|
||||
mCloseLatch.await(10, TimeUnit.SECONDS);
|
||||
Log.d(TAG, "Finished awaiting");
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "Latch interrupted", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the test HAL after the sensor becomes idle.
|
||||
// Disable the test HAL first, so that enumerate is run on the real HAL, which should have
|
||||
// no enrollments. Test-only framework enrollments will be deleted.
|
||||
setTestHalEnabled(false);
|
||||
|
||||
for (int user : mTestedUsers) {
|
||||
cleanupInternalState(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback;
|
||||
import android.hardware.biometrics.IBiometricServiceReceiver;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.PromptInfo;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
|
||||
@@ -33,7 +32,7 @@ import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
*/
|
||||
interface IAuthService {
|
||||
// Creates a test session with the specified sensorId
|
||||
ITestSession createTestSession(int sensorId, ITestSessionCallback callback, String opPackageName);
|
||||
ITestSession createTestSession(int sensorId, String opPackageName);
|
||||
|
||||
// Retrieve static sensor properties for all biometric sensors
|
||||
List<SensorPropertiesInternal> getSensorProperties(String opPackageName);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
import android.hardware.face.IFaceServiceReceiver;
|
||||
import android.hardware.face.Face;
|
||||
@@ -33,7 +32,7 @@ import android.hardware.face.Face;
|
||||
interface IBiometricAuthenticator {
|
||||
|
||||
// Creates a test session
|
||||
ITestSession createTestSession(ITestSessionCallback callback, String opPackageName);
|
||||
ITestSession createTestSession(String opPackageName);
|
||||
|
||||
// Retrieve static sensor properties
|
||||
SensorPropertiesInternal getSensorProperties(String opPackageName);
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.hardware.biometrics.IBiometricServiceReceiver;
|
||||
import android.hardware.biometrics.IBiometricAuthenticator;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.PromptInfo;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
|
||||
@@ -31,7 +30,7 @@ import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
*/
|
||||
interface IBiometricService {
|
||||
// Creates a test session with the specified sensorId
|
||||
ITestSession createTestSession(int sensorId, ITestSessionCallback callback, String opPackageName);
|
||||
ITestSession createTestSession(int sensorId, String opPackageName);
|
||||
|
||||
// Retrieve static sensor properties for all biometric sensors
|
||||
List<SensorPropertiesInternal> getSensorProperties(String opPackageName);
|
||||
|
||||
@@ -18,7 +18,7 @@ package android.hardware.biometrics;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
|
||||
/**
|
||||
* A test service for FingerprintManager and BiometricManager.
|
||||
* A test service for FingerprintManager and BiometricPrompt.
|
||||
* @hide
|
||||
*/
|
||||
interface ITestSession {
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.hardware.biometrics;
|
||||
|
||||
/**
|
||||
* ITestSession callback for FingerprintManager and BiometricManager.
|
||||
* @hide
|
||||
*/
|
||||
interface ITestSessionCallback {
|
||||
void onCleanupStarted(int userId);
|
||||
void onCleanupFinished(int userId);
|
||||
}
|
||||
@@ -574,23 +574,12 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
|
||||
mService.remove(mToken, face.getBiometricId(), userId, mServiceReceiver,
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all face templates for the given user.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(MANAGE_BIOMETRIC)
|
||||
public void removeAll(int userId, @NonNull RemovalCallback callback) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
mRemovalCallback = callback;
|
||||
mService.removeAll(mToken, userId, mServiceReceiver, mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
Slog.w(TAG, "Remote exception in remove: ", e);
|
||||
if (callback != null) {
|
||||
callback.onRemovalError(face, FACE_ERROR_HW_UNAVAILABLE,
|
||||
getErrorString(mContext, FACE_ERROR_HW_UNAVAILABLE,
|
||||
0 /* vendorCode */));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.face.IFaceServiceReceiver;
|
||||
import android.hardware.face.Face;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
@@ -33,7 +32,7 @@ import android.view.Surface;
|
||||
interface IFaceService {
|
||||
|
||||
// Creates a test session with the specified sensorId
|
||||
ITestSession createTestSession(int sensorId, ITestSessionCallback callback, String opPackageName);
|
||||
ITestSession createTestSession(int sensorId, String opPackageName);
|
||||
|
||||
// Requests a proto dump of the specified sensor
|
||||
byte[] dumpSensorServiceStateProto(int sensorId, boolean clearSchedulerBuffer);
|
||||
@@ -84,13 +83,10 @@ interface IFaceService {
|
||||
// Cancel enrollment in progress
|
||||
void cancelEnrollment(IBinder token);
|
||||
|
||||
// Removes the specified face enrollment for the specified userId.
|
||||
// Any errors resulting from this call will be returned to the listener
|
||||
void remove(IBinder token, int faceId, int userId, IFaceServiceReceiver receiver,
|
||||
String opPackageName);
|
||||
|
||||
// Removes all face enrollments for the specified userId.
|
||||
void removeAll(IBinder token, int userId, IFaceServiceReceiver receiver, String opPackageName);
|
||||
|
||||
// Get the enrolled face for user.
|
||||
List<Face> getEnrolledFaces(int sensorId, int userId, String opPackageName);
|
||||
|
||||
|
||||
@@ -154,8 +154,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
public BiometricTestSession createTestSession(int sensorId) {
|
||||
try {
|
||||
return new BiometricTestSession(mContext, sensorId,
|
||||
(context, sensorId1, callback) -> mService
|
||||
.createTestSession(sensorId1, callback, context.getOpPackageName()));
|
||||
mService.createTestSession(sensorId, mContext.getOpPackageName()));
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
@@ -740,22 +739,11 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
|
||||
mService.remove(mToken, fp.getBiometricId(), userId, mServiceReceiver,
|
||||
mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all face templates for the given user.
|
||||
* @hide
|
||||
*/
|
||||
@RequiresPermission(MANAGE_FINGERPRINT)
|
||||
public void removeAll(int userId, @NonNull RemovalCallback callback) {
|
||||
if (mService != null) {
|
||||
try {
|
||||
mRemovalCallback = callback;
|
||||
mService.removeAll(mToken, userId, mServiceReceiver, mContext.getOpPackageName());
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
Slog.w(TAG, "Remote exception in remove: ", e);
|
||||
if (callback != null) {
|
||||
callback.onRemovalError(fp, FINGERPRINT_ERROR_HW_UNAVAILABLE,
|
||||
getErrorString(mContext, FINGERPRINT_ERROR_HW_UNAVAILABLE,
|
||||
0 /* vendorCode */));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.fingerprint.IFingerprintClientActiveCallback;
|
||||
import android.hardware.fingerprint.IFingerprintServiceReceiver;
|
||||
import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
@@ -34,7 +33,7 @@ import java.util.List;
|
||||
interface IFingerprintService {
|
||||
|
||||
// Creates a test session with the specified sensorId
|
||||
ITestSession createTestSession(int sensorId, ITestSessionCallback callback, String opPackageName);
|
||||
ITestSession createTestSession(int sensorId, String opPackageName);
|
||||
|
||||
// Requests a proto dump of the specified sensor
|
||||
byte[] dumpSensorServiceStateProto(int sensorId, boolean clearSchedulerBuffer);
|
||||
@@ -88,9 +87,6 @@ interface IFingerprintService {
|
||||
void remove(IBinder token, int fingerId, int userId, IFingerprintServiceReceiver receiver,
|
||||
String opPackageName);
|
||||
|
||||
// Removes all face enrollments for the specified userId.
|
||||
void removeAll(IBinder token, int userId, IFingerprintServiceReceiver receiver, String opPackageName);
|
||||
|
||||
// Rename the fingerprint specified by fingerId and userId to the given name
|
||||
void rename(int fingerId, int userId, String name);
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.hardware.biometrics.IBiometricService;
|
||||
import android.hardware.biometrics.IBiometricServiceReceiver;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.PromptInfo;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
import android.hardware.face.IFaceService;
|
||||
@@ -145,14 +144,13 @@ public class AuthService extends SystemService {
|
||||
|
||||
private final class AuthServiceImpl extends IAuthService.Stub {
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) throws RemoteException {
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName)
|
||||
throws RemoteException {
|
||||
Utils.checkPermission(getContext(), TEST_BIOMETRIC);
|
||||
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return mInjector.getBiometricService()
|
||||
.createTestSession(sensorId, callback, opPackageName);
|
||||
return mInjector.getBiometricService().createTestSession(sensorId, opPackageName);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import android.hardware.biometrics.IBiometricServiceReceiver;
|
||||
import android.hardware.biometrics.IBiometricSysuiReceiver;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.PromptInfo;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
@@ -571,13 +570,13 @@ public class BiometricService extends SystemService {
|
||||
*/
|
||||
private final class BiometricServiceWrapper extends IBiometricService.Stub {
|
||||
@Override // Binder call
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) throws RemoteException {
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName)
|
||||
throws RemoteException {
|
||||
checkInternalPermission();
|
||||
|
||||
for (BiometricSensor sensor : mSensors) {
|
||||
if (sensor.id == sensorId) {
|
||||
return sensor.impl.createTestSession(callback, opPackageName);
|
||||
return sensor.impl.createTestSession(opPackageName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,16 +37,18 @@ public abstract class RemovalClient<S extends BiometricAuthenticator.Identifier,
|
||||
|
||||
private static final String TAG = "Biometrics/RemovalClient";
|
||||
|
||||
protected final int mBiometricId;
|
||||
private final BiometricUtils<S> mBiometricUtils;
|
||||
private final Map<Integer, Long> mAuthenticatorIds;
|
||||
|
||||
public RemovalClient(@NonNull Context context, @NonNull LazyDaemon<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) {
|
||||
int biometricId, int userId, @NonNull String owner, @NonNull BiometricUtils<S> utils,
|
||||
int sensorId, @NonNull Map<Integer, Long> authenticatorIds, int statsModality) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, 0 /* cookie */, sensorId,
|
||||
statsModality, BiometricsProtoEnums.ACTION_REMOVE,
|
||||
BiometricsProtoEnums.CLIENT_UNKNOWN);
|
||||
mBiometricId = biometricId;
|
||||
mBiometricUtils = utils;
|
||||
mAuthenticatorIds = authenticatorIds;
|
||||
}
|
||||
@@ -66,7 +68,6 @@ public abstract class RemovalClient<S extends BiometricAuthenticator.Identifier,
|
||||
|
||||
@Override
|
||||
public void onRemoved(@Nullable BiometricAuthenticator.Identifier identifier, int remaining) {
|
||||
Slog.d(TAG, "onRemoved: " + identifier.getBiometricId() + " remaining: " + remaining);
|
||||
if (identifier != null) {
|
||||
mBiometricUtils.removeBiometricForUser(getContext(), getTargetUserId(),
|
||||
identifier.getBiometricId());
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.hardware.biometrics.IBiometricAuthenticator;
|
||||
import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
import android.hardware.face.IFaceService;
|
||||
import android.os.IBinder;
|
||||
@@ -42,9 +41,8 @@ public final class FaceAuthenticator extends IBiometricAuthenticator.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestSession createTestSession(@NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) throws RemoteException {
|
||||
return mFaceService.createTestSession(mSensorId, callback, opPackageName);
|
||||
public ITestSession createTestSession(@NonNull String opPackageName) throws RemoteException {
|
||||
return mFaceService.createTestSession(mSensorId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.hardware.biometrics.IBiometricService;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.SensorProps;
|
||||
import android.hardware.face.Face;
|
||||
@@ -134,8 +133,7 @@ public class FaceService extends SystemService implements BiometricServiceCallba
|
||||
*/
|
||||
private final class FaceServiceWrapper extends IFaceService.Stub {
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
@@ -145,7 +143,7 @@ public class FaceService extends SystemService implements BiometricServiceCallba
|
||||
return null;
|
||||
}
|
||||
|
||||
return provider.createTestSession(sensorId, callback, opPackageName);
|
||||
return provider.createTestSession(sensorId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -388,22 +386,7 @@ public class FaceService extends SystemService implements BiometricServiceCallba
|
||||
opPackageName);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void removeAll(final IBinder token, final int userId,
|
||||
final IFaceServiceReceiver receiver, final String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for removeAll");
|
||||
return;
|
||||
}
|
||||
|
||||
provider.second.scheduleRemoveAll(provider.first, token, userId, receiver,
|
||||
opPackageName);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@Override
|
||||
public void addLockoutResetCallback(final IBiometricServiceLockoutResetCallback callback,
|
||||
final String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.face.Face;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.hardware.face.FaceSensorPropertiesInternal;
|
||||
@@ -29,7 +28,6 @@ import android.os.IBinder;
|
||||
import android.os.NativeHandle;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
|
||||
@@ -111,9 +109,6 @@ public interface ServiceProvider {
|
||||
void scheduleRemove(int sensorId, @NonNull IBinder token, int faceId, int userId,
|
||||
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName);
|
||||
|
||||
void scheduleRemoveAll(int sensorId, @NonNull IBinder token, int userId,
|
||||
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName);
|
||||
|
||||
void scheduleResetLockout(int sensorId, int userId, @NonNull byte[] hardwareAuthToken);
|
||||
|
||||
void scheduleSetFeature(int sensorId, @NonNull IBinder token, int userId, int feature,
|
||||
@@ -125,8 +120,7 @@ public interface ServiceProvider {
|
||||
|
||||
void startPreparedClient(int sensorId, int cookie);
|
||||
|
||||
void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback);
|
||||
void scheduleInternalCleanup(int sensorId, int userId);
|
||||
|
||||
void dumpProtoState(int sensorId, @NonNull ProtoOutputStream proto,
|
||||
boolean clearSchedulerBuffer);
|
||||
@@ -136,8 +130,7 @@ public interface ServiceProvider {
|
||||
void dumpInternal(int sensorId, @NonNull PrintWriter pw);
|
||||
|
||||
@NonNull
|
||||
ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName);
|
||||
ITestSession createTestSession(int sensorId, @NonNull String opPackageName);
|
||||
|
||||
void dumpHal(int sensorId, @NonNull FileDescriptor fd, @NonNull String[] args);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import static android.Manifest.permission.TEST_BIOMETRIC;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.face.AuthenticationFrame;
|
||||
import android.hardware.biometrics.face.BaseFrame;
|
||||
import android.hardware.face.Face;
|
||||
@@ -29,12 +28,10 @@ import android.hardware.face.FaceAuthenticationFrame;
|
||||
import android.hardware.face.FaceEnrollFrame;
|
||||
import android.hardware.face.IFaceServiceReceiver;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.HardwareAuthTokenUtils;
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.face.FaceUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -52,7 +49,6 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
private final int mSensorId;
|
||||
@NonNull private final ITestSessionCallback mCallback;
|
||||
@NonNull private final FaceProvider mProvider;
|
||||
@NonNull private final Sensor mSensor;
|
||||
@NonNull private final Set<Integer> mEnrollmentIds;
|
||||
@@ -136,11 +132,9 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
};
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback,
|
||||
@NonNull FaceProvider provider, @NonNull Sensor sensor) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mCallback = callback;
|
||||
mProvider = provider;
|
||||
mSensor = sensor;
|
||||
mEnrollmentIds = new HashSet<>();
|
||||
@@ -230,25 +224,6 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void cleanupInternalState(int userId) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
|
||||
try {
|
||||
mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
try {
|
||||
mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
mProvider.scheduleInternalCleanup(mSensorId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class FaceInternalCleanupClient extends InternalCleanupClient<Face, ISession> {
|
||||
// Internal remove does not need to send results to anyone. Cleanup (enumerate + remove)
|
||||
// is all done internally.
|
||||
return new FaceRemovalClient(context, lazyDaemon, token,
|
||||
null /* ClientMonitorCallbackConverter */, new int[] {biometricId}, userId, owner,
|
||||
utils, sensorId, authenticatorIds);
|
||||
null /* ClientMonitorCallbackConverter */, biometricId, userId, owner, utils,
|
||||
sensorId, authenticatorIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.face.IFace;
|
||||
import android.hardware.biometrics.face.SensorProps;
|
||||
import android.hardware.face.Face;
|
||||
@@ -178,8 +177,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
||||
for (int i = 0; i < mSensors.size(); i++) {
|
||||
final int sensorId = mSensors.keyAt(i);
|
||||
scheduleLoadAuthenticatorIds(sensorId);
|
||||
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser(),
|
||||
null /* callback */);
|
||||
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser());
|
||||
}
|
||||
|
||||
return mDaemon;
|
||||
@@ -470,25 +468,6 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
||||
@Override
|
||||
public void scheduleRemove(int sensorId, @NonNull IBinder token, int faceId, int userId,
|
||||
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
|
||||
scheduleRemoveSpecifiedIds(sensorId, token, new int[] {faceId}, userId, receiver,
|
||||
opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleRemoveAll(int sensorId, @NonNull IBinder token, int userId,
|
||||
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
|
||||
final List<Face> faces = FaceUtils.getInstance(sensorId)
|
||||
.getBiometricsForUser(mContext, userId);
|
||||
final int[] faceIds = new int[faces.size()];
|
||||
for (int i = 0; i < faces.size(); i++) {
|
||||
faceIds[i] = faces.get(i).getBiometricId();
|
||||
}
|
||||
|
||||
scheduleRemoveSpecifiedIds(sensorId, token, faceIds, userId, receiver, opPackageName);
|
||||
}
|
||||
|
||||
private void scheduleRemoveSpecifiedIds(int sensorId, @NonNull IBinder token, int[] faceIds,
|
||||
int userId, @NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
|
||||
mHandler.post(() -> {
|
||||
final IFace daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
@@ -506,7 +485,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
||||
|
||||
final FaceRemovalClient client = new FaceRemovalClient(mContext,
|
||||
mSensors.get(sensorId).getLazySession(), token,
|
||||
new ClientMonitorCallbackConverter(receiver), faceIds, userId,
|
||||
new ClientMonitorCallbackConverter(receiver), faceId, userId,
|
||||
opPackageName, FaceUtils.getInstance(sensorId), sensorId,
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
|
||||
@@ -564,8 +543,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback) {
|
||||
public void scheduleInternalCleanup(int sensorId, int userId) {
|
||||
mHandler.post(() -> {
|
||||
final IFace daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
@@ -586,7 +564,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
||||
FaceUtils.getInstance(sensorId),
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client, callback);
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(getTag(), "Remote exception when scheduling internal cleanup", e);
|
||||
}
|
||||
@@ -649,9 +627,8 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
return mSensors.get(sensorId).createTestSession(callback);
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName) {
|
||||
return mSensors.get(sensorId).createTestSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,22 +38,19 @@ import java.util.Map;
|
||||
class FaceRemovalClient extends RemovalClient<Face, ISession> {
|
||||
private static final String TAG = "FaceRemovalClient";
|
||||
|
||||
final int[] mBiometricIds;
|
||||
|
||||
FaceRemovalClient(@NonNull Context context, @NonNull LazyDaemon<ISession> lazyDaemon,
|
||||
@NonNull IBinder token, @NonNull ClientMonitorCallbackConverter listener,
|
||||
int[] biometricIds, int userId, @NonNull String owner,
|
||||
@NonNull BiometricUtils<Face> utils, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, utils, sensorId,
|
||||
int biometricId, int userId, @NonNull String owner, @NonNull BiometricUtils<Face> utils,
|
||||
int sensorId, @NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, token, listener, biometricId, userId, owner, utils, sensorId,
|
||||
authenticatorIds, BiometricsProtoEnums.MODALITY_FACE);
|
||||
mBiometricIds = biometricIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().removeEnrollments(mSequentialId, mBiometricIds);
|
||||
final int[] ids = new int[]{mBiometricId};
|
||||
getFreshDaemon().removeEnrollments(mSequentialId, ids);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting remove", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.face.AuthenticationFrame;
|
||||
import android.hardware.biometrics.face.EnrollmentFrame;
|
||||
import android.hardware.biometrics.face.Error;
|
||||
@@ -460,9 +459,8 @@ public class Sensor {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull ITestSession createTestSession(@NonNull ITestSessionCallback callback) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, callback,
|
||||
mProvider, this);
|
||||
@NonNull ITestSession createTestSession() {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, mProvider, this);
|
||||
}
|
||||
|
||||
void createNewSession(@NonNull IFace daemon, int sensorId, int userId)
|
||||
|
||||
@@ -21,17 +21,14 @@ import static android.Manifest.permission.TEST_BIOMETRIC;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.face.Face;
|
||||
import android.hardware.face.FaceAuthenticationFrame;
|
||||
import android.hardware.face.FaceEnrollFrame;
|
||||
import android.hardware.face.IFaceServiceReceiver;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.face.FaceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -46,7 +43,6 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
private final int mSensorId;
|
||||
@NonNull private final ITestSessionCallback mCallback;
|
||||
@NonNull private final Face10 mFace10;
|
||||
@NonNull private final Face10.HalResultController mHalResultController;
|
||||
@NonNull private final Set<Integer> mEnrollmentIds;
|
||||
@@ -124,12 +120,10 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
}
|
||||
};
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback, @NonNull Face10 face10,
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId, @NonNull Face10 face10,
|
||||
@NonNull Face10.HalResultController halResultController) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mCallback = callback;
|
||||
mFace10 = face10;
|
||||
mHalResultController = halResultController;
|
||||
mEnrollmentIds = new HashSet<>();
|
||||
@@ -207,25 +201,6 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void cleanupInternalState(int userId) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mFace10.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
|
||||
try {
|
||||
mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
try {
|
||||
mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
mFace10.scheduleInternalCleanup(mSensorId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.hardware.biometrics.BiometricFaceConstants;
|
||||
import android.hardware.biometrics.BiometricManager;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
|
||||
import android.hardware.biometrics.face.V1_0.IBiometricsFaceClientCallback;
|
||||
import android.hardware.face.Face;
|
||||
@@ -124,7 +123,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() {
|
||||
@Override
|
||||
public void onUserSwitching(int newUserId) {
|
||||
scheduleInternalCleanup(newUserId, null /* callback */);
|
||||
scheduleInternalCleanup(newUserId);
|
||||
scheduleGetFeature(mSensorId, new Binder(), newUserId,
|
||||
BiometricFaceConstants.FEATURE_REQUIRE_ATTENTION,
|
||||
null, mContext.getOpPackageName());
|
||||
@@ -438,7 +437,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
Slog.d(TAG, "Face HAL ready, HAL ID: " + halId);
|
||||
if (halId != 0) {
|
||||
scheduleLoadAuthenticatorIds();
|
||||
scheduleInternalCleanup(ActivityManager.getCurrentUser(), null /* callback */);
|
||||
scheduleInternalCleanup(ActivityManager.getCurrentUser());
|
||||
scheduleGetFeature(mSensorId, new Binder(),
|
||||
ActivityManager.getCurrentUser(),
|
||||
BiometricFaceConstants.FEATURE_REQUIRE_ATTENTION, null,
|
||||
@@ -672,20 +671,6 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleRemoveAll(int sensorId, @NonNull IBinder token, int userId,
|
||||
@NonNull IFaceServiceReceiver receiver, @NonNull String opPackageName) {
|
||||
mHandler.post(() -> {
|
||||
scheduleUpdateActiveUserWithoutHandler(userId);
|
||||
|
||||
// For IBiometricsFace@1.0, remove(0) means remove all enrollments
|
||||
final FaceRemovalClient client = new FaceRemovalClient(mContext, mLazyDaemon, token,
|
||||
new ClientMonitorCallbackConverter(receiver), 0 /* faceId */, userId,
|
||||
opPackageName,
|
||||
FaceUtils.getLegacyInstance(mSensorId), mSensorId, mAuthenticatorIds);
|
||||
mScheduler.scheduleClientMonitor(client);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleResetLockout(int sensorId, int userId, @NonNull byte[] hardwareAuthToken) {
|
||||
@@ -757,8 +742,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
});
|
||||
}
|
||||
|
||||
private void scheduleInternalCleanup(int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback) {
|
||||
private void scheduleInternalCleanup(int userId) {
|
||||
mHandler.post(() -> {
|
||||
scheduleUpdateActiveUserWithoutHandler(userId);
|
||||
|
||||
@@ -766,14 +750,13 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
final FaceInternalCleanupClient client = new FaceInternalCleanupClient(mContext,
|
||||
mLazyDaemon, userId, mContext.getOpPackageName(), mSensorId, enrolledList,
|
||||
FaceUtils.getLegacyInstance(mSensorId), mAuthenticatorIds);
|
||||
mScheduler.scheduleClientMonitor(client, callback);
|
||||
mScheduler.scheduleClientMonitor(client);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback) {
|
||||
scheduleInternalCleanup(userId, callback);
|
||||
public void scheduleInternalCleanup(int sensorId, int userId) {
|
||||
scheduleInternalCleanup(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -947,9 +930,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorId, callback, this,
|
||||
mHalResultController);
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorId, this, mHalResultController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,12 @@ import java.util.Map;
|
||||
class FaceRemovalClient extends RemovalClient<Face, IBiometricsFace> {
|
||||
private static final String TAG = "FaceRemovalClient";
|
||||
|
||||
private final int mBiometricId;
|
||||
|
||||
FaceRemovalClient(@NonNull Context context, @NonNull LazyDaemon<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) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, utils, sensorId,
|
||||
super(context, lazyDaemon, token, listener, biometricId, userId, owner, utils, sensorId,
|
||||
authenticatorIds, BiometricsProtoEnums.MODALITY_FACE);
|
||||
mBiometricId = biometricId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.hardware.biometrics.IBiometricAuthenticator;
|
||||
import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
import android.hardware.fingerprint.IFingerprintService;
|
||||
import android.os.IBinder;
|
||||
@@ -43,9 +42,8 @@ public final class FingerprintAuthenticator extends IBiometricAuthenticator.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestSession createTestSession(@NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) throws RemoteException {
|
||||
return mFingerprintService.createTestSession(mSensorId, callback, opPackageName);
|
||||
public ITestSession createTestSession(@NonNull String opPackageName) throws RemoteException {
|
||||
return mFingerprintService.createTestSession(mSensorId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,6 @@ import android.hardware.biometrics.IBiometricService;
|
||||
import android.hardware.biometrics.IBiometricServiceLockoutResetCallback;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.SensorProps;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
@@ -110,8 +109,7 @@ public class FingerprintService extends SystemService implements BiometricServic
|
||||
*/
|
||||
private final class FingerprintServiceWrapper extends IFingerprintService.Stub {
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName) {
|
||||
Utils.checkPermission(getContext(), TEST_BIOMETRIC);
|
||||
|
||||
final ServiceProvider provider = getProviderForSensor(sensorId);
|
||||
@@ -121,7 +119,7 @@ public class FingerprintService extends SystemService implements BiometricServic
|
||||
return null;
|
||||
}
|
||||
|
||||
return provider.createTestSession(sensorId, callback, opPackageName);
|
||||
return provider.createTestSession(sensorId, opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -501,21 +499,7 @@ public class FingerprintService extends SystemService implements BiometricServic
|
||||
opPackageName);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
public void removeAll(final IBinder token, final int userId,
|
||||
final IFingerprintServiceReceiver receiver, final String opPackageName) {
|
||||
Utils.checkPermission(getContext(), MANAGE_FINGERPRINT);
|
||||
|
||||
final Pair<Integer, ServiceProvider> provider = getSingleProvider();
|
||||
if (provider == null) {
|
||||
Slog.w(TAG, "Null provider for removeAll");
|
||||
return;
|
||||
}
|
||||
provider.second.scheduleRemoveAll(provider.first, token, receiver, userId,
|
||||
opPackageName);
|
||||
}
|
||||
|
||||
@Override // Binder call
|
||||
@Override
|
||||
public void addLockoutResetCallback(final IBiometricServiceLockoutResetCallback callback,
|
||||
final String opPackageName) {
|
||||
Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||
@@ -29,7 +28,6 @@ import android.hardware.fingerprint.IUdfpsOverlayController;
|
||||
import android.os.IBinder;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
|
||||
@@ -100,12 +98,7 @@ public interface ServiceProvider {
|
||||
@NonNull IFingerprintServiceReceiver receiver, int fingerId, int userId,
|
||||
@NonNull String opPackageName);
|
||||
|
||||
void scheduleRemoveAll(int sensorId, @NonNull IBinder token,
|
||||
@NonNull IFingerprintServiceReceiver receiver, int userId,
|
||||
@NonNull String opPackageName);
|
||||
|
||||
void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback);
|
||||
void scheduleInternalCleanup(int sensorId, int userId);
|
||||
|
||||
boolean isHardwareDetected(int sensorId);
|
||||
|
||||
@@ -140,6 +133,5 @@ public interface ServiceProvider {
|
||||
void dumpInternal(int sensorId, @NonNull PrintWriter pw);
|
||||
|
||||
@NonNull
|
||||
ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName);
|
||||
ITestSession createTestSession(int sensorId, @NonNull String opPackageName);
|
||||
}
|
||||
|
||||
@@ -21,17 +21,14 @@ import static android.Manifest.permission.TEST_BIOMETRIC;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.IFingerprintServiceReceiver;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.HardwareAuthTokenUtils;
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -49,7 +46,6 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
private final int mSensorId;
|
||||
@NonNull private final ITestSessionCallback mCallback;
|
||||
@NonNull private final FingerprintProvider mProvider;
|
||||
@NonNull private final Sensor mSensor;
|
||||
@NonNull private final Set<Integer> mEnrollmentIds;
|
||||
@@ -114,11 +110,9 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
};
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback, @NonNull FingerprintProvider provider,
|
||||
@NonNull Sensor sensor) {
|
||||
@NonNull FingerprintProvider provider, @NonNull Sensor sensor) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mCallback = callback;
|
||||
mProvider = provider;
|
||||
mSensor = sensor;
|
||||
mEnrollmentIds = new HashSet<>();
|
||||
@@ -198,25 +192,6 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void cleanupInternalState(int userId) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
|
||||
try {
|
||||
mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
try {
|
||||
mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
mProvider.scheduleInternalCleanup(mSensorId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class FingerprintInternalCleanupClient extends InternalCleanupClient<Fingerprint
|
||||
String owner, BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
Map<Integer, Long> authenticatorIds) {
|
||||
return new FingerprintRemovalClient(context, lazyDaemon, token,
|
||||
null /* ClientMonitorCallbackConverter */, new int[] {biometricId}, userId, owner,
|
||||
utils, sensorId, authenticatorIds);
|
||||
null /* ClientMonitorCallbackConverter */, biometricId, userId, owner, utils,
|
||||
sensorId, authenticatorIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.SensorProps;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
@@ -186,8 +185,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
for (int i = 0; i < mSensors.size(); i++) {
|
||||
final int sensorId = mSensors.keyAt(i);
|
||||
scheduleLoadAuthenticatorIds(sensorId);
|
||||
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser(),
|
||||
null /* callback */);
|
||||
scheduleInternalCleanup(sensorId, ActivityManager.getCurrentUser());
|
||||
}
|
||||
|
||||
return mDaemon;
|
||||
@@ -492,27 +490,6 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
public void scheduleRemove(int sensorId, @NonNull IBinder token,
|
||||
@NonNull IFingerprintServiceReceiver receiver, int fingerId, int userId,
|
||||
@NonNull String opPackageName) {
|
||||
scheduleRemoveSpecifiedIds(sensorId, token, new int[] {fingerId}, userId, receiver,
|
||||
opPackageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleRemoveAll(int sensorId, @NonNull IBinder token,
|
||||
@NonNull IFingerprintServiceReceiver receiver, int userId,
|
||||
@NonNull String opPackageName) {
|
||||
final List<Fingerprint> fingers = FingerprintUtils.getInstance(sensorId)
|
||||
.getBiometricsForUser(mContext, userId);
|
||||
final int[] fingerIds = new int[fingers.size()];
|
||||
for (int i = 0; i < fingers.size(); i++) {
|
||||
fingerIds[i] = fingers.get(i).getBiometricId();
|
||||
}
|
||||
|
||||
scheduleRemoveSpecifiedIds(sensorId, token, fingerIds, userId, receiver, opPackageName);
|
||||
}
|
||||
|
||||
private void scheduleRemoveSpecifiedIds(int sensorId, @NonNull IBinder token,
|
||||
int[] fingerprintIds, int userId, @NonNull IFingerprintServiceReceiver receiver,
|
||||
@NonNull String opPackageName) {
|
||||
mHandler.post(() -> {
|
||||
final IFingerprint daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
@@ -530,7 +507,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
|
||||
final FingerprintRemovalClient client = new FingerprintRemovalClient(mContext,
|
||||
mSensors.get(sensorId).getLazySession(), token,
|
||||
new ClientMonitorCallbackConverter(receiver), fingerprintIds, userId,
|
||||
new ClientMonitorCallbackConverter(receiver), fingerId, userId,
|
||||
opPackageName, FingerprintUtils.getInstance(sensorId), sensorId,
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
|
||||
@@ -541,8 +518,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback) {
|
||||
public void scheduleInternalCleanup(int sensorId, int userId) {
|
||||
mHandler.post(() -> {
|
||||
final IFingerprint daemon = getHalInstance();
|
||||
if (daemon == null) {
|
||||
@@ -562,7 +538,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
mContext.getOpPackageName(), sensorId, enrolledList,
|
||||
FingerprintUtils.getInstance(sensorId),
|
||||
mSensors.get(sensorId).getAuthenticatorIds());
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client, callback);
|
||||
mSensors.get(sensorId).getScheduler().scheduleClientMonitor(client);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(getTag(), "Remote exception when scheduling internal cleanup", e);
|
||||
}
|
||||
@@ -707,9 +683,8 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
return mSensors.get(sensorId).createTestSession(callback);
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName) {
|
||||
return mSensors.get(sensorId).createTestSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,22 +39,20 @@ import java.util.Map;
|
||||
class FingerprintRemovalClient extends RemovalClient<Fingerprint, ISession> {
|
||||
private static final String TAG = "FingerprintRemovalClient";
|
||||
|
||||
private final int[] mBiometricIds;
|
||||
|
||||
FingerprintRemovalClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<ISession> lazyDaemon, @NonNull IBinder token,
|
||||
@Nullable ClientMonitorCallbackConverter listener, int[] biometricIds, int userId,
|
||||
@Nullable ClientMonitorCallbackConverter listener, int biometricId, int userId,
|
||||
@NonNull String owner, @NonNull BiometricUtils<Fingerprint> utils, int sensorId,
|
||||
@NonNull Map<Integer, Long> authenticatorIds) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, utils, sensorId,
|
||||
super(context, lazyDaemon, token, listener, biometricId, userId, owner, utils, sensorId,
|
||||
authenticatorIds, BiometricsProtoEnums.MODALITY_FINGERPRINT);
|
||||
mBiometricIds = biometricIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startHalOperation() {
|
||||
try {
|
||||
getFreshDaemon().removeEnrollments(mSequentialId, mBiometricIds);
|
||||
final int[] ids = new int[] {mBiometricId};
|
||||
getFreshDaemon().removeEnrollments(mSequentialId, ids);
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception when requesting remove", e);
|
||||
mCallback.onClientFinished(this, false /* success */);
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.fingerprint.Error;
|
||||
import android.hardware.biometrics.fingerprint.IFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.ISession;
|
||||
@@ -440,9 +439,8 @@ class Sensor {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull ITestSession createTestSession(@NonNull ITestSessionCallback callback) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, callback,
|
||||
mProvider, this);
|
||||
@NonNull ITestSession createTestSession() {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, mProvider, this);
|
||||
}
|
||||
|
||||
void createNewSession(@NonNull IFingerprint daemon, int sensorId, int userId)
|
||||
|
||||
@@ -21,16 +21,13 @@ import static android.Manifest.permission.TEST_BIOMETRIC;
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.hardware.fingerprint.FingerprintManager;
|
||||
import android.hardware.fingerprint.IFingerprintServiceReceiver;
|
||||
import android.os.Binder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,7 +47,6 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
private final int mSensorId;
|
||||
@NonNull private final ITestSessionCallback mCallback;
|
||||
@NonNull private final Fingerprint21 mFingerprint21;
|
||||
@NonNull private final Fingerprint21.HalResultController mHalResultController;
|
||||
@NonNull private final Set<Integer> mEnrollmentIds;
|
||||
@@ -115,12 +111,10 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
};
|
||||
|
||||
BiometricTestSessionImpl(@NonNull Context context, int sensorId,
|
||||
@NonNull ITestSessionCallback callback,
|
||||
@NonNull Fingerprint21 fingerprint21,
|
||||
@NonNull Fingerprint21.HalResultController halResultController) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
mCallback = callback;
|
||||
mFingerprint21 = fingerprint21;
|
||||
mHalResultController = halResultController;
|
||||
mEnrollmentIds = new HashSet<>();
|
||||
@@ -197,25 +191,6 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
|
||||
public void cleanupInternalState(int userId) {
|
||||
Utils.checkPermission(mContext, TEST_BIOMETRIC);
|
||||
|
||||
mFingerprint21.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
|
||||
@Override
|
||||
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
|
||||
try {
|
||||
mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
try {
|
||||
mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Remote exception", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
mFingerprint21.scheduleInternalCleanup(mSensorId, userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.hardware.biometrics.BiometricManager;
|
||||
import android.hardware.biometrics.BiometricsProtoEnums;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprint;
|
||||
import android.hardware.biometrics.fingerprint.V2_2.IBiometricsFingerprintClientCallback;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
@@ -159,7 +158,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
private final UserSwitchObserver mUserSwitchObserver = new SynchronousUserSwitchObserver() {
|
||||
@Override
|
||||
public void onUserSwitching(int newUserId) {
|
||||
scheduleInternalCleanup(newUserId, null /* callback */);
|
||||
scheduleInternalCleanup(newUserId);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -438,7 +437,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
Slog.d(TAG, "Fingerprint HAL ready, HAL ID: " + halId);
|
||||
if (halId != 0) {
|
||||
scheduleLoadAuthenticatorIds();
|
||||
scheduleInternalCleanup(ActivityManager.getCurrentUser(), null /* callback */);
|
||||
scheduleInternalCleanup(ActivityManager.getCurrentUser());
|
||||
} else {
|
||||
Slog.e(TAG, "Unable to set callback");
|
||||
mDaemon = null;
|
||||
@@ -645,25 +644,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleRemoveAll(int sensorId, @NonNull IBinder token,
|
||||
@NonNull IFingerprintServiceReceiver receiver, int userId,
|
||||
@NonNull String opPackageName) {
|
||||
mHandler.post(() -> {
|
||||
scheduleUpdateActiveUserWithoutHandler(userId);
|
||||
|
||||
// For IBiometricsFingerprint@2.1, remove(0) means remove all enrollments
|
||||
final FingerprintRemovalClient client = new FingerprintRemovalClient(mContext,
|
||||
mLazyDaemon, token, new ClientMonitorCallbackConverter(receiver),
|
||||
0 /* fingerprintId */, userId, opPackageName,
|
||||
FingerprintUtils.getLegacyInstance(mSensorId),
|
||||
mSensorProperties.sensorId, mAuthenticatorIds);
|
||||
mScheduler.scheduleClientMonitor(client);
|
||||
});
|
||||
}
|
||||
|
||||
private void scheduleInternalCleanup(int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback) {
|
||||
private void scheduleInternalCleanup(int userId) {
|
||||
mHandler.post(() -> {
|
||||
scheduleUpdateActiveUserWithoutHandler(userId);
|
||||
|
||||
@@ -673,14 +654,13 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
mContext, mLazyDaemon, userId, mContext.getOpPackageName(),
|
||||
mSensorProperties.sensorId, enrolledList,
|
||||
FingerprintUtils.getLegacyInstance(mSensorId), mAuthenticatorIds);
|
||||
mScheduler.scheduleClientMonitor(client, callback);
|
||||
mScheduler.scheduleClientMonitor(client);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleInternalCleanup(int sensorId, int userId,
|
||||
@Nullable BaseClientMonitor.Callback callback) {
|
||||
scheduleInternalCleanup(userId, callback);
|
||||
public void scheduleInternalCleanup(int sensorId, int userId) {
|
||||
scheduleInternalCleanup(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -860,9 +840,8 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ITestSession createTestSession(int sensorId, @NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, callback, this,
|
||||
public ITestSession createTestSession(int sensorId, @NonNull String opPackageName) {
|
||||
return new BiometricTestSessionImpl(mContext, mSensorProperties.sensorId, this,
|
||||
mHalResultController);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,16 +39,13 @@ import java.util.Map;
|
||||
class FingerprintRemovalClient extends RemovalClient<Fingerprint, IBiometricsFingerprint> {
|
||||
private static final String TAG = "FingerprintRemovalClient";
|
||||
|
||||
private final int mBiometricId;
|
||||
|
||||
FingerprintRemovalClient(@NonNull Context context,
|
||||
@NonNull LazyDaemon<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) {
|
||||
super(context, lazyDaemon, token, listener, userId, owner, utils, sensorId,
|
||||
super(context, lazyDaemon, token, listener, biometricId, userId, owner, utils, sensorId,
|
||||
authenticatorIds, BiometricsProtoEnums.MODALITY_FINGERPRINT);
|
||||
mBiometricId = biometricId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.hardware.biometrics.IBiometricAuthenticator;
|
||||
import android.hardware.biometrics.IBiometricSensorReceiver;
|
||||
import android.hardware.biometrics.IInvalidationCallback;
|
||||
import android.hardware.biometrics.ITestSession;
|
||||
import android.hardware.biometrics.ITestSessionCallback;
|
||||
import android.hardware.biometrics.SensorPropertiesInternal;
|
||||
import android.hardware.iris.IIrisService;
|
||||
import android.os.IBinder;
|
||||
@@ -40,8 +39,7 @@ public final class IrisAuthenticator extends IBiometricAuthenticator.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITestSession createTestSession(@NonNull ITestSessionCallback callback,
|
||||
@NonNull String opPackageName) throws RemoteException {
|
||||
public ITestSession createTestSession(@NonNull String opPackageName) throws RemoteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2902,8 +2902,11 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
FingerprintManager mFingerprintManager = mInjector.getFingerprintManager();
|
||||
if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()) {
|
||||
if (mFingerprintManager.hasEnrolledFingerprints(userId)) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
mFingerprintManager.removeAll(userId, fingerprintManagerRemovalCallback(latch));
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
// For the purposes of M and N, groupId is the same as userId.
|
||||
Fingerprint finger = new Fingerprint(null, userId, 0, 0);
|
||||
mFingerprintManager.remove(finger, userId,
|
||||
fingerprintManagerRemovalCallback(latch));
|
||||
try {
|
||||
latch.await(10000, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -2917,8 +2920,9 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
FaceManager mFaceManager = mInjector.getFaceManager();
|
||||
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
|
||||
if (mFaceManager.hasEnrolledTemplates(userId)) {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
mFaceManager.removeAll(userId, faceManagerRemovalCallback(latch));
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
Face face = new Face(null, 0, 0);
|
||||
mFaceManager.remove(face, userId, faceManagerRemovalCallback(latch));
|
||||
try {
|
||||
latch.await(10000, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
@@ -2932,8 +2936,10 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
CountDownLatch latch) {
|
||||
return new FingerprintManager.RemovalCallback() {
|
||||
@Override
|
||||
public void onRemovalError(@Nullable Fingerprint fp, int errMsgId, CharSequence err) {
|
||||
Slog.e(TAG, "Unable to remove fingerprint, error: " + err);
|
||||
public void onRemovalError(Fingerprint fp, int errMsgId, CharSequence err) {
|
||||
Slog.e(TAG, String.format(
|
||||
"Can't remove fingerprint %d in group %d. Reason: %s",
|
||||
fp.getBiometricId(), fp.getGroupId(), err));
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@@ -2949,8 +2955,9 @@ public class LockSettingsService extends ILockSettings.Stub {
|
||||
private FaceManager.RemovalCallback faceManagerRemovalCallback(CountDownLatch latch) {
|
||||
return new FaceManager.RemovalCallback() {
|
||||
@Override
|
||||
public void onRemovalError(@Nullable Face face, int errMsgId, CharSequence err) {
|
||||
Slog.e(TAG, "Unable to remove face, error: " + err);
|
||||
public void onRemovalError(Face face, int errMsgId, CharSequence err) {
|
||||
Slog.e(TAG, String.format("Can't remove face %d. Reason: %s",
|
||||
face.getBiometricId(), err));
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
|
||||
@@ -339,11 +339,11 @@ public class LockSettingsServiceTests extends BaseLockSettingsServiceTests {
|
||||
mService.setLockCredential(nonePassword(), newPattern("123654"), PRIMARY_USER_ID);
|
||||
|
||||
// Verify fingerprint is removed
|
||||
verify(mFingerprintManager).removeAll(eq(PRIMARY_USER_ID), any());
|
||||
verify(mFaceManager).removeAll(eq(PRIMARY_USER_ID), any());
|
||||
verify(mFingerprintManager).remove(any(), eq(PRIMARY_USER_ID), any());
|
||||
verify(mFaceManager).remove(any(), eq(PRIMARY_USER_ID), any());
|
||||
|
||||
verify(mFingerprintManager).removeAll(eq(MANAGED_PROFILE_USER_ID), any());
|
||||
verify(mFaceManager).removeAll(eq(MANAGED_PROFILE_USER_ID), any());
|
||||
verify(mFingerprintManager).remove(any(), eq(MANAGED_PROFILE_USER_ID), any());
|
||||
verify(mFaceManager).remove(any(), eq(MANAGED_PROFILE_USER_ID), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user