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

Commit 13cb572a authored by Fang Yunong's avatar Fang Yunong Committed by Linux Build Service Account
Browse files

Support password input style of times countdown

When password is wrong more than the customized times,
keyguard could show the dialog to suggest to wipe the data.

By default the count is customized to 0, which will disable
this feature. Customize the config_max_unlock_countdown_times
to enable this feature in the operator data package overlay.

Change-Id: I9ba7cd46cb63d447a357783f68854c72cab04c38
CRs-Fixed: 1037633
parent d5a09cc7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -104,6 +104,12 @@
      <item quantity="other">SIM 卡 PUK 码不正确,您还可尝试 <xliff:g id="NUMBER_1">%d</xliff:g> 次。如果仍不正确,SIM 卡将永远无法使用。</item>
      <item quantity="one">SIM 卡 PUK 码不正确,您还可尝试 <xliff:g id="NUMBER_0">%d</xliff:g> 次。如果仍不正确,SIM 卡将永远无法使用。</item>
    </plurals>
    <string name="kg_remaining_attempts">剩余次数: <xliff:g id="number">%d</xliff:g></string>
    <string name="kg_failed_pin_attempts_now_wiping">您输入了<xliff:g id="number">%d</xliff:g>次错误的PIN, 是否重启并恢复出厂设置?</string>
    <string name="kg_failed_password_attempts_now_wiping">您输入了<xliff:g id="number">%d</xliff:g>次错误的密码, 是否重启并恢复出厂设置?</string>
    <string name="kg_failed_pattern_attempts_now_wiping">您输入了<xliff:g id="number">%d</xliff:g>次错误图案, 是否重启并恢复出厂设置?</string>
    <string name="kg_failed_attempts_now_wiping_confirm">将要清除您设备上的全部用户数据并且设备恢复成出厂设置。</string>

    <string name="kg_password_pin_failed" msgid="6268288093558031564">"SIM卡PIN码操作失败!"</string>
    <string name="kg_password_puk_failed" msgid="2838824369502455984">"SIM卡PUK码操作失败!"</string>
    <string name="kg_pin_accepted" msgid="1448241673570020097">"代码正确!"</string>
+3 −0
Original line number Diff line number Diff line
@@ -28,4 +28,7 @@

    <!-- Threshold in micro watts above which a charger is rated as "fast"; 1.5A @ 5V  -->
    <integer name="config_chargingFastThreshold">7500000</integer>

    <!-- Guide user to wipe data after fail to unlock for the max times -->
    <integer name="config_max_unlock_countdown_times">0</integer>
</resources>
+17 −0
Original line number Diff line number Diff line
@@ -304,6 +304,23 @@
        This is displayed if the phone is not connected to a carrier.-->
    <string name="keyguard_carrier_default">No service.</string>

    <string name="kg_remaining_attempts">Remaining attempts: <xliff:g id="number">%d</xliff:g></string>
    <string name="kg_failed_pin_attempts_now_wiping">
        You entered the wrong PIN <xliff:g id="number">%d</xliff:g> times,
        do you want to reset your phone to factory settings?
    </string>
    <string name="kg_failed_password_attempts_now_wiping">
        You entered the wrong Password <xliff:g id="number">%d</xliff:g> times,
        do you want to reset your phone to factory settings?
    </string>
    <string name="kg_failed_pattern_attempts_now_wiping">
        You entered the wrong Pattern <xliff:g id="number">%d</xliff:g> times,
        do you want to reset your phone to factory settings?
    </string>
    <string name="kg_failed_attempts_now_wiping_confirm">
        This will erase all data from your device\'s internal storage and your device will be back to factory settings.
    </string>

    <!-- Content description of the switch input method button for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
    <string name="accessibility_ime_switch_button" msgid="5032926134740456424">Switch input method</string>

+20 −3
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
    protected View mEcaView;
    protected boolean mEnableHaptics;
    private boolean mDismissing;
    private int mMaxCountdownTimes = 0;

    // To avoid accidental lockout due to events while the device in in the pocket, ignore
    // any passwords with length less than or equal to this length.
@@ -94,6 +95,9 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
        mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this);
        mEcaView = findViewById(R.id.keyguard_selector_fade_container);

        mMaxCountdownTimes = mContext.getResources()
                .getInteger(R.integer.config_max_unlock_countdown_times);

        EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button);
        if (button != null) {
            button.setCallback(this);
@@ -160,14 +164,15 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
        } else {
            if (isValidPassword) {
                mCallback.reportUnlockAttempt(userId, false, timeoutMs);
                if (timeoutMs > 0) {
                if  (!(mMaxCountdownTimes > 0) && timeoutMs > 0) {
                    long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
                            userId, timeoutMs);
                    handleAttemptLockout(deadline);
                }
            }
            if (timeoutMs == 0) {
                mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
                String msg = getMessageWithCount(getWrongPasswordStringId());
                mSecurityMessageDisplay.setMessage(msg, true);
            }
        }
        resetPasswordText(true /* animate */, !matched /* announce deletion if no match */);
@@ -199,6 +204,18 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
        }.start();
    }

    protected String getMessageWithCount(int msgId) {
        String msg = getContext().getString(msgId);
        int remaining = mMaxCountdownTimes
            - KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts(
            KeyguardUpdateMonitor.getCurrentUser());
        if (mMaxCountdownTimes > 0 && remaining > 0) {
            msg += " - " + getContext().getResources().getString(
                    R.string.kg_remaining_attempts, remaining);
        }
        return msg;
    }

    protected void onUserInput() {
        if (mCallback != null) {
            mCallback.userActivity();
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
    @Override
    protected void resetState() {
        super.resetState();
        mSecurityMessageDisplay.setMessage(R.string.kg_pin_instructions, false);
        mSecurityMessageDisplay.setMessage(getMessageWithCount(R.string.kg_pin_instructions), false);
    }

    @Override
Loading