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

Commit bd1056fc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "biometric-prompt"

* changes:
  Refactor FingerprintDialog to be Biometric
  Clean up interface between controller and view
parents 7ef59761 e927566c
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -140,14 +140,14 @@ oneway interface IStatusBar

    void showShutdownUi(boolean isReboot, String reason);

    // Used to show the dialog when FingerprintService starts authentication
    void showFingerprintDialog(in Bundle bundle, IBiometricPromptReceiver receiver);
    // Used to hide the dialog when a finger is authenticated
    void onFingerprintAuthenticated();
    // Used to show the dialog when BiometricService starts authentication
    void showBiometricDialog(in Bundle bundle, IBiometricPromptReceiver receiver);
    // Used to hide the dialog when a biometric is authenticated
    void onBiometricAuthenticated();
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
    void onFingerprintHelp(String message);
    void onBiometricHelp(String message);
    // Used to set a message - the dialog will dismiss after a certain amount of time
    void onFingerprintError(String error);
    // Used to hide the fingerprint dialog when the authenticationclient is stopped
    void hideFingerprintDialog();
    void onBiometricError(String error);
    // Used to hide the biometric dialog when the AuthenticationClient is stopped
    void hideBiometricDialog();
}
+8 −8
Original line number Diff line number Diff line
@@ -90,14 +90,14 @@ interface IStatusBarService
    void showPinningEnterExitToast(boolean entering);
    void showPinningEscapeToast();

    // Used to show the dialog when FingerprintService starts authentication
    void showFingerprintDialog(in Bundle bundle, IBiometricPromptReceiver receiver);
    // Used to hide the dialog when a finger is authenticated
    void onFingerprintAuthenticated();
    // Used to show the dialog when BiometricService starts authentication
    void showBiometricDialog(in Bundle bundle, IBiometricPromptReceiver receiver);
    // Used to hide the dialog when a biometric is authenticated
    void onBiometricAuthenticated();
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
    void onFingerprintHelp(String message);
    void onBiometricHelp(String message);
    // Used to set a message - the dialog will dismiss after a certain amount of time
    void onFingerprintError(String error);
    // Used to hide the fingerprint dialog when the authenticationclient is stopped
    void hideFingerprintDialog();
    void onBiometricError(String error);
    // Used to hide the biometric dialog when the AuthenticationClient is stopped
    void hideBiometricDialog();
}
+1 −1
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ Shows the global actions dialog (long-press power).

Draws decorations about the screen in software (e.g. rounded corners, cutouts).

### [com.android.systemui.fingerprint.FingerprintDialogImpl](/packages/SystemUI/src/com/android/systemui/fingerprint/FingerprintDialogImpl.java)
### [com.android.systemui.biometrics.BiometricDialogImpl](/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java)

Fingerprint UI.

+1 −1
Original line number Diff line number Diff line
@@ -354,7 +354,7 @@
        <item>com.android.systemui.LatencyTester</item>
        <item>com.android.systemui.globalactions.GlobalActionsComponent</item>
        <item>com.android.systemui.ScreenDecorations</item>
        <item>com.android.systemui.fingerprint.FingerprintDialogImpl</item>
        <item>com.android.systemui.biometrics.BiometricDialogImpl</item>
        <item>com.android.systemui.SliceBroadcastRelayHandler</item>
    </string-array>

+69 −48
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License
 */

package com.android.systemui.fingerprint;
package com.android.systemui.biometrics;

import android.content.Context;
import android.content.pm.PackageManager;
@@ -31,25 +31,28 @@ import com.android.internal.os.SomeArgs;
import com.android.systemui.SystemUI;
import com.android.systemui.statusbar.CommandQueue;

