Merge "Fix remote wipe with mobile sync server"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3625d73..75292e3 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -549,7 +549,7 @@
     <!-- In Account setup options screen, Activity title -->
     <string name="account_setup_options_title">Account options</string>
     <!-- In Account setup options screen, label for email check frequency selector -->
-    <string name="account_setup_options_mail_check_frequency_label">Email checking frequency</string>
+    <string name="account_setup_options_mail_check_frequency_label">Inbox checking frequency</string>
     <!-- In Account setup options & Account Settings screens, label for email check frequency option -->
     <string name="account_setup_options_mail_check_frequency_never">Never</string>
     <!-- In Account setup options & Account Settings screens, label for email check frequency option -->
@@ -676,7 +676,7 @@
     <!-- On Settings screen, setting summary text -->
     <string name="account_settings_notify_summary">Notify in status bar when email arrives</string>
     <!-- On Settings screen, setting option name and title of dialog box that opens -->
-    <string name="account_settings_mail_check_frequency_label">Email check frequency</string>
+    <string name="account_settings_mail_check_frequency_label">Inbox check frequency</string>
     <!-- On Settings screen, setting option name -->
     <string name="account_settings_incoming_label">Incoming settings</string>
     <!-- On Settings screen, setting option name -->
diff --git a/src/com/android/email/activity/setup/AccountSetupBasics.java b/src/com/android/email/activity/setup/AccountSetupBasics.java
index b420e3e..42d8567 100644
--- a/src/com/android/email/activity/setup/AccountSetupBasics.java
+++ b/src/com/android/email/activity/setup/AccountSetupBasics.java
@@ -23,6 +23,8 @@
 import com.android.email.provider.EmailContent.Account;
 import com.android.email.provider.EmailContent.HostAuth;
 
+import android.accounts.AccountAuthenticatorResponse;
+import android.accounts.AccountManager;
 import android.app.Activity;
 import android.app.FragmentTransaction;
 import android.content.Context;
@@ -48,6 +50,12 @@
     private boolean mManualButtonDisplayed;
     private boolean mNextButtonEnabled;
 
+    // Used when this Activity is called as part of account authentification flow,
+    // which requires to do extra work before and after the account creation.
+    // See also AccountAuthenticatorActivity.
+    private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
+    private Bundle mResultBundle = null;
+
     public static void actionNewAccount(Activity fromActivity) {
         SetupData.init(SetupData.FLOW_MODE_NORMAL);
         fromActivity.startActivity(new Intent(fromActivity, AccountSetupBasics.class));
@@ -132,6 +140,28 @@
 
         // Configure fragment
         mFragment.setCallback(this, alternateStrings);
+
+        mAccountAuthenticatorResponse =
+            getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
+
+        if (mAccountAuthenticatorResponse != null) {
+            mAccountAuthenticatorResponse.onRequestContinued();
+        }
+    }
+
+    @Override
+    public void finish() {
+        if (mAccountAuthenticatorResponse != null) {
+            // send the result bundle back if set, otherwise send an error.
+            if (mResultBundle != null) {
+                mAccountAuthenticatorResponse.onResult(mResultBundle);
+            } else {
+                mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
+                        "canceled");
+            }
+            mAccountAuthenticatorResponse = null;
+        }
+        super.finish();
     }
 
     /**