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

Commit 77ca448f authored by Bhavuk Jain's avatar Bhavuk Jain Committed by Android (Google) Code Review
Browse files

Merge "Changes for storing the PIN length"

parents b48b6a18 2dfb5509
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
package com.android.internal.widget;
package com.android.internal.widget;


import static android.provider.DeviceConfig.NAMESPACE_AUTO_PIN_CONFIRMATION;

import android.annotation.NonNull;
import android.annotation.NonNull;
import android.os.AsyncTask;
import android.os.AsyncTask;
import android.provider.DeviceConfig;


import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;


@@ -117,6 +120,10 @@ public final class LockPatternChecker {
            @Override
            @Override
            protected void onPostExecute(Boolean result) {
            protected void onPostExecute(Boolean result) {
                callback.onChecked(result, mThrottleTimeout);
                callback.onChecked(result, mThrottleTimeout);
                if (DeviceConfig.getBoolean(NAMESPACE_AUTO_PIN_CONFIRMATION,
                        "enable_auto_pin_confirmation", false)) {
                    utils.setPinLength(userId, credentialCopy.size());
                }
                credentialCopy.zeroize();
                credentialCopy.zeroize();
            }
            }


+20 −0
Original line number Original line Diff line number Diff line
@@ -151,6 +151,8 @@ public class LockPatternUtils {
    @Deprecated
    @Deprecated
    public final static String LOCKSCREEN_WIDGETS_ENABLED = "lockscreen.widgets_enabled";
    public final static String LOCKSCREEN_WIDGETS_ENABLED = "lockscreen.widgets_enabled";


    public static final String PIN_LENGTH = "lockscreen.pin_length";

    public final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory";
    public final static String PASSWORD_HISTORY_KEY = "lockscreen.passwordhistory";


    private static final String LOCK_SCREEN_OWNER_INFO = Settings.Secure.LOCK_SCREEN_OWNER_INFO;
    private static final String LOCK_SCREEN_OWNER_INFO = Settings.Secure.LOCK_SCREEN_OWNER_INFO;
@@ -565,6 +567,24 @@ public class LockPatternUtils {
        return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, userId);
        return getBoolean(PATTERN_EVER_CHOSEN_KEY, false, userId);
    }
    }


    /**
     * Used for setting the length of the PIN set by a particular user.
     * @param userId user id of the user whose pin length we save
     * @param val value of length of pin
     */
    public void setPinLength(int userId, long val) {
        setLong(PIN_LENGTH, val, userId);
    }

    /**
     * Returns the length of the PIN set by a particular user.
     * @param userId user id of the user whose pin length we have to return
     * @return the length of the pin set by user and -1 if nothing
     */
    public long getPinLength(int userId) {
        return getLong(PIN_LENGTH, -1, userId);
    }

    /**
    /**
     * Records that the user has chosen a pattern at some time, even if the pattern is
     * Records that the user has chosen a pattern at some time, even if the pattern is
     * currently cleared.
     * currently cleared.
+8 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.app.admin.DevicePolicyResources.Strings.Core.PROFILE_ENCRY
import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.Context.KEYGUARD_SERVICE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.UserHandle.USER_ALL;
import static android.os.UserHandle.USER_ALL;
import static android.provider.DeviceConfig.NAMESPACE_AUTO_PIN_CONFIRMATION;


import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD;
import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_PASSWORD;
@@ -1689,6 +1690,13 @@ public class LockSettingsService extends ILockSettings.Stub {
        if (newCredential.isPattern()) {
        if (newCredential.isPattern()) {
            setBoolean(LockPatternUtils.PATTERN_EVER_CHOSEN_KEY, true, userHandle);
            setBoolean(LockPatternUtils.PATTERN_EVER_CHOSEN_KEY, true, userHandle);
        }
        }
        if (DeviceConfig.getBoolean(NAMESPACE_AUTO_PIN_CONFIRMATION,
                "enable_auto_pin_confirmation", /* defaultValue= */ false)) {
            if (newCredential.isPin()) {
                setLong(LockPatternUtils.PIN_LENGTH, newCredential.size(), userHandle);
            }
        }

        updatePasswordHistory(newCredential, userHandle);
        updatePasswordHistory(newCredential, userHandle);
        mContext.getSystemService(TrustManager.class).reportEnabledTrustAgentsChanged(userHandle);
        mContext.getSystemService(TrustManager.class).reportEnabledTrustAgentsChanged(userHandle);
    }
    }