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

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

Merge changes from topic "biometric-manager"

* changes:
  Move biometric setting observer from KeyguardUpdateMonitor to BiometricService
  Change BiometricManager#hasEnrolledBiometrics to canAuthenticate
parents 712c7974 b7b54a60
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -152,9 +152,10 @@ java_defaults {
        ":libcamera_client_framework_aidl",
        "core/java/android/hardware/IConsumerIrService.aidl",
        "core/java/android/hardware/ISerialManager.aidl",
        "core/java/android/hardware/biometrics/IBiometricEnabledOnKeyguardCallback.aidl",
        "core/java/android/hardware/biometrics/IBiometricPromptReceiver.aidl",
        "core/java/android/hardware/biometrics/IBiometricService.aidl",
        "core/java/android/hardware/biometrics/IBiometricServiceReceiver.aidl",
        "core/java/android/hardware/biometrics/IBiometricPromptReceiver.aidl",
        "core/java/android/hardware/biometrics/IBiometricServiceLockoutResetCallback.aidl",
        "core/java/android/hardware/display/IDisplayManager.aidl",
        "core/java/android/hardware/display/IDisplayManagerCallback.aidl",
+4 −1
Original line number Diff line number Diff line
@@ -15963,7 +15963,10 @@ package android.hardware {
package android.hardware.biometrics {
  public class BiometricManager {
    method public boolean hasEnrolledBiometrics();
    method public int canAuthenticate();
    field public static final int ERROR_NONE = 0; // 0x0
    field public static final int ERROR_NO_BIOMETRICS = 11; // 0xb
    field public static final int ERROR_UNAVAILABLE = 1; // 0x1
  }
  public class BiometricPrompt {
+7 −0
Original line number Diff line number Diff line
@@ -33,6 +33,13 @@ public interface BiometricConstants {
    // removal.
    //

    /**
     * This was not added here since it would update BiometricPrompt API. But, is used in
     * BiometricManager.
     * @hide
     */
    int BIOMETRIC_ERROR_NONE = 0;

    /**
     * The hardware is unavailable. Try again later.
     */
+52 −7
Original line number Diff line number Diff line
@@ -17,16 +17,35 @@
package android.hardware.biometrics;

import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;

import android.annotation.RequiresPermission;
import android.content.Context;
import android.os.RemoteException;
import android.util.Slog;

/**
 * A class that contains biometric utilities. For authentication, see {@link BiometricPrompt}.
 */
public class BiometricManager {

    private static final String TAG = "BiometricManager";

    /**
     * No error detected.
     */
    public static final int ERROR_NONE = BiometricConstants.BIOMETRIC_ERROR_NONE;

    /**
     * The hardware is unavailable. Try again later.
     */
    public static final int ERROR_UNAVAILABLE = BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE;

    /**
     * The user does not have any biometrics enrolled.
     */
    public static final int ERROR_NO_BIOMETRICS = BiometricConstants.BIOMETRIC_ERROR_NO_BIOMETRICS;

    private final Context mContext;
    private final IBiometricService mService;

@@ -41,16 +60,42 @@ public class BiometricManager {
    }

    /**
     * Determine if there is at least one biometric enrolled.
     * Determine if biometrics can be used. In other words, determine if {@link BiometricPrompt}
     * can be expected to be shown (hardware available, templates enrolled, user-enabled).
     *
     * @return true if at least one biometric is enrolled, false otherwise
     * @return Returns {@link #ERROR_NO_BIOMETRICS} if the user does not have any enrolled, or
     *     {@link #ERROR_UNAVAILABLE} if none are currently supported/enabled. Returns
     *     {@link #ERROR_NONE} if a biometric can currently be used (enrolled and available).
     */
    @RequiresPermission(USE_BIOMETRIC)
    public boolean hasEnrolledBiometrics() {
    public int canAuthenticate() {
        if (mService != null) {
            try {
            return mService.hasEnrolledBiometrics(mContext.getOpPackageName());
                return mService.canAuthenticate(mContext.getOpPackageName());
            } catch (RemoteException e) {
            return false;
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "hasEnrolledBiometrics(): Service not connected");
            return ERROR_UNAVAILABLE;
        }
    }

    /**
     * Listens for changes to biometric eligibility on keyguard from user settings.
     * @param callback
     * @hide
     */
    @RequiresPermission(USE_BIOMETRIC_INTERNAL)
    public void registerEnabledOnKeyguardCallback(IBiometricEnabledOnKeyguardCallback callback) {
        if (mService != null) {
            try {
                mService.registerEnabledOnKeyguardCallback(callback);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        } else {
            Slog.w(TAG, "registerEnabledOnKeyguardCallback(): Service not connected");
        }
    }
}
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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;

import android.hardware.biometrics.BiometricSourceType;

/**
 * @hide
 */
oneway interface IBiometricEnabledOnKeyguardCallback {
    void onChanged(in BiometricSourceType type, boolean enabled);
}
 No newline at end of file
Loading