Refactor passwords/pins/patterns to byte[]
Relating to packages/apps/Settings Bug: 120484642 Test: manual - test setting and unlocking passwords/pins/patterns. automated - 20 of about 500 tests fail due to fragile synthetic password test code. Change-Id: Idec8338d141c185bef67ade12035fdb2fa9d17ea
This commit is contained in:
@@ -173,7 +173,7 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
|
||||
|
||||
if (helper.utils().getKeyguardStoredPasswordQuality(UserHandle.myUserId())
|
||||
== DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
||||
showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "");
|
||||
showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "".getBytes());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -193,14 +193,14 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
|
||||
// confirmation prompt; otherwise, go back to the initial state.
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
int type = data.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, -1);
|
||||
String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
byte[] password = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
if (!(password == null || password.length == 0)) {
|
||||
showFinalConfirmation(type, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showFinalConfirmation(int type, String password) {
|
||||
private void showFinalConfirmation(int type, byte[] password) {
|
||||
Preference preference = new Preference(getPreferenceManager().getContext());
|
||||
preference.setFragment(CryptKeeperConfirm.class.getName());
|
||||
preference.setTitle(R.string.crypt_keeper_confirm_title);
|
||||
@@ -208,16 +208,16 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
|
||||
((SettingsActivity) getActivity()).onPreferenceStartFragment(null, preference);
|
||||
}
|
||||
|
||||
private void addEncryptionInfoToPreference(Preference preference, int type, String password) {
|
||||
private void addEncryptionInfoToPreference(Preference preference, int type, byte[] password) {
|
||||
Activity activity = getActivity();
|
||||
DevicePolicyManager dpm = (DevicePolicyManager)
|
||||
activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
if (dpm.getDoNotAskCredentialsOnBoot()) {
|
||||
preference.getExtras().putInt(TYPE, StorageManager.CRYPT_TYPE_DEFAULT);
|
||||
preference.getExtras().putString(PASSWORD, "");
|
||||
preference.getExtras().putByteArray(PASSWORD, "".getBytes());
|
||||
} else {
|
||||
preference.getExtras().putInt(TYPE, type);
|
||||
preference.getExtras().putString(PASSWORD, password);
|
||||
preference.getExtras().putByteArray(PASSWORD, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user