public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Callbacks {
/**
 * Receives messages sent from AuthenticationClient and shows the appropriate biometric UI (e.g.
 * FingerprintDialogView).
 */
public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callbacks {
    private static final String TAG = "FingerprintDialogImpl";
    private static final boolean DEBUG = true;

    protected static final int MSG_SHOW_DIALOG = 1;
    protected static final int MSG_FINGERPRINT_AUTHENTICATED = 2;
    protected static final int MSG_FINGERPRINT_HELP = 3;
    protected static final int MSG_FINGERPRINT_ERROR = 4;
    protected static final int MSG_HIDE_DIALOG = 5;
    protected static final int MSG_BUTTON_NEGATIVE = 6;
    protected static final int MSG_USER_CANCELED = 7;
    protected static final int MSG_BUTTON_POSITIVE = 8;
    protected static final int MSG_CLEAR_MESSAGE = 9;

    private static final int MSG_SHOW_DIALOG = 1;
    private static final int MSG_BIOMETRIC_AUTHENTICATED = 2;
    private static final int MSG_BIOMETRIC_HELP = 3;
    private static final int MSG_BIOMETRIC_ERROR = 4;
    private static final int MSG_HIDE_DIALOG = 5;
    private static final int MSG_BUTTON_NEGATIVE = 6;
    private static final int MSG_USER_CANCELED = 7;
    private static final int MSG_BUTTON_POSITIVE = 8;

    private FingerprintDialogView mDialogView;
    private WindowManager mWindowManager;
    private IBiometricPromptReceiver mReceiver;
    private boolean mDialogShowing;
    private Callback mCallback = new Callback();

    private Handler mHandler = new Handler() {
        @Override
@@ -58,14 +61,14 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
                case MSG_SHOW_DIALOG:
                    handleShowDialog((SomeArgs) msg.obj);
                    break;
                case MSG_FINGERPRINT_AUTHENTICATED:
                    handleFingerprintAuthenticated();
                case MSG_BIOMETRIC_AUTHENTICATED:
                    handleBiometricAuthenticated();
                    break;
                case MSG_FINGERPRINT_HELP:
                    handleFingerprintHelp((String) msg.obj);
                case MSG_BIOMETRIC_HELP:
                    handleBiometricHelp((String) msg.obj);
                    break;
                case MSG_FINGERPRINT_ERROR:
                    handleFingerprintError((String) msg.obj);
                case MSG_BIOMETRIC_ERROR:
                    handleBiometricError((String) msg.obj);
                    break;
                case MSG_HIDE_DIALOG:
                    handleHideDialog((Boolean) msg.obj);
@@ -79,13 +82,33 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
                case MSG_BUTTON_POSITIVE:
                    handleButtonPositive();
                    break;
                case MSG_CLEAR_MESSAGE:
                    handleClearMessage();
                    break;
            }
        }
    };

    private class Callback implements DialogViewCallback {
        @Override
        public void onUserCanceled() {
            mHandler.obtainMessage(BiometricDialogImpl.MSG_USER_CANCELED).sendToTarget();
        }

        @Override
        public void onErrorShown() {
            mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_HIDE_DIALOG,
                    false /* userCanceled */), BiometricPrompt.HIDE_DIALOG_DELAY);
        }

        @Override
        public void onNegativePressed() {
            mHandler.obtainMessage(BiometricDialogImpl.MSG_BUTTON_NEGATIVE).sendToTarget();
        }

        @Override
        public void onPositivePressed() {
            mHandler.obtainMessage(BiometricDialogImpl.MSG_BUTTON_POSITIVE).sendToTarget();
        }
    }

    @Override
    public void start() {
        if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
@@ -93,16 +116,16 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
        }
        getComponent(CommandQueue.class).addCallbacks(this);
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mDialogView = new FingerprintDialogView(mContext, mHandler);
        mDialogView = new FingerprintDialogView(mContext, mCallback);
    }

    @Override
    public void showFingerprintDialog(Bundle bundle, IBiometricPromptReceiver receiver) {
        if (DEBUG) Log.d(TAG, "showFingerprintDialog");
    public void showBiometricDialog(Bundle bundle, IBiometricPromptReceiver receiver) {
        if (DEBUG) Log.d(TAG, "showBiometricDialog");
        // Remove these messages as they are part of the previous client
        mHandler.removeMessages(MSG_FINGERPRINT_ERROR);
        mHandler.removeMessages(MSG_FINGERPRINT_HELP);
        mHandler.removeMessages(MSG_FINGERPRINT_AUTHENTICATED);
        mHandler.removeMessages(MSG_BIOMETRIC_ERROR);
        mHandler.removeMessages(MSG_BIOMETRIC_HELP);
        mHandler.removeMessages(MSG_BIOMETRIC_AUTHENTICATED);
        SomeArgs args = SomeArgs.obtain();
        args.arg1 = bundle;
        args.arg2 = receiver;
@@ -110,26 +133,26 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
    }

    @Override
    public void onFingerprintAuthenticated() {
        if (DEBUG) Log.d(TAG, "onFingerprintAuthenticated");
        mHandler.obtainMessage(MSG_FINGERPRINT_AUTHENTICATED).sendToTarget();
    public void onBiometricAuthenticated() {
        if (DEBUG) Log.d(TAG, "onBiometricAuthenticated");
        mHandler.obtainMessage(MSG_BIOMETRIC_AUTHENTICATED).sendToTarget();
    }

    @Override
    public void onFingerprintHelp(String message) {
        if (DEBUG) Log.d(TAG, "onFingerprintHelp: " + message);
        mHandler.obtainMessage(MSG_FINGERPRINT_HELP, message).sendToTarget();
    public void onBiometricHelp(String message) {
        if (DEBUG) Log.d(TAG, "onBiometricHelp: " + message);
        mHandler.obtainMessage(MSG_BIOMETRIC_HELP, message).sendToTarget();
    }

    @Override
    public void onFingerprintError(String error) {
        if (DEBUG) Log.d(TAG, "onFingerprintError: " + error);
        mHandler.obtainMessage(MSG_FINGERPRINT_ERROR, error).sendToTarget();
    public void onBiometricError(String error) {
        if (DEBUG) Log.d(TAG, "onBiometricError: " + error);
        mHandler.obtainMessage(MSG_BIOMETRIC_ERROR, error).sendToTarget();
    }

    @Override
    public void hideFingerprintDialog() {
        if (DEBUG) Log.d(TAG, "hideFingerprintDialog");
    public void hideBiometricDialog() {
        if (DEBUG) Log.d(TAG, "hideBiometricDialog");
        mHandler.obtainMessage(MSG_HIDE_DIALOG, false /* userCanceled */).sendToTarget();
    }

@@ -148,21 +171,23 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
        mDialogShowing = true;
    }

    private void handleFingerprintAuthenticated() {
        if (DEBUG) Log.d(TAG, "handleFingerprintAuthenticated");
    private void handleBiometricAuthenticated() {
        if (DEBUG) Log.d(TAG, "handleBiometricAuthenticated");

        // TODO: announce correct string depending on modality
        mDialogView.announceForAccessibility(
                mContext.getResources().getText(
                        com.android.internal.R.string.fingerprint_authenticated));
        handleHideDialog(false /* userCanceled */);
    }

    private void handleFingerprintHelp(String message) {
        if (DEBUG) Log.d(TAG, "handleFingerprintHelp: " + message);
    private void handleBiometricHelp(String message) {
        if (DEBUG) Log.d(TAG, "handleBiometricHelp: " + message);
        mDialogView.showHelpMessage(message);
    }

    private void handleFingerprintError(String error) {
        if (DEBUG) Log.d(TAG, "handleFingerprintError: " + error);
    private void handleBiometricError(String error) {
        if (DEBUG) Log.d(TAG, "handleBiometricError: " + error);
        if (!mDialogShowing) {
            if (DEBUG) Log.d(TAG, "Dialog already dismissed");
            return;
@@ -216,10 +241,6 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
        handleHideDialog(false /* userCanceled */);
    }

    private void handleClearMessage() {
        mDialogView.resetMessage();
    }

    private void handleUserCanceled() {
        handleHideDialog(true /* userCanceled */);
    }
Loading