Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2108ea02 authored by Jeff Pu's avatar Jeff Pu
Browse files

Simulate finger touch with virtual fingerprint hal

Bug: 277780272
Test: atest BiometricsE2eTests
Change-Id: Ib5c044bec3490e073a778c47a12ccfccd928eb83
parent 01c82157
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -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);
            }
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -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) {};
}
+14 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}