[Auto Pin Confirm]: Trigger PIN verification when auto confirm setting is being turned on or off
- Fix the logic to set the pin_auto_confirm setting before triggering the password save workflow in ChooseLockPassword Bug: 275385372 Test: atest AutoPinConfirmPreferenceControllerTest Test: Manual Test Change-Id: Id6774bc9afcd6d3161e023dc52911ae3e1f556c9
This commit is contained in:
@@ -911,6 +911,10 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
mIsManagedProfile));
|
||||
setNextEnabled(canInput && length >= LockPatternUtils.MIN_LOCK_PASSWORD_SIZE);
|
||||
mSkipOrClearButton.setVisibility(toVisibility(canInput && length > 0));
|
||||
|
||||
// Hide the pin_confirm option when we are just asking user to confirm the pwd.
|
||||
mAutoPinConfirmOption.setVisibility(View.GONE);
|
||||
mAutoConfirmSecurityMessage.setVisibility(View.GONE);
|
||||
}
|
||||
final int stage = getStageType();
|
||||
if (getStageType() != Stage.TYPE_NONE) {
|
||||
@@ -1017,12 +1021,14 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
profileCredential);
|
||||
}
|
||||
}
|
||||
mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
|
||||
mChosenPassword, mCurrentCredential, mUserId);
|
||||
// update the pin_auto_confirm setting accordingly.
|
||||
// update the setting before triggering the password save workflow,
|
||||
// so that pinLength information is stored accordingly when setting is turned on.
|
||||
mLockPatternUtils.setAutoPinConfirm(
|
||||
(mAutoPinConfirmOption != null && mAutoPinConfirmOption.isChecked()),
|
||||
mUserId);
|
||||
|
||||
mSaveAndFinishWorker.start(mLockPatternUtils, mRequestGatekeeperPassword,
|
||||
mChosenPassword, mCurrentCredential, mUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -16,14 +16,19 @@
|
||||
|
||||
package com.android.settings.security.screenlock;
|
||||
|
||||
import static com.android.internal.widget.LockPatternUtils.MIN_AUTO_PIN_REQUIREMENT_LENGTH;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.TwoStatePreference;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.ObservablePreferenceFragment;
|
||||
|
||||
/**
|
||||
* Preference controller for the pin_auto_confirm setting.
|
||||
@@ -32,21 +37,23 @@ public class AutoPinConfirmPreferenceController extends AbstractPreferenceContro
|
||||
PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String PREF_KEY_PIN_AUTO_CONFIRM = "auto_pin_confirm";
|
||||
private static final long MIN_AUTO_PIN_REQUIREMENT_LENGTH = 6L;
|
||||
|
||||
private final int mUserId;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
private final ObservablePreferenceFragment mParentFragment;
|
||||
|
||||
public AutoPinConfirmPreferenceController(Context context, int userId,
|
||||
LockPatternUtils lockPatternUtils) {
|
||||
LockPatternUtils lockPatternUtils,
|
||||
ObservablePreferenceFragment parentFragment) {
|
||||
super(context);
|
||||
mUserId = userId;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
mParentFragment = parentFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
setPinAutoConfirmSettingState((boolean) newValue);
|
||||
launchPinConfirmActivity((boolean) newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -82,4 +89,18 @@ public class AutoPinConfirmPreferenceController extends AbstractPreferenceContro
|
||||
private void setPinAutoConfirmSettingState(boolean state) {
|
||||
mLockPatternUtils.setAutoPinConfirm(state, mUserId);
|
||||
}
|
||||
|
||||
private void launchPinConfirmActivity(boolean newState) {
|
||||
new ChooseLockSettingsHelper.Builder(mParentFragment.getActivity(), mParentFragment)
|
||||
.setUserId(mUserId)
|
||||
.setRequestCode(newState
|
||||
? ScreenLockSettings.AUTO_PIN_SETTING_ENABLING_REQUEST_CODE
|
||||
: ScreenLockSettings.AUTO_PIN_SETTING_DISABLING_REQUEST_CODE)
|
||||
.setTitle(mContext.getString(R.string.lock_screen_auto_pin_confirm_title))
|
||||
.setDescription(newState
|
||||
? mContext.getString(R.string.auto_confirm_on_pin_verify_description)
|
||||
: mContext.getString(R.string.auto_confirm_off_pin_verify_description))
|
||||
.setReturnCredentials(true)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,14 @@
|
||||
|
||||
package com.android.settings.security.screenlock;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -38,6 +42,10 @@ public class ScreenLockSettings extends DashboardFragment
|
||||
private static final String TAG = "ScreenLockSettings";
|
||||
|
||||
private static final int MY_USER_ID = UserHandle.myUserId();
|
||||
|
||||
static final int AUTO_PIN_SETTING_ENABLING_REQUEST_CODE = 111;
|
||||
static final int AUTO_PIN_SETTING_DISABLING_REQUEST_CODE = 112;
|
||||
|
||||
private LockPatternUtils mLockPatternUtils;
|
||||
|
||||
@Override
|
||||
@@ -79,7 +87,7 @@ public class ScreenLockSettings extends DashboardFragment
|
||||
controllers.add(new LockAfterTimeoutPreferenceController(
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
controllers.add(new AutoPinConfirmPreferenceController(
|
||||
context, MY_USER_ID, lockPatternUtils));
|
||||
context, MY_USER_ID, lockPatternUtils, parent));
|
||||
controllers.add(new OwnerInfoPreferenceController(context, parent));
|
||||
return controllers;
|
||||
}
|
||||
@@ -94,4 +102,17 @@ public class ScreenLockSettings extends DashboardFragment
|
||||
new LockPatternUtils(context));
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
if (requestCode == AUTO_PIN_SETTING_ENABLING_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
mLockPatternUtils.setAutoPinConfirm(/* enabled= */ true, MY_USER_ID);
|
||||
}
|
||||
} else if (requestCode == AUTO_PIN_SETTING_DISABLING_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
mLockPatternUtils.setAutoPinConfirm(/* enabled= */ false, MY_USER_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user