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

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

Merge "Add BiometricPrompt.Builder#setAllowBackgroundAuthentication TestApi" into sc-dev

parents f4635759 8115bfc7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1035,9 +1035,11 @@ package android.hardware.biometrics {

  public class BiometricPrompt {
    method @NonNull public java.util.List<java.lang.Integer> getAllowedSensorIds();
    method public boolean isAllowBackgroundAuthentication();
  }

  public static class BiometricPrompt.Builder {
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.TEST_BIOMETRIC, "android.permission.USE_BIOMETRIC_INTERNAL"}) public android.hardware.biometrics.BiometricPrompt.Builder setAllowBackgroundAuthentication(boolean);
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.TEST_BIOMETRIC, "android.permission.USE_BIOMETRIC_INTERNAL"}) public android.hardware.biometrics.BiometricPrompt.Builder setAllowedSensorIds(@NonNull java.util.List<java.lang.Integer>);
  }

+23 −0
Original line number Diff line number Diff line
@@ -367,6 +367,20 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
            return this;
        }

        /**
         * @param allow If true, allows authentication when the calling package is not in the
         *              foreground. This is set to false by default.
         * @return This builder
         * @hide
         */
        @TestApi
        @NonNull
        @RequiresPermission(anyOf = {TEST_BIOMETRIC, USE_BIOMETRIC_INTERNAL})
        public Builder setAllowBackgroundAuthentication(boolean allow) {
            mPromptInfo.setAllowBackgroundAuthentication(allow);
            return this;
        }

        /**
         * If set check the Device Policy Manager for disabled biometrics.
         *
@@ -619,6 +633,15 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        return mPromptInfo.getAllowedSensorIds();
    }

    /**
     * @return The value set by {@link Builder#setAllowBackgroundAuthentication(boolean)}
     * @hide
     */
    @TestApi
    public boolean isAllowBackgroundAuthentication() {
        return mPromptInfo.isAllowBackgroundAuthentication();
    }

    /**
     * A wrapper class for the cryptographic operations supported by BiometricPrompt.
     *
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ interface IBiometricAuthenticator {
    // startPreparedClient().
    void prepareForAuthentication(boolean requireConfirmation, IBinder token, long operationId,
            int userId, IBiometricSensorReceiver sensorReceiver, String opPackageName,
            int cookie);
            int cookie, boolean allowBackgroundAuthentication);

    // Starts authentication with the previously prepared client.
    void startPreparedClient(int cookie);
+13 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class PromptInfo implements Parcelable {
    private boolean mDisallowBiometricsIfPolicyExists;
    private boolean mReceiveSystemEvents;
    @NonNull private List<Integer> mAllowedSensorIds = new ArrayList<>();
    private boolean mAllowBackgroundAuthentication;

    public PromptInfo() {

@@ -64,6 +65,7 @@ public class PromptInfo implements Parcelable {
        mDisallowBiometricsIfPolicyExists = in.readBoolean();
        mReceiveSystemEvents = in.readBoolean();
        mAllowedSensorIds = in.readArrayList(Integer.class.getClassLoader());
        mAllowBackgroundAuthentication = in.readBoolean();
    }

    public static final Creator<PromptInfo> CREATOR = new Creator<PromptInfo>() {
@@ -99,11 +101,14 @@ public class PromptInfo implements Parcelable {
        dest.writeBoolean(mDisallowBiometricsIfPolicyExists);
        dest.writeBoolean(mReceiveSystemEvents);
        dest.writeList(mAllowedSensorIds);
        dest.writeBoolean(mAllowBackgroundAuthentication);
    }

    public boolean containsTestConfigurations() {
        if (!mAllowedSensorIds.isEmpty()) {
            return true;
        } else if (mAllowBackgroundAuthentication) {
            return true;
        }
        return false;
    }
@@ -183,6 +188,10 @@ public class PromptInfo implements Parcelable {
        mAllowedSensorIds = sensorIds;
    }

    public void setAllowBackgroundAuthentication(boolean allow) {
        mAllowBackgroundAuthentication = allow;
    }

    // Getters

    public CharSequence getTitle() {
@@ -248,4 +257,8 @@ public class PromptInfo implements Parcelable {
    public List<Integer> getAllowedSensorIds() {
        return mAllowedSensorIds;
    }

    public boolean isAllowBackgroundAuthentication() {
        return mAllowBackgroundAuthentication;
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ interface IFaceService {
    // startPreparedClient().
    void prepareForAuthentication(int sensorId, boolean requireConfirmation, IBinder token, long operationId,
            int userId, IBiometricSensorReceiver sensorReceiver, String opPackageName,
            int cookie);
            int cookie, boolean allowBackgroundAuthentication);

    // Starts authentication with the previously prepared client.
    void startPreparedClient(int sensorId, int cookie);
Loading