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

Commit 13eb5813 authored by Curtis Belmonte's avatar Curtis Belmonte Committed by Kevin Chyn
Browse files

Add setAllowedAuthenticators(int) to BiometricPrompt

Introduces a BiometricPrompt.PromptInfo#setAllowedAuthenticators(int)
method to allow a caller to specify whether to allow BiometricPrompt to
authenticate with device credential, biometric auth, or either. Also
renames the non-public Authenticator class to Authenticators, to avoid a
name collision and potential confusion with other Authenticator classes.

Test: make -j update-api
Test: atest AuthBiometricViewTest
Test: atest AuthContainerViewTest
Test: atest AuthControllerTest
Test: atest BiometricServiceTest

Bug: 80525177
Change-Id: I51da3ff0dcc7e49adb2d7f1c9cdaa12a55b11565
parent 6697c2fe
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -16782,9 +16782,21 @@ package android.hardware.biometrics {
    field public static final int BIOMETRIC_SUCCESS = 0; // 0x0
  }
  public static interface BiometricManager.Authenticators {
    field public static final int BIOMETRIC_STRONG = 15; // 0xf
    field public static final int BIOMETRIC_WEAK = 255; // 0xff
    field public static final int DEVICE_CREDENTIAL = 32768; // 0x8000
  }
  public class BiometricPrompt {
    method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public void authenticate(@NonNull android.hardware.biometrics.BiometricPrompt.CryptoObject, @NonNull android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.biometrics.BiometricPrompt.AuthenticationCallback);
    method @RequiresPermission(android.Manifest.permission.USE_BIOMETRIC) public void authenticate(@NonNull android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.hardware.biometrics.BiometricPrompt.AuthenticationCallback);
    method @Nullable public int getAllowedAuthenticators();
    method @Nullable public CharSequence getDescription();
    method @Nullable public CharSequence getNegativeButtonText();
    method @Nullable public CharSequence getSubtitle();
    method @NonNull public CharSequence getTitle();
    method public boolean isConfirmationRequired();
    field public static final int BIOMETRIC_ACQUIRED_GOOD = 0; // 0x0
    field public static final int BIOMETRIC_ACQUIRED_IMAGER_DIRTY = 3; // 0x3
    field public static final int BIOMETRIC_ACQUIRED_INSUFFICIENT = 2; // 0x2
@@ -16820,9 +16832,10 @@ package android.hardware.biometrics {
  public static class BiometricPrompt.Builder {
    ctor public BiometricPrompt.Builder(android.content.Context);
    method @NonNull public android.hardware.biometrics.BiometricPrompt build();
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setAllowedAuthenticators(int);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setConfirmationRequired(boolean);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDescription(@NonNull CharSequence);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDeviceCredentialAllowed(boolean);
    method @Deprecated @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setDeviceCredentialAllowed(boolean);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setNegativeButton(@NonNull CharSequence, @NonNull java.util.concurrent.Executor, @NonNull android.content.DialogInterface.OnClickListener);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setSubtitle(@NonNull CharSequence);
    method @NonNull public android.hardware.biometrics.BiometricPrompt.Builder setTitle(@NonNull CharSequence);
+9 −0
Original line number Diff line number Diff line
@@ -2172,6 +2172,15 @@ package android.hardware {
}
package android.hardware.biometrics {
  public static interface BiometricManager.Authenticators {
    field public static final int BIOMETRIC_CONVENIENCE = 4095; // 0xfff
    field public static final int EMPTY_SET = 0; // 0x0
  }
}
package android.hardware.camera2 {
  public abstract class CameraDevice implements java.lang.AutoCloseable {
+0 −35
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.biometrics;

/**
 * Type of authenticators defined on a granularity that the BiometricManager / BiometricPrompt
 * supports.
 * @hide
 */
public class Authenticator {

    /**
     * Device credential, e.g. Pin/Pattern/Password.
     */
    public static final int TYPE_CREDENTIAL = 1 << 0;
    /**
     * Encompasses all biometrics on the device, e.g. Fingerprint/Iris/Face.
     */
    public static final int TYPE_BIOMETRIC = 1 << 1;

}
+72 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;

import android.annotation.IntDef;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -65,6 +66,77 @@ public class BiometricManager {
            BIOMETRIC_ERROR_NO_HARDWARE})
    @interface BiometricError {}

    /**
     * Types of authenticators, defined at a level of granularity supported by
     * {@link BiometricManager} and {@link BiometricPrompt}.
     *
     * <p>Types may combined via bitwise OR into a single integer representing multiple
     * authenticators (e.g. <code>DEVICE_CREDENTIAL | BIOMETRIC_WEAK</code>).
     */
    public interface Authenticators {
        /**
         * An {@link IntDef} representing valid combinations of authenticator types.
         * @hide
         */
        @IntDef(flag = true, value = {
                BIOMETRIC_STRONG,
                BIOMETRIC_WEAK,
                DEVICE_CREDENTIAL,
        })
        @interface Types {}

        /**
         * Empty set with no authenticators specified.
         * @hide
         */
        @SystemApi
        int EMPTY_SET = 0x0;

        /**
         * Placeholder for the theoretical strongest biometric security tier.
         * @hide
         */
        int BIOMETRIC_MAX_STRENGTH = 0x001;

        /**
         * Any biometric (e.g. fingerprint, iris, or face) on the device that meets or exceeds the
         * requirements for <strong>Strong</strong>, as defined by the Android CDD.
         */
        int BIOMETRIC_STRONG = 0x00F;

        /**
         * Any biometric (e.g. fingerprint, iris, or face) on the device that meets or exceeds the
         * requirements for <strong>Weak</strong>, as defined by the Android CDD.
         *
         * <p>Note that this is a superset of {@link #BIOMETRIC_STRONG} and is defined such that
         * <code>BIOMETRIC_STRONG | BIOMETRIC_WEAK == BIOMETRIC_WEAK</code>.
         */
        int BIOMETRIC_WEAK = 0x0FF;

        /**
         * Any biometric (e.g. fingerprint, iris, or face) on the device that meets or exceeds the
         * requirements for <strong>Convenience</strong>, as defined by the Android CDD. This
         * is not a valid parameter to any of the {@link android.hardware.biometrics} APIs, since
         * the CDD allows only {@link #BIOMETRIC_WEAK} and stronger authenticators to participate.
         * @hide
         */
        @SystemApi
        int BIOMETRIC_CONVENIENCE = 0xFFF;

        /**
         * Placeholder for the theoretical weakest biometric security tier.
         * @hide
         */
        int BIOMETRIC_MIN_STRENGTH = 0x7FFF;

        /**
         * The non-biometric credential used to secure the device (i.e., PIN, pattern, or password).
         * This should typically only be used in combination with a biometric auth type, such as
         * {@link #BIOMETRIC_WEAK}.
         */
        int DEVICE_CREDENTIAL = 1 << 15;
    }

    private final Context mContext;
    private final IAuthService mService;
    private final boolean mHasHardware;
+239 −80

File changed.

Preview size limit exceeded, changes collapsed.

Loading