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

Commit 8429da25 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

14/n: Animate to device credential UI when lockout occurs

Test: manual test with BiometricPromptDemo
Test: atest com.android.systemui.biometrics
Test: atest BiometricServiceTest

Change-Id: I83547c28f1b164dc772b01861430f0d479e47a75
parent 8cbb488b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ oneway interface IStatusBar
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
    void onBiometricHelp(String message);
    // Used to set a message - the dialog will dismiss after a certain amount of time
    void onBiometricError(String error);
    void onBiometricError(int errorCode, 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
@@ -107,7 +107,7 @@ interface IStatusBarService
    // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc
    void onBiometricHelp(String message);
    // Used to set a message - the dialog will dismiss after a certain amount of time
    void onBiometricError(String error);
    void onBiometricError(int errorCode, String error);
    // Used to hide the biometric dialog when the AuthenticationClient is stopped
    void hideBiometricDialog();
}
+11 −5
Original line number Diff line number Diff line
@@ -584,11 +584,7 @@ public abstract class AuthBiometricView extends LinearLayout {
                mCallback.onAction(Callback.ACTION_USER_CANCELED);
            } else {
                if (isDeviceCredentialAllowed()) {
                    updateSize(AuthDialog.SIZE_LARGE);
                    mHandler.postDelayed(() -> {
                        mCallback.onAction(Callback.ACTION_USE_DEVICE_CREDENTIAL);
                    }, mInjector.getAnimateCredentialStartDelayMs());

                    startTransitionToCredentialUI();
                } else {
                    mCallback.onAction(Callback.ACTION_BUTTON_NEGATIVE);
                }
@@ -607,6 +603,16 @@ public abstract class AuthBiometricView extends LinearLayout {
        });
    }

    /**
     * Kicks off the animation process and invokes the callback.
     */
    void startTransitionToCredentialUI() {
        updateSize(AuthDialog.SIZE_LARGE);
        mHandler.postDelayed(() -> {
            mCallback.onAction(Callback.ACTION_USE_DEVICE_CREDENTIAL);
        }, mInjector.getAnimateCredentialStartDelayMs());
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
+12 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public class AuthContainerView extends LinearLayout
    private final CredentialCallback mCredentialCallback;

    @VisibleForTesting final FrameLayout mFrameLayout;
    private final AuthBiometricView mBiometricView;
    @VisibleForTesting AuthBiometricView mBiometricView;
    @VisibleForTesting AuthCredentialView mCredentialView;

    private final ImageView mBackgroundView;
@@ -275,6 +275,12 @@ public class AuthContainerView extends LinearLayout
        requestFocus();
    }

    @Override
    public boolean isAllowDeviceCredentials() {
        return mConfig.mBiometricPromptBundle
                .getBoolean(BiometricPrompt.KEY_ALLOW_DEVICE_CREDENTIAL);
    }

    private void addBiometricView() {
        mBiometricView.setRequireConfirmation(mConfig.mRequireConfirmation);
        mBiometricView.setPanelController(mPanelController);
@@ -429,6 +435,11 @@ public class AuthContainerView extends LinearLayout
        return mConfig.mOpPackageName;
    }

    @Override
    public void animateToCredentialUI() {
        mBiometricView.startTransitionToCredentialUI();
    }

    @VisibleForTesting
    void animateAway(int reason) {
        animateAway(true /* sendReason */, reason);
+11 −3
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.app.TaskStackListener;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.BiometricPrompt;
import android.hardware.biometrics.IBiometricServiceReceiverInternal;
import android.os.Bundle;
@@ -242,10 +243,17 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
    }

    @Override
    public void onBiometricError(String error) {
        if (DEBUG) Log.d(TAG, "onBiometricError: " + error);
    public void onBiometricError(int errorCode, String error) {
        if (DEBUG) Log.d(TAG, "onBiometricError: " + errorCode + ", " + error);

        final boolean isLockout = errorCode == BiometricConstants.BIOMETRIC_ERROR_LOCKOUT
                || errorCode == BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT;
        if (mCurrentDialog.isAllowDeviceCredentials() && isLockout) {
            mCurrentDialog.animateToCredentialUI();
        } else {
            mCurrentDialog.onError(error);
        }
    }

    @Override
    public void hideBiometricDialog() {
Loading