From fa669234be7d74d1733c73a2f51aa91acaae639e Mon Sep 17 00:00:00 2001 From: Andrew Stadler Date: Wed, 14 Apr 2010 17:41:28 -0700 Subject: [PATCH] Safer error handling in AccountNames The error handling for (mAccount == null) would crash. Use a simpler path here and just abandon the setup process. The root cause of this (the account being null) is probably solved by 3ae84b247d1a416b91c6dc9585898108389e4e6c, but still a good idea to clean this up. Bug: 2558344 Change-Id: I3167234f99e9d39844f2b56a4d94f25465c7c269 --- .../android/email/activity/setup/AccountSetupNames.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/activity/setup/AccountSetupNames.java b/src/com/android/email/activity/setup/AccountSetupNames.java index 42004c944..55387eaab 100644 --- a/src/com/android/email/activity/setup/AccountSetupNames.java +++ b/src/com/android/email/activity/setup/AccountSetupNames.java @@ -19,6 +19,7 @@ package com.android.email.activity.setup; import com.android.email.AccountBackupRestore; import com.android.email.R; import com.android.email.Utility; +import com.android.email.activity.Welcome; import com.android.email.provider.EmailContent; import com.android.email.provider.EmailContent.Account; import com.android.email.provider.EmailContent.AccountColumns; @@ -93,7 +94,11 @@ public class AccountSetupNames extends Activity implements OnClickListener { mAccount = EmailContent.Account.restoreAccountWithId(this, accountId); // Shouldn't happen, but it could if (mAccount == null) { - onBackPressed(); + // The safe thing to do here is to rewind all the way to the entry activity, + // which can handle any configuration of accounts (0, 1, or 2+) + Welcome.actionStart(this); + finish(); + return; } // Get the hostAuth for receiving HostAuth hostAuth = HostAuth.restoreHostAuthWithId(this, mAccount.mHostAuthKeyRecv);