Commit ba1691a4 authored by zea's avatar zea Committed by Commit bot

[Sync] Fix passphrase prompt for legacy accounts

Make sure that we always include the dashboard reset link in any passphrase
prompt. Also ensure we use the term "sync passphrase" rather than "google
password". Lastly, use the passphrase time if its available.

BUG=481224

Review URL: https://codereview.chromium.org/1101373002

Cr-Commit-Position: refs/heads/master@{#327209}
parent 9088a724
......@@ -502,15 +502,7 @@ public class AccountManagementFragment extends PreferenceFragment
}
if (profileSyncService.isPassphraseRequiredForDecryption()) {
switch (profileSyncService.getPassphraseType()) {
case IMPLICIT_PASSPHRASE:
return res.getString(R.string.sync_need_password);
case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentionally.
case CUSTOM_PASSPHRASE:
return res.getString(R.string.sync_need_passphrase);
default:
break;
}
return res.getString(R.string.sync_need_passphrase);
}
}
......
......@@ -72,10 +72,7 @@ public class SyncNotificationController implements ProfileSyncService.SyncStateC
} else if (mProfileSyncService.isSyncInitialized()
&& mProfileSyncService.isPassphraseRequiredForDecryption()) {
switch (mProfileSyncService.getPassphraseType()) {
case IMPLICIT_PASSPHRASE:
message = R.string.sync_need_password;
intent = createPasswordIntent();
break;
case IMPLICIT_PASSPHRASE: // Falling through intentionally.
case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentionally.
case CUSTOM_PASSPHRASE:
message = R.string.sync_need_passphrase;
......
......@@ -76,63 +76,56 @@ public class PassphraseDialogFragment extends DialogFragment implements OnClickL
LayoutInflater inflater = getActivity().getLayoutInflater();
View v = inflater.inflate(R.layout.sync_enter_passphrase, null);
boolean isGaia = getArguments().getBoolean(ARG_IS_GAIA);
TextView promptText = (TextView) v.findViewById(R.id.prompt_text);
final EditText passphrase = (EditText) v.findViewById(R.id.passphrase);
final Context context = passphrase.getContext();
TextView resetText = (TextView) v.findViewById(R.id.reset_text);
ProfileSyncService profileSyncService = ProfileSyncService.get(context);
String accountName = profileSyncService.getCurrentSignedInAccountText() + "\n\n";
if (isGaia) {
promptText.setText(accountName + context.getText(
R.string.sync_enter_google_passphrase));
passphrase.setHint(R.string.sync_enter_google_passphrase_hint);
} else {
if (profileSyncService.hasExplicitPassphraseTime()) {
resetText.setText(SpanApplier.applySpans(
context.getString(R.string.sync_passphrase_reset_instructions),
new SpanInfo("<link>", "</link>", new ClickableSpan() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
context.getText(R.string.sync_dashboard_url).toString()));
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
context.getPackageName());
intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
intent.setPackage(context.getPackageName());
context.startActivity(intent);
Activity activity = getActivity();
if (activity != null) activity.finish();
}
})));
resetText.setMovementMethod(LinkMovementMethod.getInstance());
resetText.setVisibility(View.VISIBLE);
PassphraseType passphraseType = profileSyncService.getPassphraseType();
switch (passphraseType) {
case FROZEN_IMPLICIT_PASSPHRASE:
promptText.setText(accountName + profileSyncService
.getSyncEnterGooglePassphraseBodyWithDateText());
break;
case CUSTOM_PASSPHRASE:
promptText.setText(accountName + profileSyncService
.getSyncEnterCustomPassphraseBodyWithDateText());
break;
case IMPLICIT_PASSPHRASE: // Falling through intentionally.
case KEYSTORE_PASSPHRASE: // Falling through intentionally.
default:
Log.w(TAG, "Found incorrect passphrase type "
+ passphraseType
+ ". Falling back to default string.");
promptText.setText(accountName
+ profileSyncService.getSyncEnterCustomPassphraseBodyText());
break;
}
} else {
promptText.setText(accountName
+ profileSyncService.getSyncEnterCustomPassphraseBodyText());
resetText.setText(SpanApplier.applySpans(
context.getString(R.string.sync_passphrase_reset_instructions),
new SpanInfo("<link>", "</link>", new ClickableSpan() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
context.getText(R.string.sync_dashboard_url).toString()));
intent.putExtra(Browser.EXTRA_APPLICATION_ID,
context.getPackageName());
intent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
intent.setPackage(context.getPackageName());
context.startActivity(intent);
Activity activity = getActivity();
if (activity != null) activity.finish();
}
})));
resetText.setMovementMethod(LinkMovementMethod.getInstance());
resetText.setVisibility(View.VISIBLE);
PassphraseType passphraseType = profileSyncService.getPassphraseType();
if (profileSyncService.hasExplicitPassphraseTime()) {
switch (passphraseType) {
case FROZEN_IMPLICIT_PASSPHRASE:
promptText.setText(accountName + profileSyncService
.getSyncEnterGooglePassphraseBodyWithDateText());
break;
case CUSTOM_PASSPHRASE:
promptText.setText(accountName + profileSyncService
.getSyncEnterCustomPassphraseBodyWithDateText());
break;
case IMPLICIT_PASSPHRASE: // Falling through intentionally.
case KEYSTORE_PASSPHRASE: // Falling through intentionally.
default:
Log.w(TAG, "Found incorrect passphrase type "
+ passphraseType
+ ". Falling back to default string.");
promptText.setText(accountName
+ profileSyncService.getSyncEnterCustomPassphraseBodyText());
break;
}
passphrase.setHint(R.string.sync_enter_custom_passphrase_hint);
} else {
promptText.setText(accountName
+ profileSyncService.getSyncEnterCustomPassphraseBodyText());
}
passphrase.setHint(R.string.sync_enter_custom_passphrase_hint);
passphrase.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
......
......@@ -292,13 +292,8 @@ public class SyncCustomizationFragment extends PreferenceFragment implements
return;
}
if (mProfileSyncService.isPassphraseRequiredForDecryption() && isAdded()) {
if (mProfileSyncService.isUsingSecondaryPassphrase()) {
mSyncEncryption.setSummary(
errorSummary(getString(R.string.sync_need_passphrase)));
} else {
mSyncEncryption.setSummary(
errorSummary(getString(R.string.sync_need_password)));
}
mSyncEncryption.setSummary(
errorSummary(getString(R.string.sync_need_passphrase)));
}
}
......@@ -434,11 +429,7 @@ public class SyncCustomizationFragment extends PreferenceFragment implements
@Override
public void onPassphraseEntered(String passphrase, boolean isGaia, boolean isUpdate) {
if (isUpdate) {
if (isGaia) {
handleEncryptWithGaia(passphrase);
} else {
handleEncryptWithCustomPassphrase(passphrase);
}
handleEncryptWithCustomPassphrase(passphrase);
} else {
handleDecryption(passphrase);
}
......@@ -467,25 +458,13 @@ public class SyncCustomizationFragment extends PreferenceFragment implements
@Override
public void onPassphraseTypeSelected(PassphraseType type) {
boolean isAllDataEncrypted = mProfileSyncService.isEncryptEverythingEnabled();
boolean isPassphraseGaia = !mProfileSyncService.isUsingSecondaryPassphrase();
if (type == PassphraseType.IMPLICIT_PASSPHRASE) {
// custom passphrase -> gaia is not allowed
assert (isPassphraseGaia);
boolean isGaia = true;
boolean isUpdate = !isAllDataEncrypted;
displayPasswordDialog(isGaia, isUpdate);
} else if (type == PassphraseType.CUSTOM_PASSPHRASE) {
if (isPassphraseGaia) {
displayCustomPasswordDialog();
} else {
// Now using the existing custom passphrase to encrypt
// everything.
boolean isGaia = false;
boolean isUpdate = false;
displayPasswordDialog(isGaia, isUpdate);
}
}
boolean isUsingSecondaryPassphrase = mProfileSyncService.isUsingSecondaryPassphrase();
// The passphrase type should only ever be selected if the account doesn't have
// full encryption enabled. Otherwise both options should be disabled.
assert !isAllDataEncrypted;
assert !isUsingSecondaryPassphrase;
displayCustomPasswordDialog();
}
/**
......@@ -500,7 +479,7 @@ public class SyncCustomizationFragment extends PreferenceFragment implements
}
if (preference == mSyncEncryption && mProfileSyncService.isSyncInitialized()) {
if (mProfileSyncService.isPassphraseRequiredForDecryption()) {
displayPasswordDialog(!mProfileSyncService.isUsingSecondaryPassphrase(), false);
displayPasswordDialog(false, false);
} else {
displayPasswordTypeDialog();
return true;
......
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