Only make Calendar and Contacts syncable on Exchange
b/11818312 We were using the existance of OPTIONS_CALENDAR_SYNC in the bundle to indicate that syncing was possible, and it's value to indicate whether automatic syncing should be enabled. This is misleading. Now, we check the serviceInfo for the account type to figure out if sync calendar and contacts is possible, and use the options passed in to indicate whether or not it should be automatic. Change-Id: I776519668c6630dc71153fb008218a7ca6357c74
This commit is contained in:
parent
e93b81a51a
commit
6a51abdf6e
@ -17,6 +17,7 @@
|
|||||||
package com.android.email.service;
|
package com.android.email.service;
|
||||||
|
|
||||||
import com.android.email.activity.setup.AccountSetupFinal;
|
import com.android.email.activity.setup.AccountSetupFinal;
|
||||||
|
import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
|
||||||
import com.android.emailcommon.provider.EmailContent;
|
import com.android.emailcommon.provider.EmailContent;
|
||||||
|
|
||||||
import android.accounts.AbstractAccountAuthenticator;
|
import android.accounts.AbstractAccountAuthenticator;
|
||||||
@ -56,6 +57,11 @@ public class AuthenticatorService extends Service {
|
|||||||
String authTokenType, String[] requiredFeatures, Bundle options)
|
String authTokenType, String[] requiredFeatures, Bundle options)
|
||||||
throws NetworkErrorException {
|
throws NetworkErrorException {
|
||||||
|
|
||||||
|
final String protocol = EmailServiceUtils.getProtocolFromAccountType(
|
||||||
|
AuthenticatorService.this, accountType);
|
||||||
|
final EmailServiceInfo info = EmailServiceUtils.getServiceInfo(
|
||||||
|
AuthenticatorService.this, protocol);
|
||||||
|
|
||||||
// There are two cases here:
|
// There are two cases here:
|
||||||
// 1) We are called with a username/password; this comes from the traditional email
|
// 1) We are called with a username/password; this comes from the traditional email
|
||||||
// app UI; we simply create the account and return the proper bundle
|
// app UI; we simply create the account and return the proper bundle
|
||||||
@ -67,16 +73,16 @@ public class AuthenticatorService extends Service {
|
|||||||
account, options.getString(OPTIONS_PASSWORD), null);
|
account, options.getString(OPTIONS_PASSWORD), null);
|
||||||
|
|
||||||
// Set up contacts syncing, if appropriate
|
// Set up contacts syncing, if appropriate
|
||||||
if (options.containsKey(OPTIONS_CONTACTS_SYNC_ENABLED)) {
|
if (info.syncContacts) {
|
||||||
boolean syncContacts = options.getBoolean(OPTIONS_CONTACTS_SYNC_ENABLED);
|
boolean syncContacts = options.getBoolean(OPTIONS_CONTACTS_SYNC_ENABLED, false);
|
||||||
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
|
||||||
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY,
|
ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY,
|
||||||
syncContacts);
|
syncContacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up calendar syncing, if appropriate
|
// Set up calendar syncing, if appropriate
|
||||||
if (options.containsKey(OPTIONS_CALENDAR_SYNC_ENABLED)) {
|
if (info.syncCalendar) {
|
||||||
boolean syncCalendar = options.getBoolean(OPTIONS_CALENDAR_SYNC_ENABLED);
|
boolean syncCalendar = options.getBoolean(OPTIONS_CALENDAR_SYNC_ENABLED, false);
|
||||||
ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 1);
|
ContentResolver.setIsSyncable(account, CalendarContract.AUTHORITY, 1);
|
||||||
ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY,
|
ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY,
|
||||||
syncCalendar);
|
syncCalendar);
|
||||||
|
Loading…
Reference in New Issue
Block a user