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

Commit 496d1046 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Support password input style of 10 times countdown"

parents c43ee0a1 74cd59f8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -160,4 +160,5 @@
    <item quantity="one" msgid="8134313997799638254">"输入 SIM PIN,您还有<xliff:g id="NUMBER">%d</xliff:g>次尝试机会。如果仍然失败,则必须联系运营商帮您解锁设备。"</item>
    <item quantity="other" msgid="2215723361575359486">"输入 SIM PIN,您还有<xliff:g id="NUMBER">%d</xliff:g>次尝试机会。"</item>
  </plurals>
    <string name="kg_remaining_attempts">剩余次数: <xliff:g id="number">%d</xliff:g></string>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

    <!-- Allow the menu hard key to be disabled in LockScreen on some devices [DO NOT TRANSLATE] -->
    <bool name="config_disableMenuKeyInLockScreen">false</bool>
    <integer name="config_max_unlock_countdown_times">0</integer>

    <!-- True if we need to show on "Slide" lock screen -->
    <bool name="config_showEmergencyButton">false</bool>
+2 −0
Original line number Diff line number Diff line
@@ -382,6 +382,8 @@
    <!-- On the keyguard screen, it shows the carrier the phone is connected to.
        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>

    <!-- Dismiss button text in SIM pin/puk unlock view -->
    <string name="kg_dismiss">Dismiss</string>
    <!-- Slot id in SIM pin/puk unlock view -->
+22 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,6 +42,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
    protected View mEcaView;
    private Drawable mBouncerFrame;
    protected boolean mEnableHaptics;
    protected 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.
@@ -112,12 +116,13 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
                // real password. This may require some tweaking.
                mCallback.reportUnlockAttempt(false);
                int attempts = KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
                if (0 == (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
                if (!(mMaxCountdownTimes > 0) && 0 ==
                        (attempts % LockPatternUtils.FAILED_ATTEMPTS_BEFORE_TIMEOUT)) {
                    long deadline = mLockPatternUtils.setLockoutAttemptDeadline();
                    handleAttemptLockout(deadline);
                }
            }
            mSecurityMessageDisplay.setMessage(getWrongPasswordStringId(), true);
            showWrongPassword();
        }
        resetPasswordText(true /* animate */);
    }
@@ -147,6 +152,21 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
        }.start();
    }

    protected void showWrongPassword() {
        String msg = getContext().getString(getWrongPasswordStringId());
        if (mMaxCountdownTimes > 0) {
            int remaining = getRemainingCount();
            msg += " - " + getContext().getResources().getString(
                    R.string.kg_remaining_attempts, remaining);
        }
        mSecurityMessageDisplay.setMessage(msg, true);
    }

    protected int getRemainingCount() {
        return mMaxCountdownTimes
                - KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        mCallback.userActivity();
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
@@ -42,6 +45,8 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {

    public KeyguardPINView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mMaxCountdownTimes = context.getResources()
                .getInteger(R.integer.config_max_unlock_countdown_times);
        mAppearAnimationUtils = new AppearAnimationUtils(context);
        mDisappearYTranslation = getResources().getDimensionPixelSize(
                R.dimen.disappear_y_translation);
@@ -49,8 +54,22 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {

    protected void resetState() {
        super.resetState();
        showDefautMessage();
        mPasswordEntry.setEnabled(true);
    }

    private String getMessge(int mMaxCountdownTimes) {
        String msg = getContext().getString(R.string.kg_pin_instructions);
        msg += " - " + getContext().getResources().getString(
                R.string.kg_remaining_attempts, getRemainingCount());
        return msg;
    }

    private void showDefautMessage() {
        if (KeyguardUpdateMonitor.getInstance(mContext).getMaxBiometricUnlockAttemptsReached()) {
            mSecurityMessageDisplay.setMessage(R.string.faceunlock_multiple_failures, true);
        } else if (mMaxCountdownTimes > 0) {
            mSecurityMessageDisplay.setMessage(getMessge(mMaxCountdownTimes), true);
        } else {
            mSecurityMessageDisplay.setMessage(R.string.kg_pin_instructions, false);
        }
Loading