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

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

Merge changes Idb985b00,I41d3726d

* changes:
  Only show try again button for fingerprint
  Keep task stack listener around as long as dialog is showing
parents 11d70db8 c9744ace
Loading
Loading
Loading
Loading
+3 −20
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ public abstract class BiometricDialogView extends LinearLayout {
    private final DevicePolicyManager mDevicePolicyManager;
    private final float mAnimationTranslationOffset;
    private final int mErrorColor;
    private final int mTextColor;
    private final float mDialogWidth;
    private final DialogViewCallback mCallback;

@@ -92,6 +91,8 @@ public abstract class BiometricDialogView extends LinearLayout {
    protected final Button mNegativeButton;
    protected final Button mTryAgainButton;

    protected final int mTextColor;

    private Bundle mBundle;

    private int mLastState;
@@ -108,6 +109,7 @@ public abstract class BiometricDialogView extends LinearLayout {
    protected abstract boolean shouldAnimateForTransition(int oldState, int newState);
    protected abstract int getDelayAfterAuthenticatedDurationMs();
    protected abstract boolean shouldGrayAreaDismissDialog();
    protected abstract void handleClearMessage(boolean requireTryAgain);

    private final Runnable mShowAnimationRunnable = new Runnable() {
        @Override
@@ -421,20 +423,6 @@ public abstract class BiometricDialogView extends LinearLayout {
        return mLayout;
    }

    // Clears the temporary message and shows the help message. If requireTryAgain is true,
    // we will start the authenticating state again.
    private void handleClearMessage(boolean requireTryAgain) {
        if (!requireTryAgain) {
            updateState(STATE_AUTHENTICATING);
            mErrorText.setText(getHintStringResourceId());
            mErrorText.setTextColor(mTextColor);
            mErrorText.setVisibility(View.VISIBLE);
        } else {
            updateState(STATE_IDLE);
            mErrorText.setVisibility(View.INVISIBLE);
        }
    }

    // Shows an error/help message
    private void showTemporaryMessage(String message, boolean requireTryAgain) {
        mHandler.removeMessages(MSG_CLEAR_MESSAGE);
@@ -475,11 +463,6 @@ public abstract class BiometricDialogView extends LinearLayout {
    }

    public void showTryAgainButton(boolean show) {
        if (show) {
            mTryAgainButton.setVisibility(View.VISIBLE);
        } else {
            mTryAgainButton.setVisibility(View.GONE);
        }
    }

    public void restoreState(Bundle bundle) {
+21 −1
Original line number Diff line number Diff line
@@ -210,6 +210,22 @@ public class FaceDialogView extends BiometricDialogView {
        bundle.putInt(KEY_DIALOG_SIZE, mSize);
    }


    @Override
    protected void handleClearMessage(boolean requireTryAgain) {
        // Clears the temporary message and shows the help message. If requireTryAgain is true,
        // we will start the authenticating state again.
        if (!requireTryAgain) {
            updateState(STATE_AUTHENTICATING);
            mErrorText.setText(getHintStringResourceId());
            mErrorText.setTextColor(mTextColor);
            mErrorText.setVisibility(View.VISIBLE);
        } else {
            updateState(STATE_IDLE);
            mErrorText.setVisibility(View.INVISIBLE);
        }
    }

    @Override
    public void restoreState(Bundle bundle) {
        super.restoreState(bundle);
@@ -271,7 +287,11 @@ public class FaceDialogView extends BiometricDialogView {
            // of the elements in here.
            updateSize(SIZE_BIG);
        } else {
            super.showTryAgainButton(show);
            if (show) {
                mTryAgainButton.setVisibility(View.VISIBLE);
            } else {
                mTryAgainButton.setVisibility(View.GONE);
            }
        }
    }

+8 −0
Original line number Diff line number Diff line
@@ -32,6 +32,14 @@ public class FingerprintDialogView extends BiometricDialogView {
            DialogViewCallback callback) {
        super(context, callback);
    }

    @Override
    protected void handleClearMessage(boolean requireTryAgain) {
        updateState(STATE_AUTHENTICATING);
        mErrorText.setText(getHintStringResourceId());
        mErrorText.setTextColor(mTextColor);
    }

    @Override
    protected int getHintStringResourceId() {
        return R.string.fingerprint_dialog_touch_sensor;
+10 −5
Original line number Diff line number Diff line
@@ -351,10 +351,7 @@ public class BiometricService extends SystemService {
                    if (!runningTasks.isEmpty()) {
                        final String topPackage = runningTasks.get(0).topActivity.getPackageName();
                        if (mCurrentAuthSession != null
                                && !topPackage.contentEquals(mCurrentAuthSession.mOpPackageName)
                                && mCurrentAuthSession.mState != STATE_AUTH_STARTED) {
                            // We only care about this state, since <Biometric>Service will
                            // cancel any client that's still in STATE_AUTH_STARTED
                                && !topPackage.contentEquals(mCurrentAuthSession.mOpPackageName)) {
                            mStatusBarService.hideBiometricDialog();
                            mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
                            mCurrentAuthSession.mClientReceiver.onError(
@@ -464,8 +461,9 @@ public class BiometricService extends SystemService {
                    if (mCurrentAuthSession != null && mCurrentAuthSession.containsCookie(cookie)) {
                        if (mCurrentAuthSession.mState == STATE_AUTH_STARTED) {
                            mStatusBarService.onBiometricError(message);
                            mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
                            if (error == BiometricConstants.BIOMETRIC_ERROR_CANCELED) {
                                    mActivityTaskManager.unregisterTaskStackListener(
                                            mTaskStackListener);
                                    mCurrentAuthSession.mClientReceiver.onError(error, message);
                                    mCurrentAuthSession.mState = STATE_AUTH_IDLE;
                                    mCurrentAuthSession = null;
@@ -475,6 +473,8 @@ public class BiometricService extends SystemService {
                                mHandler.postDelayed(() -> {
                                    try {
                                        if (mCurrentAuthSession != null) {
                                            mActivityTaskManager.unregisterTaskStackListener(
                                                    mTaskStackListener);
                                            mCurrentAuthSession.mClientReceiver.onError(error,
                                                    message);
                                            mCurrentAuthSession.mState = STATE_AUTH_IDLE;
@@ -543,6 +543,11 @@ public class BiometricService extends SystemService {

            @Override
            public void onDialogDismissed(int reason) throws RemoteException {
                if (mCurrentAuthSession == null) {
                    Slog.e(TAG, "onDialogDismissed: " + reason + ", auth session null");
                    return;
                }

                if (reason != BiometricPrompt.DISMISSED_REASON_POSITIVE) {
                    // Positive button is used by passive modalities as a "confirm" button,
                    // do not send to client