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

Commit bf830a37 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

Add setActiveUser to BiometricManager/Service

On devices with multiple biometrics, ConfirmCredentials can
potentially ask the user to authenticate using more than one
biometric. This is a wrapper that sets the active user for
all modalities.

Bug: 111461540

Test: With work profile set up, CC has same behavior as
      device running P.
      1) With one lock disabled, use modified BiometricPromptDemo
         to authenticate using CC in the work version of the app
      2) Go to normal version of the app, authenticating
         using BP (not CC) works with non-work biometric

Change-Id: I04b6f64d3fe373269366c243f406d897cb6fd83a
parent c79856b4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -201,10 +201,21 @@ public interface BiometricAuthenticator {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * @return true if the user has enrolled templates for this biometric.
     */
    default boolean hasEnrolledTemplates(int userId) {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * Sets the active user. This is meant to be used to select the current profile
     * to allow separate templates for work profile.
     */
    default void setActiveUser(int userId) {
        throw new UnsupportedOperationException("Stub!");
    }

    /**
     * This call warms up the hardware and starts scanning for valid biometrics. It terminates
     * when {@link AuthenticationCallback#onAuthenticationError(int,
+18 −0
Original line number Diff line number Diff line
@@ -98,4 +98,22 @@ public class BiometricManager {
            Slog.w(TAG, "registerEnabledOnKeyguardCallback(): Service not connected");
        }
    }

    /**
     * Sets the active user.
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void setActiveUser(int userId) {
        if (mService != null) {
            try {
                mService.setActiveUser(userId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "setActiveUser(): Service not connected");
        }
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -43,4 +43,7 @@ interface IBiometricService {

    // Register callback for when keyguard biometric eligibility changes.
    void registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback);

    // Explicitly set the active user.
    void setActiveUser(int userId);
}
+1 −0
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan
     * @hide
     */
    @RequiresPermission(MANAGE_BIOMETRIC)
    @Override
    public void setActiveUser(int userId) {
        if (mService != null) {
            try {
+1 −0
Original line number Diff line number Diff line
@@ -521,6 +521,7 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing
     * @hide
     */
    @RequiresPermission(MANAGE_FINGERPRINT)
    @Override
    public void setActiveUser(int userId) {
        if (mService != null) try {
            mService.setActiveUser(userId);
Loading