Update removeAll test path
1) for the old HIDL interfaces, remove(0) means to remove all enrollments. Thus, have the test HAL pass back the fake enrollmentIds instead of just "0" 2) RemovalClient never receives null identifiers. Update it to be @NonNull and remove the unnecessary null check Test: atest CtsBiometricsTestCases Bug: 183755255 Change-Id: I2cffc4afb77c009ef75ad6ebae358e7779917744
This commit is contained in:
@@ -65,12 +65,10 @@ public abstract class RemovalClient<S extends BiometricAuthenticator.Identifier,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved(@Nullable BiometricAuthenticator.Identifier identifier, int remaining) {
|
||||
public void onRemoved(@NonNull BiometricAuthenticator.Identifier identifier, int remaining) {
|
||||
Slog.d(TAG, "onRemoved: " + identifier.getBiometricId() + " remaining: " + remaining);
|
||||
if (identifier != null) {
|
||||
mBiometricUtils.removeBiometricForUser(getContext(), getTargetUserId(),
|
||||
identifier.getBiometricId());
|
||||
}
|
||||
mBiometricUtils.removeBiometricForUser(getContext(), getTargetUserId(),
|
||||
identifier.getBiometricId());
|
||||
|
||||
try {
|
||||
if (getListener() != null) {
|
||||
|
||||
@@ -398,7 +398,7 @@ public class Face10 implements IHwBinder.DeathRecipient, ServiceProvider {
|
||||
|
||||
private synchronized IBiometricsFace getDaemon() {
|
||||
if (mTestHalEnabled) {
|
||||
final TestHal testHal = new TestHal();
|
||||
final TestHal testHal = new TestHal(mContext, mSensorId);
|
||||
testHal.setCallback(mHalResultController);
|
||||
return testHal;
|
||||
}
|
||||
|
||||
@@ -16,23 +16,40 @@
|
||||
|
||||
package com.android.server.biometrics.sensors.face.hidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.face.V1_0.FaceError;
|
||||
import android.hardware.biometrics.face.V1_0.IBiometricsFace;
|
||||
import android.hardware.biometrics.face.V1_0.IBiometricsFaceClientCallback;
|
||||
import android.hardware.biometrics.face.V1_0.OptionalBool;
|
||||
import android.hardware.biometrics.face.V1_0.OptionalUint64;
|
||||
import android.hardware.biometrics.face.V1_0.Status;
|
||||
import android.hardware.face.Face;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.face.FaceUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TestHal extends IBiometricsFace.Stub {
|
||||
private static final String TAG = "face.hidl.TestHal";
|
||||
|
||||
@NonNull
|
||||
private final Context mContext;
|
||||
private final int mSensorId;
|
||||
|
||||
@Nullable
|
||||
private IBiometricsFaceClientCallback mCallback;
|
||||
private int mUserId;
|
||||
|
||||
TestHal(@NonNull Context context, int sensorId) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptionalUint64 setCallback(IBiometricsFaceClientCallback clientCallback) {
|
||||
@@ -44,6 +61,7 @@ public class TestHal extends IBiometricsFace.Stub {
|
||||
|
||||
@Override
|
||||
public int setActiveUser(int userId, String storePath) {
|
||||
mUserId = userId;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -110,8 +128,20 @@ public class TestHal extends IBiometricsFace.Stub {
|
||||
public int remove(int faceId) throws RemoteException {
|
||||
Slog.w(TAG, "remove");
|
||||
if (mCallback != null) {
|
||||
mCallback.onRemoved(0 /* deviceId */, new ArrayList<Integer>(Arrays.asList(faceId)),
|
||||
0 /* userId */);
|
||||
if (faceId == 0) {
|
||||
// For this HAL interface, remove(0) means to remove all enrollments.
|
||||
final List<Face> faces = FaceUtils.getInstance(mSensorId)
|
||||
.getBiometricsForUser(mContext, mUserId);
|
||||
final ArrayList<Integer> faceIds = new ArrayList<>();
|
||||
for (Face face : faces) {
|
||||
faceIds.add(face.getBiometricId());
|
||||
}
|
||||
mCallback.onRemoved(0 /* deviceId */, faceIds, mUserId);
|
||||
} else {
|
||||
mCallback.onRemoved(0 /* deviceId */,
|
||||
new ArrayList<>(Collections.singletonList(faceId)),
|
||||
mUserId);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ public class Fingerprint21 implements IHwBinder.DeathRecipient, ServiceProvider
|
||||
@VisibleForTesting
|
||||
synchronized IBiometricsFingerprint getDaemon() {
|
||||
if (mTestHalEnabled) {
|
||||
final TestHal testHal = new TestHal();
|
||||
final TestHal testHal = new TestHal(mContext, mSensorId);
|
||||
testHal.setNotify(mHalResultController);
|
||||
return testHal;
|
||||
}
|
||||
|
||||
@@ -16,22 +16,38 @@
|
||||
|
||||
package com.android.server.biometrics.sensors.fingerprint.hidl;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.hardware.biometrics.fingerprint.V2_1.FingerprintError;
|
||||
import android.hardware.biometrics.fingerprint.V2_1.IBiometricsFingerprintClientCallback;
|
||||
import android.hardware.biometrics.fingerprint.V2_3.IBiometricsFingerprint;
|
||||
import android.hardware.fingerprint.Fingerprint;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.biometrics.sensors.fingerprint.FingerprintUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Test HAL that provides only provides no-ops.
|
||||
*/
|
||||
public class TestHal extends IBiometricsFingerprint.Stub {
|
||||
private static final String TAG = "fingerprint.hidl.TestHal";
|
||||
|
||||
@NonNull
|
||||
private final Context mContext;
|
||||
private final int mSensorId;
|
||||
|
||||
@Nullable
|
||||
private IBiometricsFingerprintClientCallback mCallback;
|
||||
|
||||
TestHal(@NonNull Context context, int sensorId) {
|
||||
mContext = context;
|
||||
mSensorId = sensorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUdfps(int sensorId) {
|
||||
return false;
|
||||
@@ -96,7 +112,18 @@ public class TestHal extends IBiometricsFingerprint.Stub {
|
||||
public int remove(int gid, int fid) throws RemoteException {
|
||||
Slog.w(TAG, "Remove");
|
||||
if (mCallback != null) {
|
||||
mCallback.onRemoved(0 /* deviceId */, fid, gid, 0 /* remaining */);
|
||||
if (fid == 0) {
|
||||
// For this HAL interface, remove(0) means to remove all enrollments.
|
||||
final List<Fingerprint> fingerprints = FingerprintUtils.getInstance(mSensorId)
|
||||
.getBiometricsForUser(mContext, gid);
|
||||
for (int i = 0; i < fingerprints.size(); i++) {
|
||||
final Fingerprint fp = fingerprints.get(i);
|
||||
mCallback.onRemoved(0 /* deviceId */, fp.getBiometricId(), gid,
|
||||
fingerprints.size() - i - 1);
|
||||
}
|
||||
} else {
|
||||
mCallback.onRemoved(0 /* deviceId */, fid, gid, 0 /* remaining */);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user