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

博客主要讲述了Android开发中的文件修改操作。需修改frameworks/base/packages/Keyguard下的两个Java文件,以及packages/apps/Settings下的一个Java文件。若未修改最后一个文件,会导致开机后无限重启。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先修改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);
            }
        }

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值