diff options
| author | Yu Ping Hu <yph@google.com> | 2013-07-26 16:49:06 -0700 |
|---|---|---|
| committer | Yu Ping Hu <yph@google.com> | 2013-07-26 17:38:07 -0700 |
| commit | 02f0b1eee8f5de651ad5f0289146f88fea99bce0 (patch) | |
| tree | c0e5ba726a52d04db016ef731fe02c010ca2de8a /src | |
| parent | 30b28286aade0d45cf37b7f27057c1b89b8e18bd (diff) | |
| download | android_packages_apps_Email-02f0b1eee8f5de651ad5f0289146f88fea99bce0.tar.gz android_packages_apps_Email-02f0b1eee8f5de651ad5f0289146f88fea99bce0.tar.bz2 android_packages_apps_Email-02f0b1eee8f5de651ad5f0289146f88fea99bce0.zip | |
Remove MailService.
Change-Id: Ibffd0c9fb0eed4822dff28d1577fb455736cffd1
Diffstat (limited to 'src')
4 files changed, 35 insertions, 83 deletions
diff --git a/src/com/android/email/activity/setup/AccountSetupOptions.java b/src/com/android/email/activity/setup/AccountSetupOptions.java index 62f1cbe01..ee6eb1571 100644 --- a/src/com/android/email/activity/setup/AccountSetupOptions.java +++ b/src/com/android/email/activity/setup/AccountSetupOptions.java @@ -41,7 +41,6 @@ import com.android.email.activity.ActivityHelper; import com.android.email.activity.UiUtilities; import com.android.email.service.EmailServiceUtils; import com.android.email.service.EmailServiceUtils.EmailServiceInfo; -import com.android.email.service.MailService; import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.Logging; import com.android.emailcommon.provider.Account; @@ -254,7 +253,7 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick public void run() { Context context = AccountSetupOptions.this; AccountSettingsUtils.commitSettings(context, account); - MailService.setupAccountManagerAccount(context, account, + EmailServiceUtils.setupAccountManagerAccount(context, account, email2, calendar2, contacts2, mAccountManagerCallback); // We can move the notification setting to the inbox FolderPreferences later, once diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java index f20498d23..ce95a188f 100644 --- a/src/com/android/email/service/EmailServiceUtils.java +++ b/src/com/android/email/service/EmailServiceUtils.java @@ -17,6 +17,7 @@ package com.android.email.service; import android.accounts.AccountManager; +import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; import android.accounts.AuthenticatorException; import android.accounts.OperationCanceledException; @@ -250,6 +251,36 @@ public class EmailServiceUtils { } } + /** + * 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 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 AccountManagerCallback<Bundle> callback) { + final Bundle options = new Bundle(5); + final HostAuth hostAuthRecv = + HostAuth.restoreHostAuthWithId(context, account.mHostAuthKeyRecv); + if (hostAuthRecv == null) { + return null; + } + // Set up username/password + options.putString(EasAuthenticatorService.OPTIONS_USERNAME, account.mEmailAddress); + options.putString(EasAuthenticatorService.OPTIONS_PASSWORD, hostAuthRecv.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); + return AccountManager.get(context).addAccount(info.accountType, null, null, options, null, + callback, null); + } + public static void updateAccountManagerType(Context context, android.accounts.Account amAccount, final HashMap<String, String> protocolMap) { final ContentResolver resolver = context.getContentResolver(); @@ -347,8 +378,8 @@ public class EmailServiceUtils { } // Set up a new AccountManager account with new type and old settings - AccountManagerFuture<?> amFuture = MailService.setupAccountManagerAccount( - context, account, email, calendar, contacts, null); + AccountManagerFuture<?> amFuture = setupAccountManagerAccount(context, account, + email, calendar, contacts, null); finishAccountManagerBlocker(amFuture); LogUtils.w(Logging.LOG_TAG, "Created new AccountManager account"); diff --git a/src/com/android/email/service/MailService.java b/src/com/android/email/service/MailService.java deleted file mode 100644 index e626cc68b..000000000 --- a/src/com/android/email/service/MailService.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.email.service; - -import android.accounts.AccountManager; -import android.accounts.AccountManagerCallback; -import android.accounts.AccountManagerFuture; -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; -import android.os.IBinder; - -import com.android.email.provider.AccountReconciler; -import com.android.email.service.EmailServiceUtils.EmailServiceInfo; -import com.android.email2.ui.MailActivityEmail; -import com.android.emailcommon.provider.Account; -import com.android.emailcommon.provider.HostAuth; - -/** - * Legacy service, now used mainly for account reconciliation - * TODO: Eliminate this service, since it doesn't actually do anything. - */ -public class MailService extends Service { - - @Override - public int onStartCommand(final Intent intent, int flags, final int startId) { - super.onStartCommand(intent, flags, startId); - AccountReconciler.reconcileAccounts(this); - // Make sure our services are running, if necessary - MailActivityEmail.setServicesEnabledAsync(this); - return START_STICKY; - } - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - public static AccountManagerFuture<Bundle> setupAccountManagerAccount(Context context, - Account account, boolean email, boolean calendar, boolean contacts, - AccountManagerCallback<Bundle> callback) { - Bundle options = new Bundle(); - HostAuth hostAuthRecv = HostAuth.restoreHostAuthWithId(context, account.mHostAuthKeyRecv); - if (hostAuthRecv == null) { - return null; - } - // Set up username/password - options.putString(EasAuthenticatorService.OPTIONS_USERNAME, account.mEmailAddress); - options.putString(EasAuthenticatorService.OPTIONS_PASSWORD, hostAuthRecv.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); - EmailServiceInfo info = EmailServiceUtils.getServiceInfo(context, hostAuthRecv.mProtocol); - return AccountManager.get(context).addAccount(info.accountType, null, null, options, null, - callback, null); - } -} diff --git a/src/com/android/email2/ui/MailActivityEmail.java b/src/com/android/email2/ui/MailActivityEmail.java index 107528c54..4f2d9e938 100644 --- a/src/com/android/email2/ui/MailActivityEmail.java +++ b/src/com/android/email2/ui/MailActivityEmail.java @@ -20,8 +20,8 @@ import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; -import android.content.pm.PackageManager; import android.content.UriMatcher; +import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; @@ -32,7 +32,6 @@ import com.android.email.R; import com.android.email.provider.EmailProvider; import com.android.email.service.AttachmentDownloadService; import com.android.email.service.EmailServiceUtils; -import com.android.email.service.MailService; import com.android.emailcommon.Logging; import com.android.emailcommon.TempDirectory; import com.android.emailcommon.provider.Account; @@ -143,11 +142,6 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity { private static void setServicesEnabled(Context context, boolean enabled) { PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting( - new ComponentName(context, MailService.class), - enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : - PackageManager.COMPONENT_ENABLED_STATE_DISABLED, - PackageManager.DONT_KILL_APP); - pm.setComponentEnabledSetting( new ComponentName(context, AttachmentDownloadService.class), enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED, |
