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

Commit 7fcef9e6 authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Move face auth timeout error handling into a separate method." into tm-qpr-dev

parents 86ab34d0 cf5cc604
Loading
Loading
Loading
Loading
+40 −39
Original line number Diff line number Diff line
@@ -51,7 +51,6 @@ import android.content.pm.UserInfo;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.hardware.biometrics.BiometricFaceConstants;
import android.hardware.biometrics.BiometricSourceType;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
@@ -1064,9 +1063,7 @@ public class KeyguardIndicationController {
                    && msgId != BIOMETRIC_HELP_FACE_NOT_RECOGNIZED;
            final boolean faceAuthFailed = biometricSourceType == FACE
                    && msgId == BIOMETRIC_HELP_FACE_NOT_RECOGNIZED; // ran through matcher & failed
            final boolean isUnlockWithFingerprintPossible =
                    mKeyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(
                            getCurrentUser());
            final boolean isUnlockWithFingerprintPossible = canUnlockWithFingerprint();
            final boolean isCoExFaceAcquisitionMessage =
                    faceAuthSoftError && isUnlockWithFingerprintPossible;
            if (isCoExFaceAcquisitionMessage && !mCoExFaceAcquisitionMsgIdsToShow.contains(msgId)) {
@@ -1119,44 +1116,14 @@ public class KeyguardIndicationController {
        }

        private void onFaceAuthError(int msgId, String errString) {
            CharSequence deferredFaceMessage = null;
            if (msgId == BiometricFaceConstants.FACE_ERROR_TIMEOUT) {
                deferredFaceMessage = mFaceAcquiredMessageDeferral.getDeferredMessage();
                debugLog("showDeferredFaceMessage msgId=" + deferredFaceMessage);
            }
            CharSequence deferredFaceMessage = mFaceAcquiredMessageDeferral.getDeferredMessage();
            mFaceAcquiredMessageDeferral.reset();
            if (shouldSuppressFaceError(msgId, mKeyguardUpdateMonitor)) {
                debugLog("suppressingFaceError msgId=" + msgId + " errString= " + errString);
            } else if (msgId == FaceManager.FACE_ERROR_TIMEOUT) {
                // Co-ex: show deferred message OR nothing
                if (mKeyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(
                        KeyguardUpdateMonitor.getCurrentUser())) {
                    // if we're on the lock screen (bouncer isn't showing), show the deferred msg
                    if (deferredFaceMessage != null
                            && !mStatusBarKeyguardViewManager.isBouncerShowing()) {
                        showBiometricMessage(
                                deferredFaceMessage,
                                mContext.getString(R.string.keyguard_suggest_fingerprint)
                        );
                return;
            }

                    // otherwise, don't show any message
                    debugLog("skip showing FACE_ERROR_TIMEOUT due to co-ex logic");
                    return;
                }

                // Face-only: The face timeout message is not very actionable, let's ask the user to
                // manually retry.
                if (deferredFaceMessage != null) {
                    showBiometricMessage(
                            deferredFaceMessage,
                            mContext.getString(R.string.keyguard_unlock)
                    );
                } else {
                    // suggest swiping up to unlock (try face auth again or swipe up to bouncer)
                    showActionToUnlock();
                }
            if (msgId == FaceManager.FACE_ERROR_TIMEOUT) {
                handleFaceAuthTimeoutError(deferredFaceMessage);
            } else {
                handleGenericBiometricError(errString);
            }
@@ -1267,6 +1234,40 @@ public class KeyguardIndicationController {
        }
    }

    private void handleFaceAuthTimeoutError(@Nullable CharSequence deferredFaceMessage) {
        debugLog("showDeferredFaceMessage msgId=" + deferredFaceMessage);
        if (canUnlockWithFingerprint()) {
            // Co-ex: show deferred message OR nothing
            // if we're on the lock screen (bouncer isn't showing), show the deferred msg
            if (deferredFaceMessage != null
                    && !mStatusBarKeyguardViewManager.isBouncerShowing()) {
                showBiometricMessage(
                        deferredFaceMessage,
                        mContext.getString(R.string.keyguard_suggest_fingerprint)
                );
            } else {
                // otherwise, don't show any message
                debugLog("skip showing FACE_ERROR_TIMEOUT due to co-ex logic");
            }
        } else if (deferredFaceMessage != null) {
            // Face-only: The face timeout message is not very actionable, let's ask the
            // user to manually retry.
            showBiometricMessage(
                    deferredFaceMessage,
                    mContext.getString(R.string.keyguard_unlock)
            );
        } else {
            // Face-only
            // suggest swiping up to unlock (try face auth again or swipe up to bouncer)
            showActionToUnlock();
        }
    }

    private boolean canUnlockWithFingerprint() {
        return mKeyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(
                KeyguardUpdateMonitor.getCurrentUser());
    }

    private void debugLog(String logMsg) {
        if (DEBUG) {
            Log.d(TAG, logMsg);