Merge "Fix the race condition between fingerprint ennrollment sync command and the internal cleanup operations" into udc-dev
This commit is contained in:
@@ -82,7 +82,9 @@ import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.server.SystemService;
|
||||
import com.android.server.biometrics.Utils;
|
||||
import com.android.server.biometrics.log.BiometricContext;
|
||||
import com.android.server.biometrics.sensors.BaseClientMonitor;
|
||||
import com.android.server.biometrics.sensors.BiometricStateCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallback;
|
||||
import com.android.server.biometrics.sensors.ClientMonitorCallbackConverter;
|
||||
import com.android.server.biometrics.sensors.LockoutResetDispatcher;
|
||||
import com.android.server.biometrics.sensors.LockoutTracker;
|
||||
@@ -97,7 +99,9 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -1138,12 +1142,28 @@ public class FingerprintService extends SystemService {
|
||||
if (Utils.isVirtualEnabled(getContext())) {
|
||||
Slog.i(TAG, "Sync virtual enrollments");
|
||||
final int userId = ActivityManager.getCurrentUser();
|
||||
final CountDownLatch latch = new CountDownLatch(mRegistry.getProviders().size());
|
||||
for (ServiceProvider provider : mRegistry.getProviders()) {
|
||||
for (FingerprintSensorPropertiesInternal props : provider.getSensorProperties()) {
|
||||
provider.scheduleInternalCleanup(props.sensorId, userId, null /* callback */,
|
||||
true /* favorHalEnrollments */);
|
||||
provider.scheduleInternalCleanup(props.sensorId, userId,
|
||||
new ClientMonitorCallback() {
|
||||
@Override
|
||||
public void onClientFinished(
|
||||
@NonNull BaseClientMonitor clientMonitor,
|
||||
boolean success) {
|
||||
latch.countDown();
|
||||
if (!success) {
|
||||
Slog.e(TAG, "Sync virtual enrollments failed");
|
||||
}
|
||||
}
|
||||
}, true /* favorHalEnrollments */);
|
||||
}
|
||||
}
|
||||
try {
|
||||
latch.await(3, TimeUnit.SECONDS);
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Failed to wait for sync finishing", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user