Merge "Schedule cleanup with the callback that was passed in" into sc-dev

This commit is contained in:
Kevin Chyn
2021-04-03 01:25:29 +00:00
committed by Android (Google) Code Review
5 changed files with 24 additions and 14 deletions

View File

@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
*/ */
@TestApi @TestApi
public class BiometricTestSession implements AutoCloseable { public class BiometricTestSession implements AutoCloseable {
private static final String TAG = "BiometricTestSession"; private static final String BASE_TAG = "BiometricTestSession";
/** /**
* @hide * @hide
@@ -66,12 +66,12 @@ public class BiometricTestSession implements AutoCloseable {
private final ITestSessionCallback mCallback = new ITestSessionCallback.Stub() { private final ITestSessionCallback mCallback = new ITestSessionCallback.Stub() {
@Override @Override
public void onCleanupStarted(int userId) { public void onCleanupStarted(int userId) {
Log.d(TAG, "onCleanupStarted, sensor: " + mSensorId + ", userId: " + userId); Log.d(getTag(), "onCleanupStarted, sensor: " + mSensorId + ", userId: " + userId);
} }
@Override @Override
public void onCleanupFinished(int userId) { public void onCleanupFinished(int userId) {
Log.d(TAG, "onCleanupFinished, sensor: " + mSensorId Log.d(getTag(), "onCleanupFinished, sensor: " + mSensorId
+ ", userId: " + userId + ", userId: " + userId
+ ", remaining users: " + mUsersCleaningUp.size()); + ", remaining users: " + mUsersCleaningUp.size());
mUsersCleaningUp.remove(userId); mUsersCleaningUp.remove(userId);
@@ -107,7 +107,7 @@ public class BiometricTestSession implements AutoCloseable {
@RequiresPermission(TEST_BIOMETRIC) @RequiresPermission(TEST_BIOMETRIC)
private void setTestHalEnabled(boolean enabled) { private void setTestHalEnabled(boolean enabled) {
try { try {
Log.w(TAG, "setTestHalEnabled, sensor: " + mSensorId + " enabled: " + enabled); Log.w(getTag(), "setTestHalEnabled, sensor: " + mSensorId + " enabled: " + enabled);
mTestSession.setTestHalEnabled(enabled); mTestSession.setTestHalEnabled(enabled);
} catch (RemoteException e) { } catch (RemoteException e) {
throw e.rethrowFromSystemServer(); throw e.rethrowFromSystemServer();
@@ -217,7 +217,7 @@ public class BiometricTestSession implements AutoCloseable {
public void cleanupInternalState(int userId) { public void cleanupInternalState(int userId) {
try { try {
if (mUsersCleaningUp.contains(userId)) { 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); mUsersCleaningUp.add(userId);
@@ -230,6 +230,7 @@ public class BiometricTestSession implements AutoCloseable {
@Override @Override
@RequiresPermission(TEST_BIOMETRIC) @RequiresPermission(TEST_BIOMETRIC)
public void close() { 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 // Cleanup can be performed using the test HAL, since it always responds to enumerate with
// zero enrollments. // zero enrollments.
if (!mTestedUsers.isEmpty()) { if (!mTestedUsers.isEmpty()) {
@@ -239,15 +240,19 @@ public class BiometricTestSession implements AutoCloseable {
} }
try { try {
Log.d(TAG, "Awaiting latch..."); Log.d(getTag(), "Awaiting latch...");
mCloseLatch.await(10, TimeUnit.SECONDS); mCloseLatch.await(3, TimeUnit.SECONDS);
Log.d(TAG, "Finished awaiting"); Log.d(getTag(), "Finished awaiting");
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(TAG, "Latch interrupted", e); Log.e(getTag(), "Latch interrupted", e);
} }
} }
// Disable the test HAL after the sensor becomes idle. // Disable the test HAL after the sensor becomes idle.
setTestHalEnabled(false); 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 { 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; @NonNull private final Context mContext;
private final int mSensorId; private final int mSensorId;
@@ -230,10 +230,12 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
public void cleanupInternalState(int userId) { public void cleanupInternalState(int userId) {
Utils.checkPermission(mContext, TEST_BIOMETRIC); Utils.checkPermission(mContext, TEST_BIOMETRIC);
Slog.d(TAG, "cleanupInternalState: " + userId);
mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() { mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
@Override @Override
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) { public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
try { try {
Slog.d(TAG, "onClientStarted: " + clientMonitor);
mCallback.onCleanupStarted(clientMonitor.getTargetUserId()); mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e); Slog.e(TAG, "Remote exception", e);
@@ -244,6 +246,7 @@ public class BiometricTestSessionImpl extends ITestSession.Stub {
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor, public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
boolean success) { boolean success) {
try { try {
Slog.d(TAG, "onClientFinished: " + clientMonitor);
mCallback.onCleanupFinished(clientMonitor.getTargetUserId()); mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception", 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.AuthenticationClient;
import com.android.server.biometrics.sensors.BaseClientMonitor; import com.android.server.biometrics.sensors.BaseClientMonitor;
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter; 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.InvalidationRequesterClient;
import com.android.server.biometrics.sensors.LockoutResetDispatcher; import com.android.server.biometrics.sensors.LockoutResetDispatcher;
import com.android.server.biometrics.sensors.PerformanceTracker; import com.android.server.biometrics.sensors.PerformanceTracker;
@@ -443,7 +442,7 @@ public class FaceProvider implements IBinder.DeathRecipient, ServiceProvider {
mContext.getOpPackageName(), sensorId, enrolledList, mContext.getOpPackageName(), sensorId, enrolledList,
FaceUtils.getInstance(sensorId), FaceUtils.getInstance(sensorId),
mSensors.get(sensorId).getAuthenticatorIds()); 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 { class BiometricTestSessionImpl extends ITestSession.Stub {
private static final String TAG = "BiometricTestSessionImpl"; private static final String TAG = "fp/aidl/BiometricTestSessionImpl";
@NonNull private final Context mContext; @NonNull private final Context mContext;
private final int mSensorId; private final int mSensorId;
@@ -198,10 +198,12 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
public void cleanupInternalState(int userId) { public void cleanupInternalState(int userId) {
Utils.checkPermission(mContext, TEST_BIOMETRIC); Utils.checkPermission(mContext, TEST_BIOMETRIC);
Slog.d(TAG, "cleanupInternalState: " + userId);
mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() { mProvider.scheduleInternalCleanup(mSensorId, userId, new BaseClientMonitor.Callback() {
@Override @Override
public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) { public void onClientStarted(@NonNull BaseClientMonitor clientMonitor) {
try { try {
Slog.d(TAG, "onClientStarted: " + clientMonitor);
mCallback.onCleanupStarted(clientMonitor.getTargetUserId()); mCallback.onCleanupStarted(clientMonitor.getTargetUserId());
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e); Slog.e(TAG, "Remote exception", e);
@@ -212,6 +214,7 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
public void onClientFinished(@NonNull BaseClientMonitor clientMonitor, public void onClientFinished(@NonNull BaseClientMonitor clientMonitor,
boolean success) { boolean success) {
try { try {
Slog.d(TAG, "onClientFinished: " + clientMonitor);
mCallback.onCleanupFinished(clientMonitor.getTargetUserId()); mCallback.onCleanupFinished(clientMonitor.getTargetUserId());
} catch (RemoteException e) { } catch (RemoteException e) {
Slog.e(TAG, "Remote exception", e); Slog.e(TAG, "Remote exception", e);

View File

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