Remove MailService.
Change-Id: Ibffd0c9fb0eed4822dff28d1577fb455736cffd1
This commit is contained in:
parent
30b28286aa
commit
02f0b1eee8
|
@ -455,12 +455,6 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<service
|
|
||||||
android:name=".service.MailService"
|
|
||||||
android:enabled="true"
|
|
||||||
>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".service.AttachmentDownloadService"
|
android:name=".service.AttachmentDownloadService"
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
|
|
|
@ -41,7 +41,6 @@ import com.android.email.activity.ActivityHelper;
|
||||||
import com.android.email.activity.UiUtilities;
|
import com.android.email.activity.UiUtilities;
|
||||||
import com.android.email.service.EmailServiceUtils;
|
import com.android.email.service.EmailServiceUtils;
|
||||||
import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
|
import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
|
||||||
import com.android.email.service.MailService;
|
|
||||||
import com.android.email2.ui.MailActivityEmail;
|
import com.android.email2.ui.MailActivityEmail;
|
||||||
import com.android.emailcommon.Logging;
|
import com.android.emailcommon.Logging;
|
||||||
import com.android.emailcommon.provider.Account;
|
import com.android.emailcommon.provider.Account;
|
||||||
|
@ -254,7 +253,7 @@ public class AccountSetupOptions extends AccountSetupActivity implements OnClick
|
||||||
public void run() {
|
public void run() {
|
||||||
Context context = AccountSetupOptions.this;
|
Context context = AccountSetupOptions.this;
|
||||||
AccountSettingsUtils.commitSettings(context, account);
|
AccountSettingsUtils.commitSettings(context, account);
|
||||||
MailService.setupAccountManagerAccount(context, account,
|
EmailServiceUtils.setupAccountManagerAccount(context, account,
|
||||||
email2, calendar2, contacts2, mAccountManagerCallback);
|
email2, calendar2, contacts2, mAccountManagerCallback);
|
||||||
|
|
||||||
// We can move the notification setting to the inbox FolderPreferences later, once
|
// We can move the notification setting to the inbox FolderPreferences later, once
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package com.android.email.service;
|
package com.android.email.service;
|
||||||
|
|
||||||
import android.accounts.AccountManager;
|
import android.accounts.AccountManager;
|
||||||
|
import android.accounts.AccountManagerCallback;
|
||||||
import android.accounts.AccountManagerFuture;
|
import android.accounts.AccountManagerFuture;
|
||||||
import android.accounts.AuthenticatorException;
|
import android.accounts.AuthenticatorException;
|
||||||
import android.accounts.OperationCanceledException;
|
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,
|
public static void updateAccountManagerType(Context context,
|
||||||
android.accounts.Account amAccount, final HashMap<String, String> protocolMap) {
|
android.accounts.Account amAccount, final HashMap<String, String> protocolMap) {
|
||||||
final ContentResolver resolver = context.getContentResolver();
|
final ContentResolver resolver = context.getContentResolver();
|
||||||
|
@ -347,8 +378,8 @@ public class EmailServiceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up a new AccountManager account with new type and old settings
|
// Set up a new AccountManager account with new type and old settings
|
||||||
AccountManagerFuture<?> amFuture = MailService.setupAccountManagerAccount(
|
AccountManagerFuture<?> amFuture = setupAccountManagerAccount(context, account,
|
||||||
context, account, email, calendar, contacts, null);
|
email, calendar, contacts, null);
|
||||||
finishAccountManagerBlocker(amFuture);
|
finishAccountManagerBlocker(amFuture);
|
||||||
LogUtils.w(Logging.LOG_TAG, "Created new AccountManager account");
|
LogUtils.w(Logging.LOG_TAG, "Created new AccountManager account");
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,8 +20,8 @@ import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.content.UriMatcher;
|
import android.content.UriMatcher;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -32,7 +32,6 @@ import com.android.email.R;
|
||||||
import com.android.email.provider.EmailProvider;
|
import com.android.email.provider.EmailProvider;
|
||||||
import com.android.email.service.AttachmentDownloadService;
|
import com.android.email.service.AttachmentDownloadService;
|
||||||
import com.android.email.service.EmailServiceUtils;
|
import com.android.email.service.EmailServiceUtils;
|
||||||
import com.android.email.service.MailService;
|
|
||||||
import com.android.emailcommon.Logging;
|
import com.android.emailcommon.Logging;
|
||||||
import com.android.emailcommon.TempDirectory;
|
import com.android.emailcommon.TempDirectory;
|
||||||
import com.android.emailcommon.provider.Account;
|
import com.android.emailcommon.provider.Account;
|
||||||
|
@ -142,11 +141,6 @@ public class MailActivityEmail extends com.android.mail.ui.MailActivity {
|
||||||
|
|
||||||
private static void setServicesEnabled(Context context, boolean enabled) {
|
private static void setServicesEnabled(Context context, boolean enabled) {
|
||||||
PackageManager pm = context.getPackageManager();
|
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(
|
pm.setComponentEnabledSetting(
|
||||||
new ComponentName(context, AttachmentDownloadService.class),
|
new ComponentName(context, AttachmentDownloadService.class),
|
||||||
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
|
enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
|
||||||
|
|
Loading…
Reference in New Issue