Commit fd365ae9 authored by android-build-team Robot's avatar android-build-team Robot

Merge cherrypicks of [7316389, 7315812, 7315813, 7316457, 7316055, 7315736,...

Merge cherrypicks of [7316389, 7315812, 7315813, 7316457, 7316055, 7315736, 7316390, 7316458, 7316459, 7316460, 7316561, 7316562, 7316563, 7316564, 7316565, 7316566, 7316567, 7316391, 7315814, 7316548] into pi-qpr3-b-release

Change-Id: I6dc39868f631f9bb35be079cbdeb8a5f9f265e30
parents feddc93a 9804cf5b
......@@ -38,7 +38,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.core.InstrumentedFragment;
import java.util.Arrays;
import java.util.Locale;
public class CryptKeeperConfirm extends InstrumentedFragment {
......@@ -88,12 +87,7 @@ public class CryptKeeperConfirm extends InstrumentedFragment {
IStorageManager storageManager = IStorageManager.Stub.asInterface(service);
try {
Bundle args = getIntent().getExtras();
// TODO(b/120484642): Update vold to accept a password as a byte array
byte[] passwordBytes = args.getByteArray("password");
String password = passwordBytes != null ? new String(passwordBytes) : null;
Arrays.fill(passwordBytes, (byte) 0);
storageManager.encryptStorage(args.getInt("type", -1),
password);
storageManager.encryptStorage(args.getInt("type", -1), args.getString("password"));
} catch (Exception e) {
Log.e("CryptKeeper", "Error while encrypting...", e);
}
......
......@@ -63,7 +63,6 @@ import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedPreference;
import java.util.Arrays;
import java.util.List;
public class ChooseLockGeneric extends SettingsActivity {
......@@ -145,7 +144,7 @@ public class ChooseLockGeneric extends SettingsActivity {
private int mEncryptionRequestQuality;
private boolean mEncryptionRequestDisabled;
private boolean mForChangeCredRequiredForBoot = false;
private byte[] mUserPassword;
private String mUserPassword;
private LockPatternUtils mLockPatternUtils;
private FingerprintManager mFingerprintManager;
private int mUserId;
......@@ -185,7 +184,7 @@ public class ChooseLockGeneric extends SettingsActivity {
.getBooleanExtra(CONFIRM_CREDENTIALS, true);
if (getActivity() instanceof ChooseLockGeneric.InternalActivity) {
mPasswordConfirmed = !confirmCredentials;
mUserPassword = getActivity().getIntent().getByteArrayExtra(
mUserPassword = getActivity().getIntent().getStringExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
......@@ -207,7 +206,7 @@ public class ChooseLockGeneric extends SettingsActivity {
mEncryptionRequestDisabled = savedInstanceState.getBoolean(
ENCRYPT_REQUESTED_DISABLED);
if (mUserPassword == null) {
mUserPassword = savedInstanceState.getByteArray(
mUserPassword = savedInstanceState.getString(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
}
......@@ -352,12 +351,10 @@ public class ChooseLockGeneric extends SettingsActivity {
mWaitingForConfirmation = false;
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
mPasswordConfirmed = true;
mUserPassword = data != null
? data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
: null;
mUserPassword = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
updatePreferencesOrFinish(false /* isRecreatingActivity */);
if (mForChangeCredRequiredForBoot) {
if (!(mUserPassword == null || mUserPassword.length == 0)) {
if (!TextUtils.isEmpty(mUserPassword)) {
maybeEnableEncryption(
mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
} else {
......@@ -417,7 +414,7 @@ public class ChooseLockGeneric extends SettingsActivity {
outState.putInt(ENCRYPT_REQUESTED_QUALITY, mEncryptionRequestQuality);
outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled);
if (mUserPassword != null) {
outState.putByteArray(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
outState.putString(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, mUserPassword);
}
}
......@@ -593,7 +590,7 @@ public class ChooseLockGeneric extends SettingsActivity {
setPreferenceSummary(ScreenLockType.MANAGED, R.string.secure_lock_encryption_warning);
}
protected Intent getLockManagedPasswordIntent(byte[] password) {
protected Intent getLockManagedPasswordIntent(String password) {
return mManagedPasswordProvider.createIntent(false, password);
}
......
......@@ -52,7 +52,6 @@ import com.android.setupwizardlib.GlifLayout;
import com.google.android.collect.Lists;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
......@@ -112,7 +111,7 @@ public class ChooseLockPattern extends SettingsActivity {
return this;
}
public IntentBuilder setPattern(byte[] pattern) {
public IntentBuilder setPattern(String pattern) {
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
return this;
}
......@@ -171,7 +170,7 @@ public class ChooseLockPattern extends SettingsActivity {
private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
private byte[] mCurrentPattern;
private String mCurrentPattern;
private boolean mHasChallenge;
private long mChallenge;
protected TextView mTitleText;
......@@ -209,7 +208,7 @@ public class ChooseLockPattern extends SettingsActivity {
getActivity().setResult(RESULT_FINISHED);
getActivity().finish();
} else {
mCurrentPattern = data.getByteArrayExtra(
mCurrentPattern = data.getStringExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
}
......@@ -442,12 +441,12 @@ public class ChooseLockPattern extends SettingsActivity {
SaveAndFinishWorker w = new SaveAndFinishWorker();
final boolean required = getActivity().getIntent().getBooleanExtra(
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
byte[] current = intent.getByteArrayExtra(
String current = intent.getStringExtra(
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
w.setBlocking(true);
w.setListener(this);
w.start(mChooseLockSettingsHelper.utils(), required,
false, 0, LockPatternUtils.byteArrayToPattern(current), current, mUserId);
false, 0, LockPatternUtils.stringToPattern(current), current, mUserId);
}
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
mForFingerprint = intent.getBooleanExtra(
......@@ -508,8 +507,7 @@ public class ChooseLockPattern extends SettingsActivity {
final boolean confirmCredentials = getActivity().getIntent()
.getBooleanExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
Intent intent = getActivity().getIntent();
mCurrentPattern =
intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
mCurrentPattern = intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
mHasChallenge = intent.getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
......@@ -532,13 +530,13 @@ public class ChooseLockPattern extends SettingsActivity {
}
} else {
// restore from previous state
final byte[] pattern = savedInstanceState.getByteArray(KEY_PATTERN_CHOICE);
if (pattern != null) {
mChosenPattern = LockPatternUtils.byteArrayToPattern(pattern);
final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE);
if (patternString != null) {
mChosenPattern = LockPatternUtils.stringToPattern(patternString);
}
if (mCurrentPattern == null) {
mCurrentPattern = savedInstanceState.getByteArray(KEY_CURRENT_PATTERN);
mCurrentPattern = savedInstanceState.getString(KEY_CURRENT_PATTERN);
}
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
......@@ -634,12 +632,13 @@ public class ChooseLockPattern extends SettingsActivity {
outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
if (mChosenPattern != null) {
outState.putByteArray(KEY_PATTERN_CHOICE,
LockPatternUtils.patternToByteArray(mChosenPattern));
outState.putString(KEY_PATTERN_CHOICE,
LockPatternUtils.patternToString(mChosenPattern));
}
if (mCurrentPattern != null) {
outState.putByteArray(KEY_CURRENT_PATTERN, mCurrentPattern);
outState.putString(KEY_CURRENT_PATTERN,
mCurrentPattern);
}
}
......@@ -785,10 +784,6 @@ public class ChooseLockPattern extends SettingsActivity {
public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData) {
getActivity().setResult(RESULT_FINISHED, resultData);
if (mCurrentPattern != null) {
Arrays.fill(mCurrentPattern, (byte) 0);
}
if (!wasSecureBefore) {
Intent intent = getRedactionInterstitialIntent(getActivity());
if (intent != null) {
......@@ -803,12 +798,12 @@ public class ChooseLockPattern extends SettingsActivity {
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
private List<LockPatternView.Cell> mChosenPattern;
private byte[] mCurrentPattern;
private String mCurrentPattern;
private boolean mLockVirgin;
public void start(LockPatternUtils utils, boolean credentialRequired,
boolean hasChallenge, long challenge,
List<LockPatternView.Cell> chosenPattern, byte[] currentPattern, int userId) {
List<LockPatternView.Cell> chosenPattern, String currentPattern, int userId) {
prepare(utils, credentialRequired, hasChallenge, challenge, userId);
mCurrentPattern = currentPattern;
......
......@@ -332,9 +332,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
return;
}
// TODO(b/120484642): This is a point of entry for passwords from the UI
final byte[] pin = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
if (pin == null || pin.length == 0) {
final String pin = mPasswordEntry.getText().toString();
if (TextUtils.isEmpty(pin)) {
return;
}
......@@ -360,7 +359,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
return getActivity() instanceof ConfirmLockPassword.InternalActivity;
}
private void startVerifyPassword(final byte[] pin, final Intent intent) {
private void startVerifyPassword(final String pin, final Intent intent) {
long challenge = getActivity().getIntent().getLongExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
final int localEffectiveUserId = mEffectiveUserId;
......@@ -391,7 +390,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
onVerifyCallback);
}
private void startCheckPassword(final byte[] pin, final Intent intent) {
private void startCheckPassword(final String pin, final Intent intent) {
final int localEffectiveUserId = mEffectiveUserId;
mPendingLockCheck = LockPatternChecker.checkPassword(
mLockPatternUtils,
......
......@@ -462,7 +462,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
mLockPatternUtils, pattern, challenge, localUserId,
onVerifyCallback)
: LockPatternChecker.verifyTiedProfileChallenge(
mLockPatternUtils, LockPatternUtils.patternToByteArray(pattern),
mLockPatternUtils, LockPatternUtils.patternToString(pattern),
true, challenge, localUserId, onVerifyCallback);
}
......@@ -487,7 +487,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
StorageManager.CRYPT_TYPE_PATTERN);
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
LockPatternUtils.patternToByteArray(pattern));
LockPatternUtils.patternToString(pattern));
}
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
localEffectiveUserId);
......
......@@ -61,7 +61,7 @@ public class ManagedLockPasswordProvider {
* @param password Current lock password.
* @return Intent that should update lock password to a managed password.
*/
Intent createIntent(boolean requirePasswordToDecrypt, byte[] password) {
Intent createIntent(boolean requirePasswordToDecrypt, String password) {
return null;
}
}
......@@ -172,7 +172,7 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
if (helper.utils().getKeyguardStoredPasswordQuality(UserHandle.myUserId())
== DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "".getBytes());
showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "");
return true;
}
......@@ -192,14 +192,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);
byte[] password = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
if (!(password == null || password.length == 0)) {
String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
if (!TextUtils.isEmpty(password)) {
showFinalConfirmation(type, password);
}
}
}
private void showFinalConfirmation(int type, byte[] password) {
private void showFinalConfirmation(int type, String password) {
Preference preference = new Preference(getPreferenceManager().getContext());
preference.setFragment(CryptKeeperConfirm.class.getName());
preference.setTitle(R.string.crypt_keeper_confirm_title);
......@@ -207,16 +207,16 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
((SettingsActivity) getActivity()).onPreferenceStartFragment(null, preference);
}
private void addEncryptionInfoToPreference(Preference preference, int type, byte[] password) {
private void addEncryptionInfoToPreference(Preference preference, int type, String 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().putByteArray(PASSWORD, "".getBytes());
preference.getExtras().putString(PASSWORD, "");
} else {
preference.getExtras().putInt(TYPE, type);
preference.getExtras().putByteArray(PASSWORD, password);
preference.getExtras().putString(PASSWORD, password);
}
}
}
......@@ -56,8 +56,9 @@ public class LockUnificationPreferenceController extends AbstractPreferenceContr
private RestrictedSwitchPreference mUnifyProfile;
private byte[] mCurrentDevicePassword;
private byte[] mCurrentProfilePassword;
private String mCurrentDevicePassword;
private String mCurrentProfilePassword;
@Override
public void displayPreference(PreferenceScreen screen) {
......@@ -138,13 +139,13 @@ public class LockUnificationPreferenceController extends AbstractPreferenceContr
} else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
&& resultCode == Activity.RESULT_OK) {
mCurrentDevicePassword =
data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
launchConfirmProfileLockForUnification();
return true;
} else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
&& resultCode == Activity.RESULT_OK) {
mCurrentProfilePassword =
data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
unifyLocks();
return true;
}
......@@ -191,7 +192,7 @@ public class LockUnificationPreferenceController extends AbstractPreferenceContr
mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId);
if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
mLockPatternUtils.saveLockPattern(
LockPatternUtils.byteArrayToPattern(mCurrentProfilePassword),
LockPatternUtils.stringToPattern(mCurrentProfilePassword),
mCurrentDevicePassword, MY_USER_ID);
} else {
mLockPatternUtils.saveLockPassword(
......
......@@ -65,7 +65,7 @@ public class ChooseLockPasswordTest {
@Test
public void intentBuilder_setPassword_shouldAddExtras() {
Intent intent = new IntentBuilder(application)
.setPassword("password".getBytes())
.setPassword("password")
.setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
.setPasswordLengthRange(123, 456)
.setUserId(123)
......@@ -74,9 +74,9 @@ public class ChooseLockPasswordTest {
assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
.named("EXTRA_KEY_HAS_CHALLENGE")
.isFalse();
assertThat(intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
assertThat(intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
.named("EXTRA_KEY_PASSWORD")
.isEqualTo("password".getBytes());
.isEqualTo("password");
assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0))
.named("PASSWORD_MIN_KEY")
.isEqualTo(123);
......
......@@ -58,7 +58,7 @@ public class ChooseLockPatternTest {
@Test
public void intentBuilder_setPattern_shouldAddExtras() {
Intent intent = new IntentBuilder(application)
.setPattern("pattern".getBytes())
.setPattern("pattern")
.setUserId(123)
.build();
......@@ -67,9 +67,9 @@ public class ChooseLockPatternTest {
.named("EXTRA_KEY_HAS_CHALLENGE")
.isFalse();
assertThat(intent
.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
.named("EXTRA_KEY_PASSWORD")
.isEqualTo("pattern".getBytes());
.isEqualTo("pattern");
assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
.named("EXTRA_USER_ID")
.isEqualTo(123);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment