修改pin码输入错误超时时间

首先修改frameworks/base/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java 

 private void onPasswordChecked(int userId, boolean matched, int timeoutMs,
            boolean isValidPassword) {
        boolean dismissKeyguard = KeyguardUpdateMonitor.getCurrentUser() == userId;
        if (matched) {
            mLockPatternUtils.sanitizePassword();
            mCallback.reportUnlockAttempt(userId, true, 0);
            if (dismissKeyguard) {
                mDismissing = true;
                mCallback.dismiss(true);
            }
        } else {
            if (isValidPassword) {
                mCallback.reportUnlockAttempt(userId, false, timeoutMs);
                if  (!(mMaxCountdownTimes > 0) && timeoutMs > 0) {
                    long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
                            userId, 1200000);   //在这里修改时间,我修改为20分钟
                    handleAttemptLockout(deadline);
                }
            }
            if (timeoutMs == 0) {
                String msg = getMessageWithCount(getWrongPasswordStringId());
                mSecurityMessageDisplay.setMessage(msg, true);
            }
        }
        resetPasswordText(true /* animate */, !matched /* announce deletion if no match */);
    }

 然后修改frameworks/base/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java

  private void showTimeoutDialog(int timeoutMs) {
        int timeoutInSeconds = (int) timeoutMs / 1000;
        int messageId = 0;

        switch (mSecurityModel.getSecurityMode()) {
            case Pattern:
                messageId = R.string.kg_too_many_failed_pattern_attempts_dialog_message;
                break;
            case PIN:
                messageId = R.string.kg_too_many_failed_pin_attempts_dialog_message;
                break;
            case Password:
                messageId = R.string.kg_too_many_failed_password_attempts_dialog_message;
                break;
            // These don't have timeout dialogs.
            case Invalid:
            case None:
            case SimPin:
            case SimPuk:
                break;
        }

        if (messageId != 0) {
            final String message = mContext.getString(messageId,
                    KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts(
                            KeyguardUpdateMonitor.getCurrentUser()),
                    1200); //在这里修改超时提示时间为1200s
            showDialog(null, message);
        }
    }

最后还要修改一个地方packages/apps/Settings/src/com/android/settings/EncryptionInterstitial.java,之前没有修改这个文件,导致开机后无限重启,

       @Override
        public boolean onPreferenceTreeClick(Preference preference) {
            final String key = preference.getKey();
            if (key.equals(KEY_ENCRYPT_REQUIRE_PASSWORD) && false) {  //为了保证能够正常开机所以直接设置了false
                final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
                if (accEn && !mPasswordRequired) {
                    setRequirePasswordState(false); //在这里设置require password state 为false,其实就是开机后为了clear the UI state
                    showDialog(ACCESSIBILITY_WARNING_DIALOG);
                } else {
                    setRequirePasswordState(true);
                    startLockIntent();
                }
            } else {
                setRequirePasswordState(false);
                startLockIntent();
            }
            return true;
        }



        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                setRequirePasswordState(false);  //在这里同样设置一下false
                startLockIntent();

            } else if (which == DialogInterface.BUTTON_NEGATIVE) {
                setRequirePasswordState(false);
            }
        }

猜你喜欢

转载自blog.csdn.net/lancelots/article/details/82183169
今日推荐