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
This commit is contained in:
@@ -38,7 +38,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
|||||||
import com.android.internal.widget.LockPatternUtils;
|
import com.android.internal.widget.LockPatternUtils;
|
||||||
import com.android.settings.core.InstrumentedFragment;
|
import com.android.settings.core.InstrumentedFragment;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class CryptKeeperConfirm extends InstrumentedFragment {
|
public class CryptKeeperConfirm extends InstrumentedFragment {
|
||||||
@@ -88,12 +87,7 @@ public class CryptKeeperConfirm extends InstrumentedFragment {
|
|||||||
IStorageManager storageManager = IStorageManager.Stub.asInterface(service);
|
IStorageManager storageManager = IStorageManager.Stub.asInterface(service);
|
||||||
try {
|
try {
|
||||||
Bundle args = getIntent().getExtras();
|
Bundle args = getIntent().getExtras();
|
||||||
// TODO(b/120484642): Update vold to accept a password as a byte array
|
storageManager.encryptStorage(args.getInt("type", -1), args.getString("password"));
|
||||||
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);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("CryptKeeper", "Error while encrypting...", 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.RestrictedLockUtils.EnforcedAdmin;
|
||||||
import com.android.settingslib.RestrictedPreference;
|
import com.android.settingslib.RestrictedPreference;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChooseLockGeneric extends SettingsActivity {
|
public class ChooseLockGeneric extends SettingsActivity {
|
||||||
@@ -145,7 +144,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
private int mEncryptionRequestQuality;
|
private int mEncryptionRequestQuality;
|
||||||
private boolean mEncryptionRequestDisabled;
|
private boolean mEncryptionRequestDisabled;
|
||||||
private boolean mForChangeCredRequiredForBoot = false;
|
private boolean mForChangeCredRequiredForBoot = false;
|
||||||
private byte[] mUserPassword;
|
private String mUserPassword;
|
||||||
private LockPatternUtils mLockPatternUtils;
|
private LockPatternUtils mLockPatternUtils;
|
||||||
private FingerprintManager mFingerprintManager;
|
private FingerprintManager mFingerprintManager;
|
||||||
private int mUserId;
|
private int mUserId;
|
||||||
@@ -185,7 +184,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
.getBooleanExtra(CONFIRM_CREDENTIALS, true);
|
.getBooleanExtra(CONFIRM_CREDENTIALS, true);
|
||||||
if (getActivity() instanceof ChooseLockGeneric.InternalActivity) {
|
if (getActivity() instanceof ChooseLockGeneric.InternalActivity) {
|
||||||
mPasswordConfirmed = !confirmCredentials;
|
mPasswordConfirmed = !confirmCredentials;
|
||||||
mUserPassword = getActivity().getIntent().getByteArrayExtra(
|
mUserPassword = getActivity().getIntent().getStringExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
}
|
}
|
||||||
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
|
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
|
||||||
@@ -207,7 +206,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
mEncryptionRequestDisabled = savedInstanceState.getBoolean(
|
mEncryptionRequestDisabled = savedInstanceState.getBoolean(
|
||||||
ENCRYPT_REQUESTED_DISABLED);
|
ENCRYPT_REQUESTED_DISABLED);
|
||||||
if (mUserPassword == null) {
|
if (mUserPassword == null) {
|
||||||
mUserPassword = savedInstanceState.getByteArray(
|
mUserPassword = savedInstanceState.getString(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -352,12 +351,10 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
mWaitingForConfirmation = false;
|
mWaitingForConfirmation = false;
|
||||||
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
|
if (requestCode == CONFIRM_EXISTING_REQUEST && resultCode == Activity.RESULT_OK) {
|
||||||
mPasswordConfirmed = true;
|
mPasswordConfirmed = true;
|
||||||
mUserPassword = data != null
|
mUserPassword = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
? data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD)
|
|
||||||
: null;
|
|
||||||
updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
updatePreferencesOrFinish(false /* isRecreatingActivity */);
|
||||||
if (mForChangeCredRequiredForBoot) {
|
if (mForChangeCredRequiredForBoot) {
|
||||||
if (!(mUserPassword == null || mUserPassword.length == 0)) {
|
if (!TextUtils.isEmpty(mUserPassword)) {
|
||||||
maybeEnableEncryption(
|
maybeEnableEncryption(
|
||||||
mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
|
mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId), false);
|
||||||
} else {
|
} else {
|
||||||
@@ -417,7 +414,7 @@ public class ChooseLockGeneric extends SettingsActivity {
|
|||||||
outState.putInt(ENCRYPT_REQUESTED_QUALITY, mEncryptionRequestQuality);
|
outState.putInt(ENCRYPT_REQUESTED_QUALITY, mEncryptionRequestQuality);
|
||||||
outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled);
|
outState.putBoolean(ENCRYPT_REQUESTED_DISABLED, mEncryptionRequestDisabled);
|
||||||
if (mUserPassword != null) {
|
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);
|
setPreferenceSummary(ScreenLockType.MANAGED, R.string.secure_lock_encryption_warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Intent getLockManagedPasswordIntent(byte[] password) {
|
protected Intent getLockManagedPasswordIntent(String password) {
|
||||||
return mManagedPasswordProvider.createIntent(false, password);
|
return mManagedPasswordProvider.createIntent(false, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,7 +70,6 @@ import com.android.settings.widget.ImeAwareEditText;
|
|||||||
import com.android.setupwizardlib.GlifLayout;
|
import com.android.setupwizardlib.GlifLayout;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChooseLockPassword extends SettingsActivity {
|
public class ChooseLockPassword extends SettingsActivity {
|
||||||
@@ -131,7 +130,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntentBuilder setPassword(byte[] password) {
|
public IntentBuilder setPassword(String password) {
|
||||||
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
|
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, password);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -177,8 +176,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
private static final String KEY_CURRENT_PASSWORD = "current_password";
|
private static final String KEY_CURRENT_PASSWORD = "current_password";
|
||||||
private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
|
private static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
|
||||||
|
|
||||||
private byte[] mCurrentPassword;
|
private String mCurrentPassword;
|
||||||
private byte[] mChosenPassword;
|
private String mChosenPassword;
|
||||||
private boolean mHasChallenge;
|
private boolean mHasChallenge;
|
||||||
private long mChallenge;
|
private long mChallenge;
|
||||||
private ImeAwareEditText mPasswordEntry;
|
private ImeAwareEditText mPasswordEntry;
|
||||||
@@ -209,7 +208,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
private GlifLayout mLayout;
|
private GlifLayout mLayout;
|
||||||
protected boolean mForFingerprint;
|
protected boolean mForFingerprint;
|
||||||
|
|
||||||
private byte[] mFirstPin;
|
private String mFirstPin;
|
||||||
private RecyclerView mPasswordRestrictionView;
|
private RecyclerView mPasswordRestrictionView;
|
||||||
protected boolean mIsAlphaMode;
|
protected boolean mIsAlphaMode;
|
||||||
protected Button mSkipButton;
|
protected Button mSkipButton;
|
||||||
@@ -229,7 +228,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
private static final int MIN_NUMBER_IN_PASSWORD = 4;
|
private static final int MIN_NUMBER_IN_PASSWORD = 4;
|
||||||
private static final int MIN_NON_LETTER_IN_PASSWORD = 5;
|
private static final int MIN_NON_LETTER_IN_PASSWORD = 5;
|
||||||
|
|
||||||
// Error code returned from {@link #validatePassword(byte[])}.
|
// Error code returned from {@link #validatePassword(String)}.
|
||||||
static final int NO_ERROR = 0;
|
static final int NO_ERROR = 0;
|
||||||
static final int CONTAIN_INVALID_CHARACTERS = 1 << 0;
|
static final int CONTAIN_INVALID_CHARACTERS = 1 << 0;
|
||||||
static final int TOO_SHORT = 1 << 1;
|
static final int TOO_SHORT = 1 << 1;
|
||||||
@@ -351,13 +350,12 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
SaveAndFinishWorker w = new SaveAndFinishWorker();
|
SaveAndFinishWorker w = new SaveAndFinishWorker();
|
||||||
final boolean required = getActivity().getIntent().getBooleanExtra(
|
final boolean required = getActivity().getIntent().getBooleanExtra(
|
||||||
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
|
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
|
||||||
byte[] currentBytes = intent.getByteArrayExtra(
|
String current = intent.getStringExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
|
|
||||||
w.setBlocking(true);
|
w.setBlocking(true);
|
||||||
w.setListener(this);
|
w.setListener(this);
|
||||||
w.start(mChooseLockSettingsHelper.utils(), required, false, 0,
|
w.start(mChooseLockSettingsHelper.utils(), required,
|
||||||
currentBytes, currentBytes, mRequestedQuality, mUserId);
|
false, 0, current, current, mRequestedQuality, mUserId);
|
||||||
}
|
}
|
||||||
mTextChangedHandler = new TextChangedHandler();
|
mTextChangedHandler = new TextChangedHandler();
|
||||||
}
|
}
|
||||||
@@ -418,8 +416,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
Intent intent = getActivity().getIntent();
|
Intent intent = getActivity().getIntent();
|
||||||
final boolean confirmCredentials = intent.getBooleanExtra(
|
final boolean confirmCredentials = intent.getBooleanExtra(
|
||||||
ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
|
ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
|
||||||
mCurrentPassword = intent.getByteArrayExtra(
|
mCurrentPassword = intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
|
||||||
mHasChallenge = intent.getBooleanExtra(
|
mHasChallenge = intent.getBooleanExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
|
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
|
||||||
mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
|
mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
|
||||||
@@ -431,9 +428,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
mUserId);
|
mUserId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// restore from previous state
|
// restore from previous state
|
||||||
mFirstPin = savedInstanceState.getByteArray(KEY_FIRST_PIN);
|
mFirstPin = savedInstanceState.getString(KEY_FIRST_PIN);
|
||||||
final String state = savedInstanceState.getString(KEY_UI_STAGE);
|
final String state = savedInstanceState.getString(KEY_UI_STAGE);
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
mUiStage = Stage.valueOf(state);
|
mUiStage = Stage.valueOf(state);
|
||||||
@@ -441,7 +437,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentPassword == null) {
|
if (mCurrentPassword == null) {
|
||||||
mCurrentPassword = savedInstanceState.getByteArray(KEY_CURRENT_PASSWORD);
|
mCurrentPassword = savedInstanceState.getString(KEY_CURRENT_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-attach to the exiting worker if there is one.
|
// Re-attach to the exiting worker if there is one.
|
||||||
@@ -540,8 +536,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
outState.putString(KEY_UI_STAGE, mUiStage.name());
|
outState.putString(KEY_UI_STAGE, mUiStage.name());
|
||||||
outState.putByteArray(KEY_FIRST_PIN, mFirstPin);
|
outState.putString(KEY_FIRST_PIN, mFirstPin);
|
||||||
outState.putByteArray(KEY_CURRENT_PASSWORD, mCurrentPassword);
|
outState.putString(KEY_CURRENT_PASSWORD, mCurrentPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -554,7 +550,7 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
getActivity().setResult(RESULT_FINISHED);
|
getActivity().setResult(RESULT_FINISHED);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
} else {
|
} else {
|
||||||
mCurrentPassword = data.getByteArrayExtra(
|
mCurrentPassword = data.getStringExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -645,22 +641,22 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
* @param password the raw password the user typed in
|
* @param password the raw password the user typed in
|
||||||
* @return the validation result.
|
* @return the validation result.
|
||||||
*/
|
*/
|
||||||
int validatePassword(byte[] password) {
|
private int validatePassword(String password) {
|
||||||
int errorCode = NO_ERROR;
|
int errorCode = NO_ERROR;
|
||||||
final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
|
final PasswordMetrics metrics = PasswordMetrics.computeForPassword(password);
|
||||||
|
|
||||||
|
|
||||||
if (password == null || password.length < mPasswordMinLength) {
|
if (password.length() < mPasswordMinLength) {
|
||||||
if (mPasswordMinLength > mPasswordMinLengthToFulfillAllPolicies) {
|
if (mPasswordMinLength > mPasswordMinLengthToFulfillAllPolicies) {
|
||||||
errorCode |= TOO_SHORT;
|
errorCode |= TOO_SHORT;
|
||||||
}
|
}
|
||||||
} else if (password.length > mPasswordMaxLength) {
|
} else if (password.length() > mPasswordMaxLength) {
|
||||||
errorCode |= TOO_LONG;
|
errorCode |= TOO_LONG;
|
||||||
} else {
|
} else {
|
||||||
// The length requirements are fulfilled.
|
// The length requirements are fulfilled.
|
||||||
final int dpmQuality = mLockPatternUtils.getRequestedPasswordQuality(mUserId);
|
final int dpmQuality = mLockPatternUtils.getRequestedPasswordQuality(mUserId);
|
||||||
if (dpmQuality == PASSWORD_QUALITY_NUMERIC_COMPLEX &&
|
if (dpmQuality == PASSWORD_QUALITY_NUMERIC_COMPLEX &&
|
||||||
metrics.numeric == password.length) {
|
metrics.numeric == password.length()) {
|
||||||
// Check for repeated characters or sequences (e.g. '1234', '0000', '2468')
|
// Check for repeated characters or sequences (e.g. '1234', '0000', '2468')
|
||||||
// if DevicePolicyManager requires a complex numeric password. There can be
|
// if DevicePolicyManager requires a complex numeric password. There can be
|
||||||
// two cases in the UI: 1. User chooses to enroll a PIN, 2. User chooses to
|
// two cases in the UI: 1. User chooses to enroll a PIN, 2. User chooses to
|
||||||
@@ -679,8 +675,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allow non-control Latin-1 characters only.
|
// Allow non-control Latin-1 characters only.
|
||||||
for (int i = 0; i < password.length; i++) {
|
for (int i = 0; i < password.length(); i++) {
|
||||||
char c = (char) password[i];
|
char c = password.charAt(i);
|
||||||
if (c < 32 || c > 127) {
|
if (c < 32 || c > 127) {
|
||||||
errorCode |= CONTAIN_INVALID_CHARACTERS;
|
errorCode |= CONTAIN_INVALID_CHARACTERS;
|
||||||
break;
|
break;
|
||||||
@@ -750,9 +746,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
|
|
||||||
public void handleNext() {
|
public void handleNext() {
|
||||||
if (mSaveAndFinishWorker != null) return;
|
if (mSaveAndFinishWorker != null) return;
|
||||||
// TODO(b/120484642): This is a point of entry for passwords from the UI
|
mChosenPassword = mPasswordEntry.getText().toString();
|
||||||
mChosenPassword = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
|
if (TextUtils.isEmpty(mChosenPassword)) {
|
||||||
if (mChosenPassword == null || mChosenPassword.length == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mUiStage == Stage.Introduction) {
|
if (mUiStage == Stage.Introduction) {
|
||||||
@@ -760,11 +755,9 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
mFirstPin = mChosenPassword;
|
mFirstPin = mChosenPassword;
|
||||||
mPasswordEntry.setText("");
|
mPasswordEntry.setText("");
|
||||||
updateStage(Stage.NeedToConfirm);
|
updateStage(Stage.NeedToConfirm);
|
||||||
} else {
|
|
||||||
Arrays.fill(mChosenPassword, (byte) 0);
|
|
||||||
}
|
}
|
||||||
} else if (mUiStage == Stage.NeedToConfirm) {
|
} else if (mUiStage == Stage.NeedToConfirm) {
|
||||||
if (Arrays.equals(mFirstPin, mChosenPassword)) {
|
if (mFirstPin.equals(mChosenPassword)) {
|
||||||
startSaveAndFinish();
|
startSaveAndFinish();
|
||||||
} else {
|
} else {
|
||||||
CharSequence tmp = mPasswordEntry.getText();
|
CharSequence tmp = mPasswordEntry.getText();
|
||||||
@@ -772,7 +765,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
Selection.setSelection((Spannable) tmp, 0, tmp.length());
|
Selection.setSelection((Spannable) tmp, 0, tmp.length());
|
||||||
}
|
}
|
||||||
updateStage(Stage.ConfirmWrong);
|
updateStage(Stage.ConfirmWrong);
|
||||||
Arrays.fill(mChosenPassword, (byte) 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -883,8 +875,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
*/
|
*/
|
||||||
protected void updateUi() {
|
protected void updateUi() {
|
||||||
final boolean canInput = mSaveAndFinishWorker == null;
|
final boolean canInput = mSaveAndFinishWorker == null;
|
||||||
byte[] password = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
|
String password = mPasswordEntry.getText().toString();
|
||||||
final int length = password.length;
|
final int length = password.length();
|
||||||
if (mUiStage == Stage.Introduction) {
|
if (mUiStage == Stage.Introduction) {
|
||||||
mPasswordRestrictionView.setVisibility(View.VISIBLE);
|
mPasswordRestrictionView.setVisibility(View.VISIBLE);
|
||||||
final int errorCode = validatePassword(password);
|
final int errorCode = validatePassword(password);
|
||||||
@@ -912,7 +904,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
|
|
||||||
setNextText(mUiStage.buttonText);
|
setNextText(mUiStage.buttonText);
|
||||||
mPasswordEntryInputDisabler.setInputEnabled(canInput);
|
mPasswordEntryInputDisabler.setInputEnabled(canInput);
|
||||||
Arrays.fill(password, (byte) 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int toVisibility(boolean visibleOrGone) {
|
private int toVisibility(boolean visibleOrGone) {
|
||||||
@@ -971,18 +962,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData) {
|
public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData) {
|
||||||
getActivity().setResult(RESULT_FINISHED, resultData);
|
getActivity().setResult(RESULT_FINISHED, resultData);
|
||||||
|
|
||||||
if (mChosenPassword != null) {
|
|
||||||
Arrays.fill(mChosenPassword, (byte) 0);
|
|
||||||
}
|
|
||||||
if (mCurrentPassword != null) {
|
|
||||||
Arrays.fill(mCurrentPassword, (byte) 0);
|
|
||||||
}
|
|
||||||
if (mFirstPin != null) {
|
|
||||||
Arrays.fill(mFirstPin, (byte) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
mPasswordEntry.setText("");
|
|
||||||
|
|
||||||
if (!wasSecureBefore) {
|
if (!wasSecureBefore) {
|
||||||
Intent intent = getRedactionInterstitialIntent(getActivity());
|
Intent intent = getRedactionInterstitialIntent(getActivity());
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
@@ -1020,13 +999,13 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
|
|
||||||
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
|
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
|
||||||
|
|
||||||
private byte[] mChosenPassword;
|
private String mChosenPassword;
|
||||||
private byte[] mCurrentPassword;
|
private String mCurrentPassword;
|
||||||
private int mRequestedQuality;
|
private int mRequestedQuality;
|
||||||
|
|
||||||
public void start(LockPatternUtils utils, boolean required,
|
public void start(LockPatternUtils utils, boolean required,
|
||||||
boolean hasChallenge, long challenge,
|
boolean hasChallenge, long challenge,
|
||||||
byte[] chosenPassword, byte[] currentPassword, int requestedQuality, int userId) {
|
String chosenPassword, String currentPassword, int requestedQuality, int userId) {
|
||||||
prepare(utils, required, hasChallenge, challenge, userId);
|
prepare(utils, required, hasChallenge, challenge, userId);
|
||||||
|
|
||||||
mChosenPassword = chosenPassword;
|
mChosenPassword = chosenPassword;
|
||||||
|
@@ -52,7 +52,6 @@ import com.android.setupwizardlib.GlifLayout;
|
|||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -112,7 +111,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntentBuilder setPattern(byte[] pattern) {
|
public IntentBuilder setPattern(String pattern) {
|
||||||
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
|
mIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD, pattern);
|
||||||
return this;
|
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 static final String FRAGMENT_TAG_SAVE_AND_FINISH = "save_and_finish_worker";
|
||||||
|
|
||||||
private byte[] mCurrentPattern;
|
private String mCurrentPattern;
|
||||||
private boolean mHasChallenge;
|
private boolean mHasChallenge;
|
||||||
private long mChallenge;
|
private long mChallenge;
|
||||||
protected TextView mTitleText;
|
protected TextView mTitleText;
|
||||||
@@ -209,7 +208,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
getActivity().setResult(RESULT_FINISHED);
|
getActivity().setResult(RESULT_FINISHED);
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
} else {
|
} else {
|
||||||
mCurrentPattern = data.getByteArrayExtra(
|
mCurrentPattern = data.getStringExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,12 +441,12 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
SaveAndFinishWorker w = new SaveAndFinishWorker();
|
SaveAndFinishWorker w = new SaveAndFinishWorker();
|
||||||
final boolean required = getActivity().getIntent().getBooleanExtra(
|
final boolean required = getActivity().getIntent().getBooleanExtra(
|
||||||
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
|
EncryptionInterstitial.EXTRA_REQUIRE_PASSWORD, true);
|
||||||
byte[] current = intent.getByteArrayExtra(
|
String current = intent.getStringExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
w.setBlocking(true);
|
w.setBlocking(true);
|
||||||
w.setListener(this);
|
w.setListener(this);
|
||||||
w.start(mChooseLockSettingsHelper.utils(), required,
|
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);
|
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
|
||||||
mForFingerprint = intent.getBooleanExtra(
|
mForFingerprint = intent.getBooleanExtra(
|
||||||
@@ -508,8 +507,7 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
final boolean confirmCredentials = getActivity().getIntent()
|
final boolean confirmCredentials = getActivity().getIntent()
|
||||||
.getBooleanExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
|
.getBooleanExtra(ChooseLockGeneric.CONFIRM_CREDENTIALS, true);
|
||||||
Intent intent = getActivity().getIntent();
|
Intent intent = getActivity().getIntent();
|
||||||
mCurrentPattern =
|
mCurrentPattern = intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
|
||||||
mHasChallenge = intent.getBooleanExtra(
|
mHasChallenge = intent.getBooleanExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
|
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
|
||||||
mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
|
mChallenge = intent.getLongExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
|
||||||
@@ -532,13 +530,13 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// restore from previous state
|
// restore from previous state
|
||||||
final byte[] pattern = savedInstanceState.getByteArray(KEY_PATTERN_CHOICE);
|
final String patternString = savedInstanceState.getString(KEY_PATTERN_CHOICE);
|
||||||
if (pattern != null) {
|
if (patternString != null) {
|
||||||
mChosenPattern = LockPatternUtils.byteArrayToPattern(pattern);
|
mChosenPattern = LockPatternUtils.stringToPattern(patternString);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentPattern == null) {
|
if (mCurrentPattern == null) {
|
||||||
mCurrentPattern = savedInstanceState.getByteArray(KEY_CURRENT_PATTERN);
|
mCurrentPattern = savedInstanceState.getString(KEY_CURRENT_PATTERN);
|
||||||
}
|
}
|
||||||
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
|
updateStage(Stage.values()[savedInstanceState.getInt(KEY_UI_STAGE)]);
|
||||||
|
|
||||||
@@ -634,12 +632,13 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
|
|
||||||
outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
|
outState.putInt(KEY_UI_STAGE, mUiStage.ordinal());
|
||||||
if (mChosenPattern != null) {
|
if (mChosenPattern != null) {
|
||||||
outState.putByteArray(KEY_PATTERN_CHOICE,
|
outState.putString(KEY_PATTERN_CHOICE,
|
||||||
LockPatternUtils.patternToByteArray(mChosenPattern));
|
LockPatternUtils.patternToString(mChosenPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentPattern != null) {
|
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) {
|
public void onChosenLockSaveFinished(boolean wasSecureBefore, Intent resultData) {
|
||||||
getActivity().setResult(RESULT_FINISHED, resultData);
|
getActivity().setResult(RESULT_FINISHED, resultData);
|
||||||
|
|
||||||
if (mCurrentPattern != null) {
|
|
||||||
Arrays.fill(mCurrentPattern, (byte) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wasSecureBefore) {
|
if (!wasSecureBefore) {
|
||||||
Intent intent = getRedactionInterstitialIntent(getActivity());
|
Intent intent = getRedactionInterstitialIntent(getActivity());
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
@@ -803,12 +798,12 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
|
public static class SaveAndFinishWorker extends SaveChosenLockWorkerBase {
|
||||||
|
|
||||||
private List<LockPatternView.Cell> mChosenPattern;
|
private List<LockPatternView.Cell> mChosenPattern;
|
||||||
private byte[] mCurrentPattern;
|
private String mCurrentPattern;
|
||||||
private boolean mLockVirgin;
|
private boolean mLockVirgin;
|
||||||
|
|
||||||
public void start(LockPatternUtils utils, boolean credentialRequired,
|
public void start(LockPatternUtils utils, boolean credentialRequired,
|
||||||
boolean hasChallenge, long challenge,
|
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);
|
prepare(utils, credentialRequired, hasChallenge, challenge, userId);
|
||||||
|
|
||||||
mCurrentPattern = currentPattern;
|
mCurrentPattern = currentPattern;
|
||||||
|
@@ -332,9 +332,8 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/120484642): This is a point of entry for passwords from the UI
|
final String pin = mPasswordEntry.getText().toString();
|
||||||
final byte[] pin = LockPatternUtils.charSequenceToByteArray(mPasswordEntry.getText());
|
if (TextUtils.isEmpty(pin)) {
|
||||||
if (pin == null || pin.length == 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,7 +359,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
return getActivity() instanceof ConfirmLockPassword.InternalActivity;
|
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(
|
long challenge = getActivity().getIntent().getLongExtra(
|
||||||
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
|
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, 0);
|
||||||
final int localEffectiveUserId = mEffectiveUserId;
|
final int localEffectiveUserId = mEffectiveUserId;
|
||||||
@@ -391,7 +390,7 @@ public class ConfirmLockPassword extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
onVerifyCallback);
|
onVerifyCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startCheckPassword(final byte[] pin, final Intent intent) {
|
private void startCheckPassword(final String pin, final Intent intent) {
|
||||||
final int localEffectiveUserId = mEffectiveUserId;
|
final int localEffectiveUserId = mEffectiveUserId;
|
||||||
mPendingLockCheck = LockPatternChecker.checkPassword(
|
mPendingLockCheck = LockPatternChecker.checkPassword(
|
||||||
mLockPatternUtils,
|
mLockPatternUtils,
|
||||||
|
@@ -462,7 +462,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
mLockPatternUtils, pattern, challenge, localUserId,
|
mLockPatternUtils, pattern, challenge, localUserId,
|
||||||
onVerifyCallback)
|
onVerifyCallback)
|
||||||
: LockPatternChecker.verifyTiedProfileChallenge(
|
: LockPatternChecker.verifyTiedProfileChallenge(
|
||||||
mLockPatternUtils, LockPatternUtils.patternToByteArray(pattern),
|
mLockPatternUtils, LockPatternUtils.patternToString(pattern),
|
||||||
true, challenge, localUserId, onVerifyCallback);
|
true, challenge, localUserId, onVerifyCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +487,7 @@ public class ConfirmLockPattern extends ConfirmDeviceCredentialBaseActivity {
|
|||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE,
|
||||||
StorageManager.CRYPT_TYPE_PATTERN);
|
StorageManager.CRYPT_TYPE_PATTERN);
|
||||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
|
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
|
||||||
LockPatternUtils.patternToByteArray(pattern));
|
LockPatternUtils.patternToString(pattern));
|
||||||
}
|
}
|
||||||
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
|
mCredentialCheckResultTracker.setResult(matched, intent, timeoutMs,
|
||||||
localEffectiveUserId);
|
localEffectiveUserId);
|
||||||
|
@@ -61,7 +61,7 @@ public class ManagedLockPasswordProvider {
|
|||||||
* @param password Current lock password.
|
* @param password Current lock password.
|
||||||
* @return Intent that should update lock password to a managed 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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -172,7 +172,7 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
|
|||||||
|
|
||||||
if (helper.utils().getKeyguardStoredPasswordQuality(UserHandle.myUserId())
|
if (helper.utils().getKeyguardStoredPasswordQuality(UserHandle.myUserId())
|
||||||
== DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
== DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
||||||
showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "".getBytes());
|
showFinalConfirmation(StorageManager.CRYPT_TYPE_DEFAULT, "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,14 +192,14 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
|
|||||||
// confirmation prompt; otherwise, go back to the initial state.
|
// confirmation prompt; otherwise, go back to the initial state.
|
||||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||||
int type = data.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, -1);
|
int type = data.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, -1);
|
||||||
byte[] password = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
if (!(password == null || password.length == 0)) {
|
if (!TextUtils.isEmpty(password)) {
|
||||||
showFinalConfirmation(type, 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 preference = new Preference(getPreferenceManager().getContext());
|
||||||
preference.setFragment(CryptKeeperConfirm.class.getName());
|
preference.setFragment(CryptKeeperConfirm.class.getName());
|
||||||
preference.setTitle(R.string.crypt_keeper_confirm_title);
|
preference.setTitle(R.string.crypt_keeper_confirm_title);
|
||||||
@@ -207,16 +207,16 @@ public class CryptKeeperSettings extends InstrumentedPreferenceFragment {
|
|||||||
((SettingsActivity) getActivity()).onPreferenceStartFragment(null, preference);
|
((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();
|
Activity activity = getActivity();
|
||||||
DevicePolicyManager dpm = (DevicePolicyManager)
|
DevicePolicyManager dpm = (DevicePolicyManager)
|
||||||
activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
if (dpm.getDoNotAskCredentialsOnBoot()) {
|
if (dpm.getDoNotAskCredentialsOnBoot()) {
|
||||||
preference.getExtras().putInt(TYPE, StorageManager.CRYPT_TYPE_DEFAULT);
|
preference.getExtras().putInt(TYPE, StorageManager.CRYPT_TYPE_DEFAULT);
|
||||||
preference.getExtras().putByteArray(PASSWORD, "".getBytes());
|
preference.getExtras().putString(PASSWORD, "");
|
||||||
} else {
|
} else {
|
||||||
preference.getExtras().putInt(TYPE, type);
|
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 RestrictedSwitchPreference mUnifyProfile;
|
||||||
|
|
||||||
private byte[] mCurrentDevicePassword;
|
|
||||||
private byte[] mCurrentProfilePassword;
|
private String mCurrentDevicePassword;
|
||||||
|
private String mCurrentProfilePassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
@@ -138,13 +139,13 @@ public class LockUnificationPreferenceController extends AbstractPreferenceContr
|
|||||||
} else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
|
} else if (requestCode == UNIFY_LOCK_CONFIRM_DEVICE_REQUEST
|
||||||
&& resultCode == Activity.RESULT_OK) {
|
&& resultCode == Activity.RESULT_OK) {
|
||||||
mCurrentDevicePassword =
|
mCurrentDevicePassword =
|
||||||
data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
launchConfirmProfileLockForUnification();
|
launchConfirmProfileLockForUnification();
|
||||||
return true;
|
return true;
|
||||||
} else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
|
} else if (requestCode == UNIFY_LOCK_CONFIRM_PROFILE_REQUEST
|
||||||
&& resultCode == Activity.RESULT_OK) {
|
&& resultCode == Activity.RESULT_OK) {
|
||||||
mCurrentProfilePassword =
|
mCurrentProfilePassword =
|
||||||
data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||||
unifyLocks();
|
unifyLocks();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -191,7 +192,7 @@ public class LockUnificationPreferenceController extends AbstractPreferenceContr
|
|||||||
mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId);
|
mLockPatternUtils.getKeyguardStoredPasswordQuality(mProfileChallengeUserId);
|
||||||
if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
|
if (profileQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
|
||||||
mLockPatternUtils.saveLockPattern(
|
mLockPatternUtils.saveLockPattern(
|
||||||
LockPatternUtils.byteArrayToPattern(mCurrentProfilePassword),
|
LockPatternUtils.stringToPattern(mCurrentProfilePassword),
|
||||||
mCurrentDevicePassword, MY_USER_ID);
|
mCurrentDevicePassword, MY_USER_ID);
|
||||||
} else {
|
} else {
|
||||||
mLockPatternUtils.saveLockPassword(
|
mLockPatternUtils.saveLockPassword(
|
||||||
|
@@ -65,7 +65,7 @@ public class ChooseLockPasswordTest {
|
|||||||
@Test
|
@Test
|
||||||
public void intentBuilder_setPassword_shouldAddExtras() {
|
public void intentBuilder_setPassword_shouldAddExtras() {
|
||||||
Intent intent = new IntentBuilder(application)
|
Intent intent = new IntentBuilder(application)
|
||||||
.setPassword("password".getBytes())
|
.setPassword("password")
|
||||||
.setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
|
.setPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC)
|
||||||
.setPasswordLengthRange(123, 456)
|
.setPasswordLengthRange(123, 456)
|
||||||
.setUserId(123)
|
.setUserId(123)
|
||||||
@@ -74,9 +74,9 @@ public class ChooseLockPasswordTest {
|
|||||||
assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
|
assertThat(intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, true))
|
||||||
.named("EXTRA_KEY_HAS_CHALLENGE")
|
.named("EXTRA_KEY_HAS_CHALLENGE")
|
||||||
.isFalse();
|
.isFalse();
|
||||||
assertThat(intent.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
|
assertThat(intent.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
|
||||||
.named("EXTRA_KEY_PASSWORD")
|
.named("EXTRA_KEY_PASSWORD")
|
||||||
.isEqualTo("password".getBytes());
|
.isEqualTo("password");
|
||||||
assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0))
|
assertThat(intent.getIntExtra(ChooseLockPassword.PASSWORD_MIN_KEY, 0))
|
||||||
.named("PASSWORD_MIN_KEY")
|
.named("PASSWORD_MIN_KEY")
|
||||||
.isEqualTo(123);
|
.isEqualTo(123);
|
||||||
|
@@ -58,7 +58,7 @@ public class ChooseLockPatternTest {
|
|||||||
@Test
|
@Test
|
||||||
public void intentBuilder_setPattern_shouldAddExtras() {
|
public void intentBuilder_setPattern_shouldAddExtras() {
|
||||||
Intent intent = new IntentBuilder(application)
|
Intent intent = new IntentBuilder(application)
|
||||||
.setPattern("pattern".getBytes())
|
.setPattern("pattern")
|
||||||
.setUserId(123)
|
.setUserId(123)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
@@ -67,9 +67,9 @@ public class ChooseLockPatternTest {
|
|||||||
.named("EXTRA_KEY_HAS_CHALLENGE")
|
.named("EXTRA_KEY_HAS_CHALLENGE")
|
||||||
.isFalse();
|
.isFalse();
|
||||||
assertThat(intent
|
assertThat(intent
|
||||||
.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
|
.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD))
|
||||||
.named("EXTRA_KEY_PASSWORD")
|
.named("EXTRA_KEY_PASSWORD")
|
||||||
.isEqualTo("pattern".getBytes());
|
.isEqualTo("pattern");
|
||||||
assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
|
assertThat(intent.getIntExtra(Intent.EXTRA_USER_ID, 0))
|
||||||
.named("EXTRA_USER_ID")
|
.named("EXTRA_USER_ID")
|
||||||
.isEqualTo(123);
|
.isEqualTo(123);
|
||||||
|
Reference in New Issue
Block a user