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

Commit 8cc77410 authored by Kevin Chyn's avatar Kevin Chyn Committed by Android (Google) Code Review
Browse files

Merge "Add FingerprintManager#hasEnrolledTemplatesForAnySensor"

parents 5cb7da24 1f57d493
Loading
Loading
Loading
Loading
+24 −5
Original line number Diff line number Diff line
@@ -765,6 +765,26 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        return hasEnrolledFingerprints(userId);
    }

    /**
     * Checks if the specified user has enrollments in any of the specified sensors.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public boolean hasEnrolledTemplatesForAnySensor(int userId,
            @NonNull List<FingerprintSensorPropertiesInternal> sensors) {
        if (mService == null) {
            Slog.w(TAG, "hasEnrolledTemplatesForAnySensor: no fingerprint service");
            return false;
        }

        try {
            return mService.hasEnrolledTemplatesForAnySensor(userId, sensors,
                    mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * @hide
     */
@@ -778,7 +798,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        try {
            mService.setUdfpsOverlayController(controller);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
    }

@@ -795,7 +815,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        try {
            mService.onPointerDown(sensorId, x, y, minor, major);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
    }

@@ -812,7 +832,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
        try {
            mService.onPointerUp(sensorId);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
    }

@@ -885,9 +905,8 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
            }
            return mService.getSensorPropertiesInternal(mContext.getOpPackageName());
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        }
        return new ArrayList<>();
    }

    /**
+3 −0
Original line number Diff line number Diff line
@@ -100,6 +100,9 @@ interface IFingerprintService {
    // Determine if a user has at least one enrolled fingerprint
    boolean hasEnrolledFingerprints(int userId, String opPackageName);

    // Determine if a user has at least one enrolled fingerprint in any of the specified sensors
    boolean hasEnrolledTemplatesForAnySensor(int userId, in List<FingerprintSensorPropertiesInternal> sensors, String opPackageName);

    // Return the LockoutTracker status for the specified user
    int getLockoutModeForUser(int userId);

+21 −0
Original line number Diff line number Diff line
@@ -468,6 +468,27 @@ public class FingerprintService extends SystemService {
                    .isEmpty();
        }

        @Override // Binder call
        public boolean hasEnrolledTemplatesForAnySensor(int userId,
                @NonNull List<FingerprintSensorPropertiesInternal> sensors,
                @NonNull String opPackageName) {
            Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);

            for (FingerprintSensorPropertiesInternal prop : sensors) {
                final ServiceProvider provider = getProviderForSensor(prop.sensorId);
                if (provider == null) {
                    Slog.w(TAG, "Null provider for sensorId: " + prop.sensorId
                            + ", caller: " + opPackageName);
                    continue;
                }

                if (!provider.getEnrolledFingerprints(prop.sensorId, userId).isEmpty()) {
                    return true;
                }
            }
            return false;
        }

        @Override // Binder call
        public @LockoutTracker.LockoutMode int getLockoutModeForUser(int userId) {
            Utils.checkPermission(getContext(), USE_BIOMETRIC_INTERNAL);