summaryrefslogtreecommitdiffstats
path: root/src/com/android/email/service
diff options
context:
space:
mode:
authorAnthony Lee <anthonylee@google.com>2014-07-24 13:28:26 -0700
committerAnthony Lee <anthonylee@google.com>2014-07-24 13:28:26 -0700
commit20110e628830a906f4c6a80eabb0bb127bf7d4be (patch)
treee69930b9f8e9635384d4791224d8866839362f89 /src/com/android/email/service
parenta0389a26b88705c375b0e144d1810ef46e1d0d8f (diff)
downloadandroid_packages_apps_Email-20110e628830a906f4c6a80eabb0bb127bf7d4be.tar.gz
android_packages_apps_Email-20110e628830a906f4c6a80eabb0bb127bf7d4be.tar.bz2
android_packages_apps_Email-20110e628830a906f4c6a80eabb0bb127bf7d4be.zip
Factor out the guts of setupAccountManagerAccount()
The new function will be called by the old function but it also allows me to use it from the Migration code. Change-Id: If9b2ad82479d60c63e8924d42fb6ce18d7d9a2f8
Diffstat (limited to 'src/com/android/email/service')
-rw-r--r--src/com/android/email/service/EmailServiceUtils.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java
index 54dcdd826..d42b0ee70 100644
--- a/src/com/android/email/service/EmailServiceUtils.java
+++ b/src/com/android/email/service/EmailServiceUtils.java
@@ -284,19 +284,38 @@ public class EmailServiceUtils {
public static AccountManagerFuture<Bundle> setupAccountManagerAccount(final Context context,
final Account account, final boolean email, final boolean calendar,
final boolean contacts, final AccountManagerCallback<Bundle> callback) {
- final Bundle options = new Bundle(5);
final HostAuth hostAuthRecv =
HostAuth.restoreHostAuthWithId(context, account.mHostAuthKeyRecv);
- if (hostAuthRecv == null) {
+ return setupAccountManagerAccount(context, account, email, calendar, contacts,
+ hostAuthRecv, callback);
+ }
+
+ /**
+ * Add an account to the AccountManager.
+ * @param context Our {@link Context}.
+ * @param account The {@link Account} we're adding.
+ * @param email Whether the user wants to sync email on this account.
+ * @param calendar Whether the user wants to sync calendar on this account.
+ * @param contacts Whether the user wants to sync contacts on this account.
+ * @param hostAuth HostAuth that identifies the protocol and password for this account.
+ * @param callback A callback for when the AccountManager is done.
+ * @return The result of {@link AccountManager#addAccount}.
+ */
+ public static AccountManagerFuture<Bundle> setupAccountManagerAccount(final Context context,
+ final Account account, final boolean email, final boolean calendar,
+ final boolean contacts, final HostAuth hostAuth,
+ final AccountManagerCallback<Bundle> callback) {
+ if (hostAuth == null) {
return null;
}
// Set up username/password
+ final Bundle options = new Bundle(5);
options.putString(EasAuthenticatorService.OPTIONS_USERNAME, account.mEmailAddress);
- options.putString(EasAuthenticatorService.OPTIONS_PASSWORD, hostAuthRecv.mPassword);
+ options.putString(EasAuthenticatorService.OPTIONS_PASSWORD, hostAuth.mPassword);
options.putBoolean(EasAuthenticatorService.OPTIONS_CONTACTS_SYNC_ENABLED, contacts);
options.putBoolean(EasAuthenticatorService.OPTIONS_CALENDAR_SYNC_ENABLED, calendar);
options.putBoolean(EasAuthenticatorService.OPTIONS_EMAIL_SYNC_ENABLED, email);
- final EmailServiceInfo info = getServiceInfo(context, hostAuthRecv.mProtocol);
+ final EmailServiceInfo info = getServiceInfo(context, hostAuth.mProtocol);
return AccountManager.get(context).addAccount(info.accountType, null, null, options, null,
callback, null);
}