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

Commit b5746cb1 authored by Andres Morales's avatar Andres Morales Committed by Android (Google) Code Review
Browse files

Merge "[LockSettings] pipe through HW throttle timeout" into mnc-dev

parents 6fd26aae 91e6c499
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.text.Selection;
import android.text.Spannable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -61,6 +62,8 @@ public class ChooseLockPassword extends SettingsActivity {
    public static final String PASSWORD_MIN_SYMBOLS_KEY = "lockscreen.password_min_symbols";
    public static final String PASSWORD_MIN_NONLETTER_KEY = "lockscreen.password_min_nonletter";

    private static final String TAG = "ChooseLockPassword";

    @Override
    public Intent getIntent() {
        Intent modIntent = new Intent(super.getIntent());
@@ -533,7 +536,11 @@ public class ChooseLockPassword extends SettingsActivity {
                    UserHandle.myUserId(),
                    new LockPatternChecker.OnVerifyCallback() {
                        @Override
                        public void onVerified(byte[] token) {
                        public void onVerified(byte[] token, int timeoutMs) {
                            if (token == null) {
                                Log.e(TAG, "critical: no token returned from known good password");
                            }

                            mPasswordEntryInputDisabler.setInputEnabled(true);
                            setNextEnabled(true);
                            mPendingLockCheck = null;
+8 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.UserHandle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -64,6 +65,8 @@ public class ChooseLockPattern extends SettingsActivity {
     */
    static final int RESULT_FINISHED = RESULT_FIRST_USER;

    private static final String TAG = "ChooseLockPattern";

    @Override
    public Intent getIntent() {
        Intent modIntent = new Intent(super.getIntent());
@@ -663,7 +666,11 @@ public class ChooseLockPattern extends SettingsActivity {
                    UserHandle.myUserId(),
                    new LockPatternChecker.OnVerifyCallback() {
                        @Override
                        public void onVerified(byte[] token) {
                        public void onVerified(byte[] token, int timeoutMs) {
                            if (token == null) {
                                Log.e(TAG, "critical: no token returned for known good pattern");
                            }

                            mLockPatternView.enableInput();
                            mPendingLockCheck = null;

+8 −8
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
                return;
            }

            onPasswordChecked(false, intent);
            onPasswordChecked(false, intent, 0);
        }

        private boolean isInternalActivity() {
@@ -277,7 +277,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
                    UserHandle.myUserId(),
                    new LockPatternChecker.OnVerifyCallback() {
                        @Override
                        public void onVerified(byte[] token) {
                        public void onVerified(byte[] token, int timeoutMs) {
                            mPendingLockCheck = null;
                            boolean matched = false;
                            if (token != null) {
@@ -286,7 +286,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
                                        ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
                                        token);
                            }
                            onPasswordChecked(matched, intent);
                            onPasswordChecked(matched, intent, timeoutMs);
                        }
                    });
        }
@@ -298,7 +298,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
                    UserHandle.myUserId(),
                    new LockPatternChecker.OnCheckCallback() {
                        @Override
                        public void onChecked(boolean matched) {
                        public void onChecked(boolean matched, int timeoutMs) {
                            mPendingLockCheck = null;
                            if (matched && isInternalActivity()) {
                                intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
@@ -307,20 +307,20 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
                                intent.putExtra(
                                        ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pin);
                            }
                            onPasswordChecked(matched, intent);
                            onPasswordChecked(matched, intent, timeoutMs);
                        }
                    });
        }

        private void onPasswordChecked(boolean matched, Intent intent) {
        private void onPasswordChecked(boolean matched, Intent intent, int timeoutMs) {
            mPasswordEntryInputDisabler.setInputEnabled(true);
            if (matched) {
                getActivity().setResult(RESULT_OK, intent);
                getActivity().finish();
            } else {
                if (++mNumWrongConfirmAttempts >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
                if (timeoutMs > 0) {
                    long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
                            UserHandle.myUserId());
                            UserHandle.myUserId(), timeoutMs);
                    handleAttemptLockout(deadline);
                } else {
                    showError(getErrorMessage());
+13 −11
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
                    return;
                }

                onPatternChecked(pattern, false, intent);
                onPatternChecked(pattern, false, intent, 0);
            }

            private boolean isInternalActivity() {
@@ -313,7 +313,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
                        UserHandle.myUserId(),
                        new LockPatternChecker.OnVerifyCallback() {
                            @Override
                            public void onVerified(byte[] token) {
                            public void onVerified(byte[] token, int timeoutMs) {
                                mPendingLockCheck = null;
                                boolean matched = false;
                                if (token != null) {
@@ -322,20 +322,25 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
                                            ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN,
                                            token);
                                }
                                onPatternChecked(pattern, matched, intent);
                                onPatternChecked(pattern, matched, intent, timeoutMs);
                            }
                        });
            }

            private void startCheckPattern(final List<LockPatternView.Cell> pattern,
                    final Intent intent) {
                if (pattern.size() <= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL) {
                    onPatternChecked(pattern, false, intent, 0);
                    return;
                }

                mPendingLockCheck = LockPatternChecker.checkPattern(
                        mLockPatternUtils,
                        pattern,
                        UserHandle.myUserId(),
                        new LockPatternChecker.OnCheckCallback() {
                            @Override
                            public void onChecked(boolean matched) {
                            public void onChecked(boolean matched, int timeoutMs) {
                                mPendingLockCheck = null;
                                if (matched && isInternalActivity()) {
                                    intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
@@ -343,24 +348,21 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
                                    intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
                                                    LockPatternUtils.patternToString(pattern));
                                }
                                onPatternChecked(pattern, matched, intent);
                                onPatternChecked(pattern, matched, intent, timeoutMs);
                            }
                        });
            }

            private void onPatternChecked(List<LockPatternView.Cell> pattern,
                    boolean matched,
                    Intent intent) {
                    boolean matched, Intent intent, int timeoutMs) {
                mLockPatternView.setEnabled(true);
                if (matched) {
                    getActivity().setResult(Activity.RESULT_OK, intent);
                    getActivity().finish();
                } else {
                    if (pattern.size() >= LockPatternUtils.MIN_PATTERN_REGISTER_FAIL &&
                            ++mNumWrongConfirmAttempts
                            >= LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT) {
                    if (timeoutMs > 0) {
                        long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
                                UserHandle.myUserId());
                                UserHandle.myUserId(), timeoutMs);
                        handleAttemptLockout(deadline);
                    } else {
                        updateStage(Stage.NeedToUnlockWrong);