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

Commit 832d40e0 authored by Pavel Grafov's avatar Pavel Grafov Committed by android-build-merger
Browse files

Merge "Use DPM's counter for invalid password attempts" into pi-dev

am: 375e397b

Change-Id: I675d053d3250ad91adb3999ba10bba7110190ac2
parents e206929d 375e397b
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.keyguard;

import android.R.style;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager;
@@ -26,7 +25,6 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.Slog;
import android.util.StatsLog;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
@@ -210,7 +208,7 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe

        if (messageId != 0) {
            final String message = mContext.getString(messageId,
                    KeyguardUpdateMonitor.getInstance(mContext).getFailedUnlockAttempts(userId),
                    mLockPatternUtils.getCurrentFailedPasswordAttempts(userId),
                    timeoutInSeconds);
            showDialog(null, message);
        }
@@ -255,8 +253,8 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
    }

    private void reportFailedUnlockAttempt(int userId, int timeoutMs) {
        final KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
        final int failedAttempts = monitor.getFailedUnlockAttempts(userId) + 1; // +1 for this time
        // +1 for this time
        final int failedAttempts = mLockPatternUtils.getCurrentFailedPasswordAttempts(userId) + 1;

        if (DEBUG) Log.d(TAG, "reportFailedPatternAttempt: #" + failedAttempts);

@@ -290,7 +288,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
                showWipeDialog(failedAttempts, userType);
            }
        }
        monitor.reportFailedStrongAuthUnlockAttempt(userId);
        mLockPatternUtils.reportFailedPasswordAttempt(userId);
        if (timeoutMs > 0) {
            mLockPatternUtils.reportPasswordLockout(timeoutMs, userId);
@@ -434,7 +431,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe
            if (success) {
                StatsLog.write(StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
                    StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED__RESULT__SUCCESS);
                monitor.clearFailedUnlockAttempts();
                mLockPatternUtils.reportSuccessfulPasswordAttempt(userId);
            } else {
                StatsLog.write(StatsLog.KEYGUARD_BOUNCER_PASSWORD_ENTERED,
+0 −15
Original line number Diff line number Diff line
@@ -209,9 +209,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    // Battery status
    private BatteryStatus mBatteryStatus;

    // Password attempts
    private SparseIntArray mFailedAttempts = new SparseIntArray();

    private final StrongAuthTracker mStrongAuthTracker;

    private final ArrayList<WeakReference<KeyguardUpdateMonitorCallback>>
@@ -1800,22 +1797,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        return mDeviceProvisioned;
    }

    public void clearFailedUnlockAttempts() {
        mFailedAttempts.delete(sCurrentUser);
    }

    public ServiceState getServiceState(int subId) {
        return mServiceStates.get(subId);
    }

    public int getFailedUnlockAttempts(int userId) {
        return mFailedAttempts.get(userId, 0);
    }

    public void reportFailedStrongAuthUnlockAttempt(int userId) {
        mFailedAttempts.put(userId, getFailedUnlockAttempts(userId) + 1);
    }

    public void clearFingerprintRecognized() {
        mUserFingerprintAuthenticated.clear();
        mTrustManager.clearAllFingerprints();
+0 −1
Original line number Diff line number Diff line
@@ -1647,7 +1647,6 @@ public class KeyguardViewMediator extends SystemUI {
            resetKeyguardDonePendingLocked();
        }

        mUpdateMonitor.clearFailedUnlockAttempts();
        mUpdateMonitor.clearFingerprintRecognized();

        if (mGoingToSleep) {
+6 −4
Original line number Diff line number Diff line
@@ -4572,11 +4572,13 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        enforceFullCrossUsersPermission(userHandle);
        synchronized (getLockObject()) {
            if (!isCallerWithSystemUid()) {
                // This API can only be called by an active device admin,
                // so try to retrieve it to check that the caller is one.
                // This API can be called by an active device admin or by keyguard code.
                if (mContext.checkCallingPermission(permission.ACCESS_KEYGUARD_SECURE_STORAGE)
                        != PackageManager.PERMISSION_GRANTED) {
                    getActiveAdminForCallerLocked(
                            null, DeviceAdminInfo.USES_POLICY_WATCH_LOGIN, parent);
                }
            }
            DevicePolicyData policy = getUserDataUnchecked(getCredentialOwner(userHandle, parent));