From b7fe21676ec46ce98e88bc181fc82a18e882236a Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 12 Mar 2010 23:17:28 -0800 Subject: [PATCH] Prevent multiple calls to onDone() in AccountSetupOptions * When "Done" is pressed in AccountSetupOptions and the Account is EAS, the finish() isn't called until an async method's callback is invoked (system account creation) * This allowed the user to execute onDone() multiple times, each one of which would attempt to create an account * The net effect was the referenced bug, which can manifest in a number of ugly ways * The fix is to prevent multiple calls to onDone() Bug: 2501574 Change-Id: I61057bbb8c1f85da07e83ed6c56474bfe4e23f6c --- .../email/activity/setup/AccountSetupOptions.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/activity/setup/AccountSetupOptions.java b/src/com/android/email/activity/setup/AccountSetupOptions.java index 8652f4a6e..1be825b2a 100644 --- a/src/com/android/email/activity/setup/AccountSetupOptions.java +++ b/src/com/android/email/activity/setup/AccountSetupOptions.java @@ -58,6 +58,7 @@ public class AccountSetupOptions extends Activity implements OnClickListener { private EmailContent.Account mAccount; private boolean mEasFlowMode; private Handler mHandler = new Handler(); + private boolean mDonePressed = false; /** Default sync window for new EAS accounts */ private static final int SYNC_WINDOW_EAS_DEFAULT = com.android.email.Account.SYNC_WINDOW_3_DAYS; @@ -228,7 +229,13 @@ public class AccountSetupOptions extends Activity implements OnClickListener { public void onClick(View v) { switch (v.getId()) { case R.id.next: - onDone(); + // Don't allow this more than once (Exchange accounts call an async method + // before finish()'ing the Activity, which allows this code to potentially be + // executed multiple times + if (!mDonePressed) { + onDone(); + mDonePressed = true; + } break; } }