Merge "Changes for storing the PIN length"

This commit is contained in:
Bhavuk Jain
2023-01-30 03:57:39 +00:00
committed by Android (Google) Code Review
3 changed files with 35 additions and 0 deletions

View File

@@ -1,7 +1,10 @@
package com.android.internal.widget;
import static android.provider.DeviceConfig.NAMESPACE_AUTO_PIN_CONFIRMATION;
import android.annotation.NonNull;
import android.os.AsyncTask;
import android.provider.DeviceConfig;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;
@@ -117,6 +120,10 @@ public final class LockPatternChecker {
@Override
protected void onPostExecute(Boolean result) {
callback.onChecked(result, mThrottleTimeout);
if (DeviceConfig.getBoolean(NAMESPACE_AUTO_PIN_CONFIRMATION,
"enable_auto_pin_confirmation", false)) {
utils.setPinLength(userId, credentialCopy.size());
}
credentialCopy.zeroize();
}

View File

@@ -151,6 +151,8 @@ public class LockPatternUtils {
@Deprecated
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";
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);
}
/**
* 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
* currently cleared.

View File

@@ -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.pm.PackageManager.PERMISSION_GRANTED;
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_PASSWORD;
@@ -1689,6 +1690,13 @@ public class LockSettingsService extends ILockSettings.Stub {
if (newCredential.isPattern()) {
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);
mContext.getSystemService(TrustManager.class).reportEnabledTrustAgentsChanged(userHandle);
}