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

Commit 77cc20ee authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Face auth messaging cleanup" into qt-r1-dev

parents 2dc5961c 51996bbc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -310,7 +310,9 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout

    @Override
    public void showMessage(CharSequence message, ColorStateList colorState) {
        if (colorState != null) {
            mSecurityMessageDisplay.setNextMessageColor(colorState);
        }
        mSecurityMessageDisplay.setMessage(message);
    }

+3 −1
Original line number Diff line number Diff line
@@ -438,7 +438,9 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit

    @Override
    public void showMessage(CharSequence message, ColorStateList colorState) {
        if (colorState != null) {
            mSecurityMessageDisplay.setNextMessageColor(colorState);
        }
        mSecurityMessageDisplay.setMessage(message);
    }

+3 −1
Original line number Diff line number Diff line
@@ -229,8 +229,10 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
        }
        if (action == MotionEvent.ACTION_UP) {
            if (-getTranslationY() > TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                    MIN_DRAG_SIZE, getResources().getDisplayMetrics())) {
                    MIN_DRAG_SIZE, getResources().getDisplayMetrics())
                    && !mUpdateMonitor.isFaceDetectionRunning()) {
                mUpdateMonitor.requestFaceAuth();
                showMessage(null, null);
            }
        }
        return true;
+12 −2
Original line number Diff line number Diff line
@@ -168,6 +168,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
     */
    private static final int BIOMETRIC_STATE_CANCELLING_RESTARTING = 3;

    private static final int BIOMETRIC_HELP_FINGERPRINT_NOT_RECOGNIZED = -1;
    public static final int BIOMETRIC_HELP_FACE_NOT_RECOGNIZED = -2;

    private static final int DEFAULT_CHARGING_VOLTAGE_MICRO_VOLT = 5000000;

    private static final ComponentName FALLBACK_HOME_COMPONENT = new ComponentName(
@@ -570,7 +573,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                cb.onBiometricAuthFailed(BiometricSourceType.FINGERPRINT);
            }
        }
        handleFingerprintHelp(-1, mContext.getString(R.string.kg_fingerprint_not_recognized));
        handleFingerprintHelp(BIOMETRIC_HELP_FINGERPRINT_NOT_RECOGNIZED,
                mContext.getString(R.string.kg_fingerprint_not_recognized));
    }

    private void handleFingerprintAcquired(int acquireInfo) {
@@ -722,7 +726,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                cb.onBiometricAuthFailed(BiometricSourceType.FACE);
            }
        }
        handleFaceHelp(-1, mContext.getString(R.string.kg_face_not_recognized));
        handleFaceHelp(BIOMETRIC_HELP_FACE_NOT_RECOGNIZED,
                mContext.getString(R.string.kg_face_not_recognized));
    }

    private void handleFaceAcquired(int acquireInfo) {
@@ -803,6 +808,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                    getCurrentUser());
        }

        // The face timeout message is not very actionable, let's ask the user to
        // manually retry.
        if (msgId == FaceManager.FACE_ERROR_TIMEOUT) {
            errString = mContext.getString(R.string.keyguard_unlock);
        }
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
+27 −1
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public class KeyguardIndicationController implements StateListener,

    private static final int MSG_HIDE_TRANSIENT = 1;
    private static final int MSG_CLEAR_BIOMETRIC_MSG = 2;
    private static final int MSG_SWIPE_UP_TO_UNLOCK = 3;
    private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300;

    private final Context mContext;
@@ -318,6 +319,7 @@ public class KeyguardIndicationController implements StateListener,
        mTransientIndication = transientIndication;
        mTransientTextColorState = textColorState;
        mHandler.removeMessages(MSG_HIDE_TRANSIENT);
        mHandler.removeMessages(MSG_SWIPE_UP_TO_UNLOCK);
        if (mDozing && !TextUtils.isEmpty(mTransientIndication)) {
            // Make sure this doesn't get stuck and burns in. Acquire wakelock until its cleared.
            mWakeLock.setAcquired(true);
@@ -536,10 +538,26 @@ public class KeyguardIndicationController implements StateListener,
                hideTransientIndication();
            } else if (msg.what == MSG_CLEAR_BIOMETRIC_MSG) {
                mLockIcon.setTransientBiometricsError(false);
            } else if (msg.what == MSG_SWIPE_UP_TO_UNLOCK) {
                showSwipeUpToUnlock();
            }
        }
    };

    private void showSwipeUpToUnlock() {
        if (mDozing) {
            return;
        }

        String message = mContext.getString(R.string.keyguard_unlock);
        if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
            mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState);
        } else if (mKeyguardUpdateMonitor.isScreenOn()) {
            showTransientIndication(message);
            hideTransientIndicationDelayed(BaseKeyguardCallback.HIDE_DELAY_MS);
        }
    }

    public void setDozing(boolean dozing) {
        if (mDozing == dozing) {
            return;
@@ -620,14 +638,22 @@ public class KeyguardIndicationController implements StateListener,
                return;
            }
            animatePadlockError();
            boolean showSwipeToUnlock =
                    msgId == KeyguardUpdateMonitor.BIOMETRIC_HELP_FACE_NOT_RECOGNIZED;
            if (mStatusBarKeyguardViewManager.isBouncerShowing()) {
                mStatusBarKeyguardViewManager.showBouncerMessage(helpString,
                        mInitialTextColorState);
            } else if (updateMonitor.isScreenOn()) {
                showTransientIndication(helpString);
                if (!showSwipeToUnlock) {
                    hideTransientIndicationDelayed(TRANSIENT_BIOMETRIC_ERROR_TIMEOUT);
                }
            }
            if (showSwipeToUnlock) {
                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SWIPE_UP_TO_UNLOCK),
                        TRANSIENT_BIOMETRIC_ERROR_TIMEOUT);
            }
        }

        @Override
        public void onBiometricError(int msgId, String errString,