Schedule cleanup with the callback that was passed in

For the AIDL providers, send the scheduler the callback that
was passed in. Otherwise, the test infrastructure wouldn't know
when cleanup completes. This saves ~20s from each test session
close time.

The added logs do not affect/spam production code.

Bug: 152240892
Test: atest CtsBiometricsTestCases
Change-Id: I047ec8da01b3237e738e4567eb6ef3554f6b868d
This commit is contained in:
Kevin Chyn
2021-04-02 12:16:28 -07:00
parent 82722a0423
commit 6a0b25111a
5 changed files with 24 additions and 14 deletions

View File

@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
*/
@TestApi
public class BiometricTestSession implements AutoCloseable {
private static final String TAG = "BiometricTestSession";
private static final String BASE_TAG = "BiometricTestSession";
/**
* @hide
@@ -66,12 +66,12 @@ public class BiometricTestSession implements AutoCloseable {
private final ITestSessionCallback mCallback = new ITestSessionCallback.Stub() {
@Override
public void onCleanupStarted(int userId) {
Log.d(TAG, "onCleanupStarted, sensor: " + mSensorId + ", userId: " + userId);
Log.d(getTag(), "onCleanupStarted, sensor: " + mSensorId + ", userId: " + userId);
}
@Override
public void onCleanupFinished(int userId) {
Log.d(TAG, "onCleanupFinished, sensor: " + mSensorId
Log.d(getTag(), "onCleanupFinished, sensor: " + mSensorId
+ ", userId: " + userId
+ ", remaining users: " + mUsersCleaningUp.size());
mUsersCleaningUp.remove(userId);
@@ -107,7 +107,7 @@ public class BiometricTestSession implements AutoCloseable {
@RequiresPermission(TEST_BIOMETRIC)
private void setTestHalEnabled(boolean enabled) {
try {
Log.w(TAG, "setTestHalEnabled, sensor: " + mSensorId + " enabled: " + enabled);
Log.w(getTag(), "setTestHalEnabled, sensor: " + mSensorId + " enabled: " + enabled);
mTestSession.setTestHalEnabled(enabled);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -217,7 +217,7 @@ public class BiometricTestSession implements AutoCloseable {
public void cleanupInternalState(int userId) {
try {
if (mUsersCleaningUp.contains(userId)) {
Log.w(TAG, "Cleanup already in progress for user: " + userId);
Log.w(getTag(), "Cleanup already in progress for user: " + userId);
}
mUsersCleaningUp.add(userId);
@@ -230,6 +230,7 @@ public class BiometricTestSession implements AutoCloseable {
@Override
@RequiresPermission(TEST_BIOMETRIC)
public void close() {
Log.d(getTag(), "Close, mTestedUsers size; " + mTestedUsers.size());
// Cleanup can be performed using the test HAL, since it always responds to enumerate with
// zero enrollments.
if (!mTestedUsers.isEmpty()) {
@@ -239,15 +240,19 @@ public class BiometricTestSession implements AutoCloseable {
}
try {
Log.d(TAG, "Awaiting latch...");
mCloseLatch.await(10, TimeUnit.SECONDS);
Log.d(TAG, "Finished awaiting");
Log.d(getTag(), "Awaiting latch...");
mCloseLatch.await(3, TimeUnit.SECONDS);
Log.d(getTag(), "Finished awaiting");
} catch (InterruptedException e) {
Log.e(TAG, "Latch interrupted", e);
Log.e(getTag(), "Latch interrupted", e);
}
}
// Disable the test HAL after the sensor becomes idle.
setTestHalEnabled(false);
}
private String getTag() {
return BASE_TAG + "_" + mSensorId;
}
}

View File

@@ -48,7 +48,7 @@ import java.util.Set;
*/
public class BiometricTestSessionImpl extends ITestSession.Stub {
private static final String TAG = "BiometricTestSessionImpl";
private static final String TAG = "face/aidl/BiometricTestSessionImpl";
@NonNull private final Context mContext;
private final int mSensorId;
@@ -230,10 +230,12 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
public void cleanupInternalState(int userId) {
Utils.checkPermission(mContext, TEST_BIOMETRIC);
Slog.d(TAG, "cleanupInternalState: " + userId);
mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
@Override
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
try {
Slog.d(TAG, "onClientStarted: " + clientMonitor);
mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
@@ -244,6 +246,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
boolean success) {
try {
Slog.d(TAG, "onClientFinished: " + clientMonitor);
mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);

View File

@@ -49,7 +49,6 @@ import com.android.server.biometrics.Utils;
import com.android.server.biometrics.sensors.AuthenticationClient;
import com.android.server.biometrics.sensors.BaseClientMonitor;
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
import com.android.server.biometrics.sensors.HalClientMonitor;
import com.android.server.biometrics.sensors.InvalidationRequesterClient;
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.PerformanceTracker;
@@ -443,7 +442,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
mContext.getOpPackageName(), sensorId, enrolledList,
FaceUtils.getInstance(sensorId),
mSensors.get(sensorId).getAuthenticatorIds());
scheduleForSensor(sensorId, client);
scheduleForSensor(sensorId, client, callback);
});
}

View File

@@ -45,7 +45,7 @@ import java.util.Set;
*/
class BiometricTestSessionImpl extends ITestSession.Stub {
private static final String TAG = "BiometricTestSessionImpl";
private static final String TAG = "fp/aidl/BiometricTestSessionImpl";
@NonNull private final Context mContext;
private final int mSensorId;
@@ -198,10 +198,12 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
public void cleanupInternalState(int userId) {
Utils.checkPermission(mContext, TEST_BIOMETRIC);
Slog.d(TAG, "cleanupInternalState: " + userId);
mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
@Override
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
try {
Slog.d(TAG, "onClientStarted: " + clientMonitor);
mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);
@@ -212,6 +214,7 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
boolean success) {
try {
Slog.d(TAG, "onClientFinished: " + clientMonitor);
mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
} catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e);

View File

@@ -432,7 +432,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
mContext.getOpPackageName(), sensorId, enrolledList,
FingerprintUtils.getInstance(sensorId),
mSensors.get(sensorId).getAuthenticatorIds());
scheduleForSensor(sensorId, client);
scheduleForSensor(sensorId, client, callback);
});
}