Clear account incomplete flag properly; handle unusual flow
* We waited to clear the incomplete flag until security was agreed to, but this can lead to accounts left incomplete; we now clear the flag as soon as the AccountManager account is created (by convention, this is when the EmailProvider account is complete) * Also, allow onDone() to be called more than once with a saved account, leaving cleanly, rather than throwing a runtime exception Bug: 5016792 Change-Id: Ib5fc44ac045a1dd9bd5d63f922c037ed637d5341
This commit is contained in:
parent
68ce7f3d60
commit
8df9af0df3
@ -207,6 +207,11 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick
|
||||
*/
|
||||
private void onDone() {
|
||||
final Account account = SetupData.getAccount();
|
||||
if (account.isSaved()) {
|
||||
// Disrupting the normal flow could get us here, but if the account is already
|
||||
// saved, we've done this work
|
||||
return;
|
||||
}
|
||||
account.setDisplayName(account.getEmailAddress());
|
||||
int newFlags = account.getFlags() &
|
||||
~(Account.FLAGS_NOTIFY_NEW_MAIL | Account.FLAGS_BACKGROUND_ATTACHMENTS);
|
||||
@ -225,9 +230,6 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick
|
||||
}
|
||||
account.setDefaultAccount(mDefaultView.isChecked());
|
||||
|
||||
if (account.isSaved()) {
|
||||
throw new IllegalStateException("in AccountSetupOptions with already-saved account");
|
||||
}
|
||||
if (account.mHostAuthRecv == null) {
|
||||
throw new IllegalStateException("in AccountSetupOptions with null mHostAuthRecv");
|
||||
}
|
||||
@ -327,8 +329,12 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick
|
||||
SetupData.setAccountAuthenticatorResponse(null);
|
||||
}
|
||||
|
||||
// If we've got policies for this account, ask the user to accept.
|
||||
// Now that AccountManager account creation is complete, clear the INCOMPLETE flag
|
||||
Account account = SetupData.getAccount();
|
||||
account.mFlags &= ~Account.FLAGS_INCOMPLETE;
|
||||
AccountSettingsUtils.commitSettings(AccountSetupOptions.this, account);
|
||||
|
||||
// If we've got policies for this account, ask the user to accept.
|
||||
if ((account.mFlags & Account.FLAGS_SECURITY_HOLD) != 0) {
|
||||
Intent intent = AccountSecurity.actionUpdateSecurityIntent(this, account.mId, false);
|
||||
startActivityForResult(intent, AccountSetupOptions.REQUEST_CODE_ACCEPT_POLICIES);
|
||||
@ -358,9 +364,9 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick
|
||||
@Override
|
||||
public void run() {
|
||||
AccountSetupOptions context = AccountSetupOptions.this;
|
||||
// Clear the incomplete/security hold flag now
|
||||
// Clear the security hold flag now
|
||||
Account account = SetupData.getAccount();
|
||||
account.mFlags &= ~(Account.FLAGS_INCOMPLETE | Account.FLAGS_SECURITY_HOLD);
|
||||
account.mFlags &= ~Account.FLAGS_SECURITY_HOLD;
|
||||
AccountSettingsUtils.commitSettings(context, account);
|
||||
// Start up services based on new account(s)
|
||||
Email.setServicesEnabledSync(context);
|
||||
|
Loading…
Reference in New Issue
Block a user