Fix crash when the Email process is killed

If the Email process is killed during setup, the Account information
wouldn't be set.  Specify this information in the intent as the intent will be delivered
again when the activity is restored

This is a short term fix. Ideally we would switch all of the intents for the setup
activities to use these extras to pass this information, or we would save the state of
SetupData in onSaveInstanceState

Bug: 7163201

Change-Id: Ic1758eb031cd113089073d03f3c2571e37a98b23
This commit is contained in:
Paul Westbrook 2012-09-18 19:17:46 -07:00
parent fb42a915e7
commit 5e1db519d9
1 changed files with 20 additions and 1 deletions

View File

@ -51,10 +51,20 @@ public class AccountSetupIncoming extends AccountSetupActivity
private final static String STATE_STARTED_AUTODISCOVERY =
"AccountSetupExchange.StartedAutoDiscovery";
// Extras for AccountSetupIncoming intent
private final static String FLOW_MODE_EXTRA = "flow-mode-extra";
private final static String ACCOUNT_EXTRA = "account-extra";
public static void actionIncomingSettings(Activity fromActivity, int mode, Account account) {
SetupData.setFlowMode(mode);
SetupData.setAccount(account);
fromActivity.startActivity(new Intent(fromActivity, AccountSetupIncoming.class));
final Intent intent = new Intent(fromActivity, AccountSetupIncoming.class);
// Add the additional information to the intent, in case the Email process is killed.
intent.putExtra(FLOW_MODE_EXTRA, mode);
intent.putExtra(ACCOUNT_EXTRA, account);
fromActivity.startActivity(intent);
}
@Override
@ -62,6 +72,15 @@ public class AccountSetupIncoming extends AccountSetupActivity
super.onCreate(savedInstanceState);
ActivityHelper.debugSetWindowFlags(this);
final Account dataAccount = SetupData.getAccount();
if (dataAccount == null) {
// The account is not set in the SetupData. This probably means that the Email
// process was killed, and we are in the process of restoring the activity
final Bundle extras = getIntent().getExtras();
SetupData.setFlowMode(extras.getInt(FLOW_MODE_EXTRA));
SetupData.setAccount((Account)extras.getParcelable(ACCOUNT_EXTRA));
}
HostAuth hostAuth = SetupData.getAccount().mHostAuthRecv;
mServiceInfo = EmailServiceUtils.getServiceInfo(this, hostAuth.mProtocol);