Loading src/com/android/settings/ChooseLockGeneric.java +28 −24 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import com.android.internal.widget.LockPatternUtils; public class ChooseLockGeneric extends SettingsActivity { public static final String CONFIRM_CREDENTIALS = "confirm_credentials"; public static final String KEY_USER_ID = "user_id"; @Override public Intent getIntent() { Loading Loading @@ -103,6 +104,7 @@ public class ChooseLockGeneric extends SettingsActivity { private String mUserPassword; private LockPatternUtils mLockPatternUtils; private FingerprintManager mFingerprintManager; private int mUserId; private RemovalCallback mRemovalCallback = new RemovalCallback() { @Override Loading Loading @@ -161,13 +163,16 @@ public class ChooseLockGeneric extends SettingsActivity { ENCRYPT_REQUESTED_DISABLED); } // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getSameOwnerUserId(getContext(), getArguments()); if (mPasswordConfirmed) { updatePreferencesOrFinish(); } else if (!mWaitingForConfirmation) { ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this.getActivity(), this); if (!helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), true)) { getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId)) { mPasswordConfirmed = true; // no password set, so no need to confirm updatePreferencesOrFinish(); } else { Loading @@ -188,7 +193,7 @@ public class ChooseLockGeneric extends SettingsActivity { public boolean onPreferenceTreeClick(Preference preference) { final String key = preference.getKey(); if (!isUnlockMethodSecure(key) && mLockPatternUtils.isSecure(UserHandle.myUserId())) { if (!isUnlockMethodSecure(key) && mLockPatternUtils.isSecure(mUserId)) { // Show the disabling FRP warning only when the user is switching from a secure // unlock method to an insecure one showFactoryResetProtectionWarningDialog(key); Loading Loading @@ -293,10 +298,10 @@ public class ChooseLockGeneric extends SettingsActivity { } private String getKeyForCurrent() { if (mLockPatternUtils.isLockScreenDisabled(UserHandle.myUserId())) { if (mLockPatternUtils.isLockScreenDisabled(mUserId)) { return KEY_UNLOCK_SET_OFF; } switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId())) { switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: return KEY_UNLOCK_SET_PATTERN; case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: Loading Loading @@ -410,38 +415,38 @@ public class ChooseLockGeneric extends SettingsActivity { protected Intent getLockPasswordIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, boolean confirmCredentials) { boolean requirePasswordToDecrypt, boolean confirmCredentials, int userId) { return ChooseLockPassword.createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, confirmCredentials); maxLength, requirePasswordToDecrypt, confirmCredentials, userId); } protected Intent getLockPasswordIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) { boolean requirePasswordToDecrypt, long challenge, int userId) { return ChooseLockPassword.createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, challenge); maxLength, requirePasswordToDecrypt, challenge, userId); } protected Intent getLockPasswordIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) { int maxLength, boolean requirePasswordToDecrypt, String password, int userId) { return ChooseLockPassword.createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, password); requirePasswordToDecrypt, password, userId); } protected Intent getLockPatternIntent(Context context, final boolean requirePassword, final boolean confirmCredentials) { final boolean confirmCredentials, int userId) { return ChooseLockPattern.createIntent(context, requirePassword, confirmCredentials); confirmCredentials, userId); } protected Intent getLockPatternIntent(Context context, final boolean requirePassword, long challenge) { return ChooseLockPattern.createIntent(context, requirePassword, challenge); long challenge, int userId) { return ChooseLockPattern.createIntent(context, requirePassword, challenge, userId); } protected Intent getLockPatternIntent(Context context, final boolean requirePassword, final String pattern) { return ChooseLockPattern.createIntent(context, requirePassword, pattern); final String pattern, int userId) { return ChooseLockPattern.createIntent(context, requirePassword, pattern, userId); } protected Intent getEncryptionInterstitialIntent(Context context, int quality, Loading Loading @@ -476,26 +481,25 @@ public class ChooseLockGeneric extends SettingsActivity { Intent intent; if (mHasChallenge) { intent = getLockPasswordIntent(context, quality, minLength, maxLength, mRequirePassword, mChallenge); maxLength, mRequirePassword, mChallenge, mUserId); } else { intent = getLockPasswordIntent(context, quality, minLength, maxLength, mRequirePassword, mUserPassword); maxLength, mRequirePassword, mUserPassword, mUserId); } startActivityForResult(intent, CHOOSE_LOCK_REQUEST); } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) { Intent intent; if (mHasChallenge) { intent = getLockPatternIntent(context, mRequirePassword, mChallenge); mChallenge, mUserId); } else { intent = getLockPatternIntent(context, mRequirePassword, mUserPassword); mUserPassword, mUserId); } startActivityForResult(intent, CHOOSE_LOCK_REQUEST); } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { mChooseLockSettingsHelper.utils().clearLock(UserHandle.myUserId()); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, UserHandle.myUserId()); mChooseLockSettingsHelper.utils().clearLock(mUserId); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId); removeAllFingerprintTemplatesAndFinish(); getActivity().setResult(Activity.RESULT_OK); } else { Loading Loading @@ -524,7 +528,7 @@ public class ChooseLockGeneric extends SettingsActivity { private int getResIdForFactoryResetProtectionWarningMessage() { boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(); switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId())) { switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: return hasFingerprints ? R.string.unlock_disable_frp_warning_content_pattern_fingerprint Loading src/com/android/settings/ChooseLockPassword.java +46 −15 Original line number Diff line number Diff line Loading @@ -82,6 +82,15 @@ public class ChooseLockPassword extends SettingsActivity { return intent; } public static Intent createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, boolean confirmCredentials, int userId) { Intent intent = createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, confirmCredentials); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } public static Intent createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) { Intent intent = createIntent(context, quality, minLength, maxLength, Loading @@ -90,6 +99,14 @@ public class ChooseLockPassword extends SettingsActivity { return intent; } public static Intent createIntent(Context context, int quality, int minLength, int maxLength, boolean requirePasswordToDecrypt, String password, int userId) { Intent intent = createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, password); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } public static Intent createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) { Intent intent = createIntent(context, quality, minLength, maxLength, Loading @@ -99,6 +116,14 @@ public class ChooseLockPassword extends SettingsActivity { return intent; } public static Intent createIntent(Context context, int quality, int minLength, int maxLength, boolean requirePasswordToDecrypt, long challenge, int userId) { Intent intent = createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, challenge); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } @Override protected boolean isValidFragment(String fragmentName) { if (ChooseLockPasswordFragment.class.getName().equals(fragmentName)) return true; Loading Loading @@ -160,6 +185,8 @@ public class ChooseLockPassword extends SettingsActivity { private static final long ERROR_MESSAGE_TIMEOUT = 3000; private static final int MSG_SHOW_ERROR = 1; private int mUserId; private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Loading Loading @@ -210,32 +237,34 @@ public class ChooseLockPassword extends SettingsActivity { if (!(getActivity() instanceof ChooseLockPassword)) { throw new SecurityException("Fragment contained in wrong activity"); } // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); mRequestedQuality = Math.max(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedQuality), mLockPatternUtils.getRequestedPasswordQuality( UserHandle.myUserId())); mUserId)); mPasswordMinLength = Math.max(Math.max( LockPatternUtils.MIN_LOCK_PASSWORD_SIZE, intent.getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength)), mLockPatternUtils.getRequestedMinimumPasswordLength(UserHandle.myUserId())); mLockPatternUtils.getRequestedMinimumPasswordLength(mUserId)); mPasswordMaxLength = intent.getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength); mPasswordMinLetters = Math.max(intent.getIntExtra(PASSWORD_MIN_LETTERS_KEY, mPasswordMinLetters), mLockPatternUtils.getRequestedPasswordMinimumLetters( UserHandle.myUserId())); mUserId)); mPasswordMinUpperCase = Math.max(intent.getIntExtra(PASSWORD_MIN_UPPERCASE_KEY, mPasswordMinUpperCase), mLockPatternUtils.getRequestedPasswordMinimumUpperCase( UserHandle.myUserId())); mUserId)); mPasswordMinLowerCase = Math.max(intent.getIntExtra(PASSWORD_MIN_LOWERCASE_KEY, mPasswordMinLowerCase), mLockPatternUtils.getRequestedPasswordMinimumLowerCase( UserHandle.myUserId())); mUserId)); mPasswordMinNumeric = Math.max(intent.getIntExtra(PASSWORD_MIN_NUMERIC_KEY, mPasswordMinNumeric), mLockPatternUtils.getRequestedPasswordMinimumNumeric( UserHandle.myUserId())); mUserId)); mPasswordMinSymbols = Math.max(intent.getIntExtra(PASSWORD_MIN_SYMBOLS_KEY, mPasswordMinSymbols), mLockPatternUtils.getRequestedPasswordMinimumSymbols( UserHandle.myUserId())); mUserId)); mPasswordMinNonLetter = Math.max(intent.getIntExtra(PASSWORD_MIN_NONLETTER_KEY, mPasswordMinNonLetter), mLockPatternUtils.getRequestedPasswordMinimumNonLetter( UserHandle.myUserId())); mUserId)); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity()); } Loading Loading @@ -289,7 +318,8 @@ public class ChooseLockPassword extends SettingsActivity { updateStage(Stage.Introduction); if (confirmCredentials) { mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), true); getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId); } } else { // restore from previous state Loading Loading @@ -477,7 +507,7 @@ public class ChooseLockPassword extends SettingsActivity { return getString(R.string.lockpassword_password_requires_digit); } } if(mLockPatternUtils.checkPasswordHistory(password, UserHandle.myUserId())) { if(mLockPatternUtils.checkPasswordHistory(password, mUserId)) { return getString(mIsAlphaMode ? R.string.lockpassword_password_recently_used : R.string.lockpassword_pin_recently_used); } Loading Loading @@ -618,7 +648,7 @@ public class ChooseLockPassword extends SettingsActivity { final boolean required = getActivity().getIntent().getBooleanExtra( EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); mSaveAndFinishWorker.start(mLockPatternUtils, required, mHasChallenge, mChallenge, mChosenPassword, mCurrentPassword, mRequestedQuality); mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId); } @Override Loading @@ -640,15 +670,17 @@ public class ChooseLockPassword extends SettingsActivity { private String mChosenPassword; private String mCurrentPassword; private int mRequestedQuality; private int mUserId; public void start(LockPatternUtils utils, boolean required, boolean hasChallenge, long challenge, String chosenPassword, String currentPassword, int requestedQuality) { String chosenPassword, String currentPassword, int requestedQuality, int userId) { prepare(utils, required, hasChallenge, challenge); mChosenPassword = chosenPassword; mCurrentPassword = currentPassword; mRequestedQuality = requestedQuality; mUserId = userId; start(); } Loading @@ -656,14 +688,13 @@ public class ChooseLockPassword extends SettingsActivity { @Override protected Intent saveAndVerifyInBackground() { Intent result = null; final int userId = UserHandle.myUserId(); mUtils.saveLockPassword(mChosenPassword, mCurrentPassword, mRequestedQuality, userId); mUserId); if (mHasChallenge) { byte[] token; try { token = mUtils.verifyPassword(mChosenPassword, mChallenge, userId); token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId); } catch (RequestThrottledException e) { token = null; } Loading src/com/android/settings/ChooseLockPattern.java +19 −12 Original line number Diff line number Diff line Loading @@ -73,25 +73,25 @@ public class ChooseLockPattern extends SettingsActivity { } public static Intent createIntent(Context context, boolean requirePassword, boolean confirmCredentials) { boolean requirePassword, boolean confirmCredentials, int userId) { Intent intent = new Intent(context, ChooseLockPattern.class); intent.putExtra("key_lock_method", "pattern"); intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials); intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } public static Intent createIntent(Context context, boolean requirePassword, String pattern) { Intent intent = createIntent(context, requirePassword, false); boolean requirePassword, String pattern, int userId) { Intent intent = createIntent(context, requirePassword, false, userId); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern); return intent; } public static Intent createIntent(Context context, boolean requirePassword, long challenge) { Intent intent = createIntent(context, requirePassword, false); boolean requirePassword, long challenge, int userId) { Intent intent = createIntent(context, requirePassword, false, userId); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); return intent; Loading Loading @@ -355,6 +355,7 @@ public class ChooseLockPattern extends SettingsActivity { private ChooseLockSettingsHelper mChooseLockSettingsHelper; private SaveAndFinishWorker mSaveAndFinishWorker; private int mUserId; private static final String KEY_UI_STAGE = "uiStage"; private static final String KEY_PATTERN_CHOICE = "chosenPattern"; Loading @@ -367,6 +368,9 @@ public class ChooseLockPattern extends SettingsActivity { if (!(getActivity() instanceof ChooseLockPattern)) { throw new SecurityException("Fragment contained in wrong activity"); } Intent intent = getActivity().getIntent(); // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); } @Override Loading Loading @@ -415,7 +419,8 @@ public class ChooseLockPattern extends SettingsActivity { boolean launchedConfirmationActivity = mChooseLockSettingsHelper.launchConfirmationActivity( CONFIRM_EXISTING_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), true); getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId); if (!launchedConfirmationActivity) { updateStage(Stage.Introduction); } Loading Loading @@ -644,7 +649,7 @@ public class ChooseLockPattern extends SettingsActivity { final boolean required = getActivity().getIntent().getBooleanExtra( EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); mSaveAndFinishWorker.start(mChooseLockSettingsHelper.utils(), required, mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern); mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern, mUserId); } @Override Loading @@ -666,16 +671,18 @@ public class ChooseLockPattern extends SettingsActivity { private List<LockPatternView.Cell> mChosenPattern; private String mCurrentPattern; private boolean mLockVirgin; private int mUserId; public void start(LockPatternUtils utils, boolean credentialRequired, boolean hasChallenge, long challenge, List<LockPatternView.Cell> chosenPattern, String currentPattern) { List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId) { prepare(utils, credentialRequired, hasChallenge, challenge); mCurrentPattern = currentPattern; mChosenPattern = chosenPattern; mUserId = userId; mLockVirgin = !mUtils.isPatternEverChosen(UserHandle.myUserId()); mLockVirgin = !mUtils.isPatternEverChosen(mUserId); start(); } Loading @@ -683,7 +690,7 @@ public class ChooseLockPattern extends SettingsActivity { @Override protected Intent saveAndVerifyInBackground() { Intent result = null; final int userId = UserHandle.myUserId(); final int userId = mUserId; mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); if (mHasChallenge) { Loading @@ -708,7 +715,7 @@ public class ChooseLockPattern extends SettingsActivity { @Override protected void finish(Intent resultData) { if (mLockVirgin) { mUtils.setVisiblePatternEnabled(true, UserHandle.myUserId()); mUtils.setVisiblePatternEnabled(true, mUserId); } super.finish(resultData); Loading src/com/android/settings/ChooseLockSettingsHelper.java +23 −8 Original line number Diff line number Diff line Loading @@ -76,6 +76,22 @@ public final class ChooseLockSettingsHelper { return launchConfirmationActivity(request, title, null, null, returnCredentials, false); } /** * If a pattern, password or PIN exists, prompt the user before allowing them to change it. * * @param title title of the confirmation screen; shown in the action bar * @param returnCredentials if true, put credentials into intent. Note that if this is true, * this can only be called internally. * @param userId The userId for whom the lock should be confirmed. * @return true if one exists and we launched an activity to confirm it * @see Activity#onActivityResult(int, int, android.content.Intent) */ boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials, int userId) { return launchConfirmationActivity(request, title, null, null, returnCredentials, false, false, 0, Utils.getSameOwnerUserId(mActivity, userId)); } /** * If a pattern, password or PIN exists, prompt the user before allowing them to change it. * Loading @@ -93,7 +109,7 @@ public final class ChooseLockSettingsHelper { @Nullable CharSequence header, @Nullable CharSequence description, boolean returnCredentials, boolean external) { return launchConfirmationActivity(request, title, header, description, returnCredentials, external, false, 0); returnCredentials, external, false, 0, Utils.getEffectiveUserId(mActivity)); } /** Loading @@ -109,24 +125,22 @@ public final class ChooseLockSettingsHelper { @Nullable CharSequence header, @Nullable CharSequence description, long challenge) { return launchConfirmationActivity(request, title, header, description, false, false, true, challenge); false, false, true, challenge, Utils.getEffectiveUserId(mActivity)); } private boolean launchConfirmationActivity(int request, @Nullable CharSequence title, @Nullable CharSequence header, @Nullable CharSequence description, boolean returnCredentials, boolean external, boolean hasChallenge, long challenge) { long challenge, int effectiveUserId) { boolean launched = false; int effectiveUserId = Utils.getEffectiveUserId(mActivity); switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(effectiveUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: launched = launchConfirmationActivity(request, title, header, description, returnCredentials || hasChallenge ? ConfirmLockPattern.InternalActivity.class : ConfirmLockPattern.class, external, hasChallenge, challenge); hasChallenge, challenge, effectiveUserId); break; case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: Loading @@ -137,7 +151,7 @@ public final class ChooseLockSettingsHelper { returnCredentials || hasChallenge ? ConfirmLockPassword.InternalActivity.class : ConfirmLockPassword.class, external, hasChallenge, challenge); hasChallenge, challenge, effectiveUserId); break; } return launched; Loading @@ -145,7 +159,7 @@ public final class ChooseLockSettingsHelper { private boolean launchConfirmationActivity(int request, CharSequence title, CharSequence header, CharSequence message, Class<?> activityClass, boolean external, boolean hasChallenge, long challenge) { long challenge, int userId) { final Intent intent = new Intent(); intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title); intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header); Loading @@ -156,6 +170,7 @@ public final class ChooseLockSettingsHelper { intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, external); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); intent.setClassName(ConfirmDeviceCredentialBaseFragment.PACKAGE, activityClass.getName()); if (external) { intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); Loading src/com/android/settings/ConfirmLockPassword.java +3 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/com/android/settings/ChooseLockGeneric.java +28 −24 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import com.android.internal.widget.LockPatternUtils; public class ChooseLockGeneric extends SettingsActivity { public static final String CONFIRM_CREDENTIALS = "confirm_credentials"; public static final String KEY_USER_ID = "user_id"; @Override public Intent getIntent() { Loading Loading @@ -103,6 +104,7 @@ public class ChooseLockGeneric extends SettingsActivity { private String mUserPassword; private LockPatternUtils mLockPatternUtils; private FingerprintManager mFingerprintManager; private int mUserId; private RemovalCallback mRemovalCallback = new RemovalCallback() { @Override Loading Loading @@ -161,13 +163,16 @@ public class ChooseLockGeneric extends SettingsActivity { ENCRYPT_REQUESTED_DISABLED); } // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getSameOwnerUserId(getContext(), getArguments()); if (mPasswordConfirmed) { updatePreferencesOrFinish(); } else if (!mWaitingForConfirmation) { ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(this.getActivity(), this); if (!helper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), true)) { getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId)) { mPasswordConfirmed = true; // no password set, so no need to confirm updatePreferencesOrFinish(); } else { Loading @@ -188,7 +193,7 @@ public class ChooseLockGeneric extends SettingsActivity { public boolean onPreferenceTreeClick(Preference preference) { final String key = preference.getKey(); if (!isUnlockMethodSecure(key) && mLockPatternUtils.isSecure(UserHandle.myUserId())) { if (!isUnlockMethodSecure(key) && mLockPatternUtils.isSecure(mUserId)) { // Show the disabling FRP warning only when the user is switching from a secure // unlock method to an insecure one showFactoryResetProtectionWarningDialog(key); Loading Loading @@ -293,10 +298,10 @@ public class ChooseLockGeneric extends SettingsActivity { } private String getKeyForCurrent() { if (mLockPatternUtils.isLockScreenDisabled(UserHandle.myUserId())) { if (mLockPatternUtils.isLockScreenDisabled(mUserId)) { return KEY_UNLOCK_SET_OFF; } switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId())) { switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: return KEY_UNLOCK_SET_PATTERN; case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: Loading Loading @@ -410,38 +415,38 @@ public class ChooseLockGeneric extends SettingsActivity { protected Intent getLockPasswordIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, boolean confirmCredentials) { boolean requirePasswordToDecrypt, boolean confirmCredentials, int userId) { return ChooseLockPassword.createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, confirmCredentials); maxLength, requirePasswordToDecrypt, confirmCredentials, userId); } protected Intent getLockPasswordIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) { boolean requirePasswordToDecrypt, long challenge, int userId) { return ChooseLockPassword.createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, challenge); maxLength, requirePasswordToDecrypt, challenge, userId); } protected Intent getLockPasswordIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) { int maxLength, boolean requirePasswordToDecrypt, String password, int userId) { return ChooseLockPassword.createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, password); requirePasswordToDecrypt, password, userId); } protected Intent getLockPatternIntent(Context context, final boolean requirePassword, final boolean confirmCredentials) { final boolean confirmCredentials, int userId) { return ChooseLockPattern.createIntent(context, requirePassword, confirmCredentials); confirmCredentials, userId); } protected Intent getLockPatternIntent(Context context, final boolean requirePassword, long challenge) { return ChooseLockPattern.createIntent(context, requirePassword, challenge); long challenge, int userId) { return ChooseLockPattern.createIntent(context, requirePassword, challenge, userId); } protected Intent getLockPatternIntent(Context context, final boolean requirePassword, final String pattern) { return ChooseLockPattern.createIntent(context, requirePassword, pattern); final String pattern, int userId) { return ChooseLockPattern.createIntent(context, requirePassword, pattern, userId); } protected Intent getEncryptionInterstitialIntent(Context context, int quality, Loading Loading @@ -476,26 +481,25 @@ public class ChooseLockGeneric extends SettingsActivity { Intent intent; if (mHasChallenge) { intent = getLockPasswordIntent(context, quality, minLength, maxLength, mRequirePassword, mChallenge); maxLength, mRequirePassword, mChallenge, mUserId); } else { intent = getLockPasswordIntent(context, quality, minLength, maxLength, mRequirePassword, mUserPassword); maxLength, mRequirePassword, mUserPassword, mUserId); } startActivityForResult(intent, CHOOSE_LOCK_REQUEST); } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) { Intent intent; if (mHasChallenge) { intent = getLockPatternIntent(context, mRequirePassword, mChallenge); mChallenge, mUserId); } else { intent = getLockPatternIntent(context, mRequirePassword, mUserPassword); mUserPassword, mUserId); } startActivityForResult(intent, CHOOSE_LOCK_REQUEST); } else if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) { mChooseLockSettingsHelper.utils().clearLock(UserHandle.myUserId()); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, UserHandle.myUserId()); mChooseLockSettingsHelper.utils().clearLock(mUserId); mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId); removeAllFingerprintTemplatesAndFinish(); getActivity().setResult(Activity.RESULT_OK); } else { Loading Loading @@ -524,7 +528,7 @@ public class ChooseLockGeneric extends SettingsActivity { private int getResIdForFactoryResetProtectionWarningMessage() { boolean hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(); switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId())) { switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: return hasFingerprints ? R.string.unlock_disable_frp_warning_content_pattern_fingerprint Loading
src/com/android/settings/ChooseLockPassword.java +46 −15 Original line number Diff line number Diff line Loading @@ -82,6 +82,15 @@ public class ChooseLockPassword extends SettingsActivity { return intent; } public static Intent createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, boolean confirmCredentials, int userId) { Intent intent = createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, confirmCredentials); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } public static Intent createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, String password) { Intent intent = createIntent(context, quality, minLength, maxLength, Loading @@ -90,6 +99,14 @@ public class ChooseLockPassword extends SettingsActivity { return intent; } public static Intent createIntent(Context context, int quality, int minLength, int maxLength, boolean requirePasswordToDecrypt, String password, int userId) { Intent intent = createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, password); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } public static Intent createIntent(Context context, int quality, int minLength, final int maxLength, boolean requirePasswordToDecrypt, long challenge) { Intent intent = createIntent(context, quality, minLength, maxLength, Loading @@ -99,6 +116,14 @@ public class ChooseLockPassword extends SettingsActivity { return intent; } public static Intent createIntent(Context context, int quality, int minLength, int maxLength, boolean requirePasswordToDecrypt, long challenge, int userId) { Intent intent = createIntent(context, quality, minLength, maxLength, requirePasswordToDecrypt, challenge); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } @Override protected boolean isValidFragment(String fragmentName) { if (ChooseLockPasswordFragment.class.getName().equals(fragmentName)) return true; Loading Loading @@ -160,6 +185,8 @@ public class ChooseLockPassword extends SettingsActivity { private static final long ERROR_MESSAGE_TIMEOUT = 3000; private static final int MSG_SHOW_ERROR = 1; private int mUserId; private Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { Loading Loading @@ -210,32 +237,34 @@ public class ChooseLockPassword extends SettingsActivity { if (!(getActivity() instanceof ChooseLockPassword)) { throw new SecurityException("Fragment contained in wrong activity"); } // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); mRequestedQuality = Math.max(intent.getIntExtra(LockPatternUtils.PASSWORD_TYPE_KEY, mRequestedQuality), mLockPatternUtils.getRequestedPasswordQuality( UserHandle.myUserId())); mUserId)); mPasswordMinLength = Math.max(Math.max( LockPatternUtils.MIN_LOCK_PASSWORD_SIZE, intent.getIntExtra(PASSWORD_MIN_KEY, mPasswordMinLength)), mLockPatternUtils.getRequestedMinimumPasswordLength(UserHandle.myUserId())); mLockPatternUtils.getRequestedMinimumPasswordLength(mUserId)); mPasswordMaxLength = intent.getIntExtra(PASSWORD_MAX_KEY, mPasswordMaxLength); mPasswordMinLetters = Math.max(intent.getIntExtra(PASSWORD_MIN_LETTERS_KEY, mPasswordMinLetters), mLockPatternUtils.getRequestedPasswordMinimumLetters( UserHandle.myUserId())); mUserId)); mPasswordMinUpperCase = Math.max(intent.getIntExtra(PASSWORD_MIN_UPPERCASE_KEY, mPasswordMinUpperCase), mLockPatternUtils.getRequestedPasswordMinimumUpperCase( UserHandle.myUserId())); mUserId)); mPasswordMinLowerCase = Math.max(intent.getIntExtra(PASSWORD_MIN_LOWERCASE_KEY, mPasswordMinLowerCase), mLockPatternUtils.getRequestedPasswordMinimumLowerCase( UserHandle.myUserId())); mUserId)); mPasswordMinNumeric = Math.max(intent.getIntExtra(PASSWORD_MIN_NUMERIC_KEY, mPasswordMinNumeric), mLockPatternUtils.getRequestedPasswordMinimumNumeric( UserHandle.myUserId())); mUserId)); mPasswordMinSymbols = Math.max(intent.getIntExtra(PASSWORD_MIN_SYMBOLS_KEY, mPasswordMinSymbols), mLockPatternUtils.getRequestedPasswordMinimumSymbols( UserHandle.myUserId())); mUserId)); mPasswordMinNonLetter = Math.max(intent.getIntExtra(PASSWORD_MIN_NONLETTER_KEY, mPasswordMinNonLetter), mLockPatternUtils.getRequestedPasswordMinimumNonLetter( UserHandle.myUserId())); mUserId)); mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity()); } Loading Loading @@ -289,7 +318,8 @@ public class ChooseLockPassword extends SettingsActivity { updateStage(Stage.Introduction); if (confirmCredentials) { mChooseLockSettingsHelper.launchConfirmationActivity(CONFIRM_EXISTING_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), true); getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId); } } else { // restore from previous state Loading Loading @@ -477,7 +507,7 @@ public class ChooseLockPassword extends SettingsActivity { return getString(R.string.lockpassword_password_requires_digit); } } if(mLockPatternUtils.checkPasswordHistory(password, UserHandle.myUserId())) { if(mLockPatternUtils.checkPasswordHistory(password, mUserId)) { return getString(mIsAlphaMode ? R.string.lockpassword_password_recently_used : R.string.lockpassword_pin_recently_used); } Loading Loading @@ -618,7 +648,7 @@ public class ChooseLockPassword extends SettingsActivity { final boolean required = getActivity().getIntent().getBooleanExtra( EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); mSaveAndFinishWorker.start(mLockPatternUtils, required, mHasChallenge, mChallenge, mChosenPassword, mCurrentPassword, mRequestedQuality); mChosenPassword, mCurrentPassword, mRequestedQuality, mUserId); } @Override Loading @@ -640,15 +670,17 @@ public class ChooseLockPassword extends SettingsActivity { private String mChosenPassword; private String mCurrentPassword; private int mRequestedQuality; private int mUserId; public void start(LockPatternUtils utils, boolean required, boolean hasChallenge, long challenge, String chosenPassword, String currentPassword, int requestedQuality) { String chosenPassword, String currentPassword, int requestedQuality, int userId) { prepare(utils, required, hasChallenge, challenge); mChosenPassword = chosenPassword; mCurrentPassword = currentPassword; mRequestedQuality = requestedQuality; mUserId = userId; start(); } Loading @@ -656,14 +688,13 @@ public class ChooseLockPassword extends SettingsActivity { @Override protected Intent saveAndVerifyInBackground() { Intent result = null; final int userId = UserHandle.myUserId(); mUtils.saveLockPassword(mChosenPassword, mCurrentPassword, mRequestedQuality, userId); mUserId); if (mHasChallenge) { byte[] token; try { token = mUtils.verifyPassword(mChosenPassword, mChallenge, userId); token = mUtils.verifyPassword(mChosenPassword, mChallenge, mUserId); } catch (RequestThrottledException e) { token = null; } Loading
src/com/android/settings/ChooseLockPattern.java +19 −12 Original line number Diff line number Diff line Loading @@ -73,25 +73,25 @@ public class ChooseLockPattern extends SettingsActivity { } public static Intent createIntent(Context context, boolean requirePassword, boolean confirmCredentials) { boolean requirePassword, boolean confirmCredentials, int userId) { Intent intent = new Intent(context, ChooseLockPattern.class); intent.putExtra("key_lock_method", "pattern"); intent.putExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, confirmCredentials); intent.putExtra(EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, requirePassword); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); return intent; } public static Intent createIntent(Context context, boolean requirePassword, String pattern) { Intent intent = createIntent(context, requirePassword, false); boolean requirePassword, String pattern, int userId) { Intent intent = createIntent(context, requirePassword, false, userId); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern); return intent; } public static Intent createIntent(Context context, boolean requirePassword, long challenge) { Intent intent = createIntent(context, requirePassword, false); boolean requirePassword, long challenge, int userId) { Intent intent = createIntent(context, requirePassword, false, userId); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); return intent; Loading Loading @@ -355,6 +355,7 @@ public class ChooseLockPattern extends SettingsActivity { private ChooseLockSettingsHelper mChooseLockSettingsHelper; private SaveAndFinishWorker mSaveAndFinishWorker; private int mUserId; private static final String KEY_UI_STAGE = "uiStage"; private static final String KEY_PATTERN_CHOICE = "chosenPattern"; Loading @@ -367,6 +368,9 @@ public class ChooseLockPattern extends SettingsActivity { if (!(getActivity() instanceof ChooseLockPattern)) { throw new SecurityException("Fragment contained in wrong activity"); } Intent intent = getActivity().getIntent(); // Only take this argument into account if it belongs to the current profile. mUserId = Utils.getSameOwnerUserId(getActivity(), intent.getExtras()); } @Override Loading Loading @@ -415,7 +419,8 @@ public class ChooseLockPattern extends SettingsActivity { boolean launchedConfirmationActivity = mChooseLockSettingsHelper.launchConfirmationActivity( CONFIRM_EXISTING_REQUEST, getString(R.string.unlock_set_unlock_launch_picker_title), true); getString(R.string.unlock_set_unlock_launch_picker_title), true, mUserId); if (!launchedConfirmationActivity) { updateStage(Stage.Introduction); } Loading Loading @@ -644,7 +649,7 @@ public class ChooseLockPattern extends SettingsActivity { final boolean required = getActivity().getIntent().getBooleanExtra( EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true); mSaveAndFinishWorker.start(mChooseLockSettingsHelper.utils(), required, mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern); mHasChallenge, mChallenge, mChosenPattern, mCurrentPattern, mUserId); } @Override Loading @@ -666,16 +671,18 @@ public class ChooseLockPattern extends SettingsActivity { private List<LockPatternView.Cell> mChosenPattern; private String mCurrentPattern; private boolean mLockVirgin; private int mUserId; public void start(LockPatternUtils utils, boolean credentialRequired, boolean hasChallenge, long challenge, List<LockPatternView.Cell> chosenPattern, String currentPattern) { List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId) { prepare(utils, credentialRequired, hasChallenge, challenge); mCurrentPattern = currentPattern; mChosenPattern = chosenPattern; mUserId = userId; mLockVirgin = !mUtils.isPatternEverChosen(UserHandle.myUserId()); mLockVirgin = !mUtils.isPatternEverChosen(mUserId); start(); } Loading @@ -683,7 +690,7 @@ public class ChooseLockPattern extends SettingsActivity { @Override protected Intent saveAndVerifyInBackground() { Intent result = null; final int userId = UserHandle.myUserId(); final int userId = mUserId; mUtils.saveLockPattern(mChosenPattern, mCurrentPattern, userId); if (mHasChallenge) { Loading @@ -708,7 +715,7 @@ public class ChooseLockPattern extends SettingsActivity { @Override protected void finish(Intent resultData) { if (mLockVirgin) { mUtils.setVisiblePatternEnabled(true, UserHandle.myUserId()); mUtils.setVisiblePatternEnabled(true, mUserId); } super.finish(resultData); Loading
src/com/android/settings/ChooseLockSettingsHelper.java +23 −8 Original line number Diff line number Diff line Loading @@ -76,6 +76,22 @@ public final class ChooseLockSettingsHelper { return launchConfirmationActivity(request, title, null, null, returnCredentials, false); } /** * If a pattern, password or PIN exists, prompt the user before allowing them to change it. * * @param title title of the confirmation screen; shown in the action bar * @param returnCredentials if true, put credentials into intent. Note that if this is true, * this can only be called internally. * @param userId The userId for whom the lock should be confirmed. * @return true if one exists and we launched an activity to confirm it * @see Activity#onActivityResult(int, int, android.content.Intent) */ boolean launchConfirmationActivity(int request, CharSequence title, boolean returnCredentials, int userId) { return launchConfirmationActivity(request, title, null, null, returnCredentials, false, false, 0, Utils.getSameOwnerUserId(mActivity, userId)); } /** * If a pattern, password or PIN exists, prompt the user before allowing them to change it. * Loading @@ -93,7 +109,7 @@ public final class ChooseLockSettingsHelper { @Nullable CharSequence header, @Nullable CharSequence description, boolean returnCredentials, boolean external) { return launchConfirmationActivity(request, title, header, description, returnCredentials, external, false, 0); returnCredentials, external, false, 0, Utils.getEffectiveUserId(mActivity)); } /** Loading @@ -109,24 +125,22 @@ public final class ChooseLockSettingsHelper { @Nullable CharSequence header, @Nullable CharSequence description, long challenge) { return launchConfirmationActivity(request, title, header, description, false, false, true, challenge); false, false, true, challenge, Utils.getEffectiveUserId(mActivity)); } private boolean launchConfirmationActivity(int request, @Nullable CharSequence title, @Nullable CharSequence header, @Nullable CharSequence description, boolean returnCredentials, boolean external, boolean hasChallenge, long challenge) { long challenge, int effectiveUserId) { boolean launched = false; int effectiveUserId = Utils.getEffectiveUserId(mActivity); switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(effectiveUserId)) { case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: launched = launchConfirmationActivity(request, title, header, description, returnCredentials || hasChallenge ? ConfirmLockPattern.InternalActivity.class : ConfirmLockPattern.class, external, hasChallenge, challenge); hasChallenge, challenge, effectiveUserId); break; case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC: case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: Loading @@ -137,7 +151,7 @@ public final class ChooseLockSettingsHelper { returnCredentials || hasChallenge ? ConfirmLockPassword.InternalActivity.class : ConfirmLockPassword.class, external, hasChallenge, challenge); hasChallenge, challenge, effectiveUserId); break; } return launched; Loading @@ -145,7 +159,7 @@ public final class ChooseLockSettingsHelper { private boolean launchConfirmationActivity(int request, CharSequence title, CharSequence header, CharSequence message, Class<?> activityClass, boolean external, boolean hasChallenge, long challenge) { long challenge, int userId) { final Intent intent = new Intent(); intent.putExtra(ConfirmDeviceCredentialBaseFragment.TITLE_TEXT, title); intent.putExtra(ConfirmDeviceCredentialBaseFragment.HEADER_TEXT, header); Loading @@ -156,6 +170,7 @@ public final class ChooseLockSettingsHelper { intent.putExtra(ConfirmDeviceCredentialBaseFragment.SHOW_WHEN_LOCKED, external); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge); intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge); intent.putExtra(ChooseLockGeneric.KEY_USER_ID, userId); intent.setClassName(ConfirmDeviceCredentialBaseFragment.PACKAGE, activityClass.getName()); if (external) { intent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); Loading
src/com/android/settings/ConfirmLockPassword.java +3 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes