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

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

Merge changes from topic "biometric-tests"

* changes:
  4/n: Make BiometricDialogView testable
  3/n: Move task stack listener to SystemUI
  2/n: Update BiometricService with cleaner lifecycle
  1/n: Update BiometricDialog (SystemUI side) with cleaner lifecycle
parents 336f7c75 27fafb76
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -100,9 +100,12 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
    /**
     * @hide
     */
    public static final int DISMISSED_REASON_POSITIVE = 1;
    public static final int DISMISSED_REASON_CONFIRMED = 1;

    /**
     * Dialog is done animating away after user clicked on the button set via
     * {@link BiometricPrompt.Builder#setNegativeButton(CharSequence, Executor,
     * DialogInterface.OnClickListener)}.
     * @hide
     */
    public static final int DISMISSED_REASON_NEGATIVE = 2;
@@ -112,6 +115,25 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
     */
    public static final int DISMISSED_REASON_USER_CANCEL = 3;

    /**
     * Authenticated, confirmation not required. Dialog animated away.
     * @hide
     */
    public static final int DISMISSED_REASON_CONFIRM_NOT_REQUIRED = 4;

    /**
     * Error message shown on SystemUI. When BiometricService receives this, the UI is already
     * gone.
     * @hide
     */
    public static final int DISMISSED_REASON_ERROR = 5;

    /**
     * Dialog dismissal requested by BiometricService.
     * @hide
     */
    public static final int DISMISSED_REASON_SERVER_REQUESTED = 6;

    private static class ButtonInfo {
        Executor executor;
        DialogInterface.OnClickListener listener;
@@ -362,7 +384,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
        @Override
        public void onDialogDismissed(int reason) throws RemoteException {
            // Check the reason and invoke OnClickListener(s) if necessary
            if (reason == DISMISSED_REASON_POSITIVE) {
            if (reason == DISMISSED_REASON_CONFIRMED) {
                mPositiveButtonInfo.executor.execute(() -> {
                    mPositiveButtonInfo.listener.onClick(null, DialogInterface.BUTTON_POSITIVE);
                });
+2 −2
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@ oneway interface IBiometricServiceReceiverInternal {
    // Notify BiometricService that authentication was successful. If user confirmation is required,
    // the auth token must be submitted into KeyStore.
    void onAuthenticationSucceeded(boolean requireConfirmation, in byte[] token);
    // Notify BiometricService that an error has occurred.
    void onAuthenticationFailed(int cookie, boolean requireConfirmation);
    // Notify BiometricService authentication was rejected.
    void onAuthenticationFailed();
    // Notify BiometricService than an error has occured. Forward to the correct receiver depending
    // on the cookie.
    void onError(int cookie, int error, String message);
+1 −1
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ oneway interface IStatusBar

    // Used to show the dialog when BiometricService starts authentication
    void showBiometricDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, int type,
            boolean requireConfirmation, int userId);
            boolean requireConfirmation, int userId, String opPackageName);
    // Used to hide the dialog when a biometric is authenticated
    void onBiometricAuthenticated(boolean authenticated, String failureReason);
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ interface IStatusBarService

    // Used to show the dialog when BiometricService starts authentication
    void showBiometricDialog(in Bundle bundle, IBiometricServiceReceiverInternal receiver, int type,
            boolean requireConfirmation, int userId);
            boolean requireConfirmation, int userId, String opPackageName);
    // Used to hide the dialog when a biometric is authenticated
    void onBiometricAuthenticated(boolean authenticated, String failureReason);
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
+108 −0
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 com.android.systemui.biometrics;

import android.hardware.biometrics.BiometricPrompt;
import android.os.Bundle;
import android.view.WindowManager;

import com.android.systemui.biometrics.ui.BiometricDialogView;

/**
 * Interface for the biometric dialog UI.
 */
public interface BiometricDialog {

    // TODO: Clean up save/restore state
    String[] KEYS_TO_BACKUP = {
            BiometricPrompt.KEY_TITLE,
            BiometricPrompt.KEY_USE_DEFAULT_TITLE,
            BiometricPrompt.KEY_SUBTITLE,
            BiometricPrompt.KEY_DESCRIPTION,
            BiometricPrompt.KEY_POSITIVE_TEXT,
            BiometricPrompt.KEY_NEGATIVE_TEXT,
            BiometricPrompt.KEY_REQUIRE_CONFIRMATION,
            BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL,
            BiometricPrompt.KEY_FROM_CONFIRM_DEVICE_CREDENTIAL,

            BiometricDialogView.KEY_TRY_AGAIN_VISIBILITY,
            BiometricDialogView.KEY_CONFIRM_VISIBILITY,
            BiometricDialogView.KEY_CONFIRM_ENABLED,
            BiometricDialogView.KEY_STATE,
            BiometricDialogView.KEY_ERROR_TEXT_VISIBILITY,
            BiometricDialogView.KEY_ERROR_TEXT_STRING,
            BiometricDialogView.KEY_ERROR_TEXT_IS_TEMPORARY,
            BiometricDialogView.KEY_ERROR_TEXT_COLOR,
    };

    /**
     * Show the dialog.
     * @param wm
     * @param skipIntroAnimation
     */
    void show(WindowManager wm, boolean skipIntroAnimation);

    /**
     * Dismiss the dialog without sending a callback.
     */
    void dismissWithoutCallback(boolean animate);

    /**
     * Dismiss the dialog. Animate away.
     */
    void dismissFromSystemServer();

    /**
     * Biometric authenticated. May be pending user confirmation, or completed.
     */
    void onAuthenticationSucceeded();

    /**
     * Authentication failed (reject, timeout). Dialog stays showing.
     * @param failureReason
     */
    void onAuthenticationFailed(String failureReason);

    /**
     * Authentication rejected, or help message received.
     * @param help
     */
    void onHelp(String help);

    /**
     * Authentication failed. Dialog going away.
     * @param error
     */
    void onError(String error);

    /**
     * Save the current state.
     * @param outState
     */
    void onSaveState(Bundle outState);

    /**
     * Restore a previous state.
     * @param savedState
     */
    void restoreState(Bundle savedState);

    /**
     * Get the client's package name
     */
    String getOpPackageName();
}
Loading