Simulate finger touch with virtual fingerprint hal

Bug: 277780272
Test: atest BiometricsE2eTests
Change-Id: Ib5c044bec3490e073a778c47a12ccfccd928eb83
This commit is contained in:
Jeff Pu
2023-06-14 14:13:24 +00:00
parent 01c82157b6
commit 2108ea0285
4 changed files with 41 additions and 1 deletions

View File

@@ -913,7 +913,6 @@ public class FingerprintService extends SystemService {
}
provider.onPointerDown(requestId, sensorId, pc);
}
@android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
@Override
@@ -1182,4 +1181,15 @@ public class FingerprintService extends SystemService {
}
}
}
void simulateVhalFingerDown() {
if (Utils.isVirtualEnabled(getContext())) {
Slog.i(TAG, "Simulate virtual HAL finger down event");
final Pair<Integer, ServiceProvider> provider = mRegistry.getSingleProvider();
if (provider != null) {
provider.second.simulateVhalFingerDown(UserHandle.getCallingUserId(),
provider.first);
}
}
}
}

View File

@@ -45,6 +45,8 @@ public class FingerprintShellCommand extends ShellCommand {
return doHelp();
case "sync":
return doSync();
case "fingerdown":
return doSimulateVhalFingerDown();
default:
getOutPrintWriter().println("Unrecognized command: " + cmd);
}
@@ -62,6 +64,8 @@ public class FingerprintShellCommand extends ShellCommand {
pw.println(" Print this help text.");
pw.println(" sync");
pw.println(" Sync enrollments now (virtualized sensors only).");
pw.println(" fingerdown");
pw.println(" Simulate finger down event (virtualized sensors only).");
}
private int doHelp() {
@@ -73,4 +77,9 @@ public class FingerprintShellCommand extends ShellCommand {
mService.syncEnrollmentsNow();
return 0;
}
private int doSimulateVhalFingerDown() {
mService.simulateVhalFingerDown();
return 0;
}
}

View File

@@ -157,4 +157,11 @@ public interface ServiceProvider extends
* @param sensorId sensor ID of the associated operation
*/
default void scheduleWatchdog(int sensorId) {}
/**
* Simulate fingerprint down touch event for virtual HAL
* @param userId user ID
* @param sensorId sensor ID
*/
default void simulateVhalFingerDown(int userId, int sensorId) {};
}

View File

@@ -856,4 +856,18 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
}
biometricScheduler.startWatchdog();
}
@Override
public void simulateVhalFingerDown(int userId, int sensorId) {
Slog.d(getTag(), "Simulate virtual HAL finger down event");
final AidlSession session = mFingerprintSensors.get(sensorId).getSessionForUser(userId);
final PointerContext pc = new PointerContext();
try {
session.getSession().onPointerDownWithContext(pc);
session.getSession().onUiReady();
session.getSession().onPointerUpWithContext(pc);
} catch (RemoteException e) {
Slog.e(getTag(), "failed hal operation ", e);
}
}
}