From a97faa25ac3265209b50d4534b4c2b41cd211e5c Mon Sep 17 00:00:00 2001 From: Andy Stadler Date: Tue, 25 Jan 2011 23:18:45 -0800 Subject: [PATCH] Discard result of Dupe Account check if paused Fixes a potential race condition with a slow DB lookup and a fast user (or monkey). Bug: 3384992 Change-Id: I0602820e1d9f49eb01b09c9d78db3d0fc47ccfb1 --- .../email/activity/setup/AccountSetupBasics.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/com/android/email/activity/setup/AccountSetupBasics.java b/src/com/android/email/activity/setup/AccountSetupBasics.java index 4e11b8b9b..a56859266 100644 --- a/src/com/android/email/activity/setup/AccountSetupBasics.java +++ b/src/com/android/email/activity/setup/AccountSetupBasics.java @@ -117,6 +117,7 @@ public class AccountSetupBasics extends AccountSetupActivity private Button mManualButton; private Button mNextButton; private boolean mNextButtonInhibit; + private boolean mPaused; // Used when this Activity is called as part of account authentification flow, // which requires to do extra work before and after the account creation. @@ -296,6 +297,18 @@ public class AccountSetupBasics extends AccountSetupActivity Utility.runAsync(mOwnerLookupTask); } + @Override + public void onPause() { + super.onPause(); + mPaused = true; + } + + @Override + public void onResume() { + super.onResume(); + mPaused = false; + } + @Override public void finish() { if (mAccountAuthenticatorResponse != null) { @@ -477,6 +490,8 @@ public class AccountSetupBasics extends AccountSetupActivity @Override protected void onPostExecute(Account duplicateAccount) { mNextButtonInhibit = false; + // Exit immediately if the user left before we finished + if (mPaused) return; // Show duplicate account warning, or proceed if (duplicateAccount != null) { DuplicateAccountDialogFragment dialogFragment =