summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2013-05-29 15:37:26 -0700
committerJay Shrauner <shrauner@google.com>2013-05-31 17:42:26 +0000
commit0543dbe1113dca036da00124513eeb8f922c94cb (patch)
tree67c1600e56be51a66293801f89ea58e114efd1ae /src
parent49db9e1eeb8e1eabe543d4c1bd24b20efa92c997 (diff)
downloadpackages_apps_ContactsCommon-0543dbe1113dca036da00124513eeb8f922c94cb.tar.gz
packages_apps_ContactsCommon-0543dbe1113dca036da00124513eeb8f922c94cb.tar.bz2
packages_apps_ContactsCommon-0543dbe1113dca036da00124513eeb8f922c94cb.zip
Use ContentResolver instead of IContentService
Switch to using public ContentResolver calls (needed for unbundling). Bug: 6948882 Change-Id: I4affb6aaa14b670861c9b739b6b4bb457699985f
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/common/model/AccountTypeManager.java148
1 files changed, 69 insertions, 79 deletions
diff --git a/src/com/android/contacts/common/model/AccountTypeManager.java b/src/com/android/contacts/common/model/AccountTypeManager.java
index a8eb3778..b5a9a165 100644
--- a/src/com/android/contacts/common/model/AccountTypeManager.java
+++ b/src/com/android/contacts/common/model/AccountTypeManager.java
@@ -23,7 +23,6 @@ import android.accounts.OnAccountsUpdateListener;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.IContentService;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SyncAdapterType;
@@ -395,102 +394,93 @@ class AccountTypeManagerImpl extends AccountTypeManager
final Set<String> extensionPackages = Sets.newHashSet();
final AccountManager am = mAccountManager;
- final IContentService cs = ContentResolver.getContentService();
- try {
- final SyncAdapterType[] syncs = cs.getSyncAdapterTypes();
- final AuthenticatorDescription[] auths = am.getAuthenticatorTypes();
+ final SyncAdapterType[] syncs = ContentResolver.getSyncAdapterTypes();
+ final AuthenticatorDescription[] auths = am.getAuthenticatorTypes();
- // First process sync adapters to find any that provide contact data.
- for (SyncAdapterType sync : syncs) {
- if (!ContactsContract.AUTHORITY.equals(sync.authority)) {
- // Skip sync adapters that don't provide contact data.
- continue;
- }
+ // First process sync adapters to find any that provide contact data.
+ for (SyncAdapterType sync : syncs) {
+ if (!ContactsContract.AUTHORITY.equals(sync.authority)) {
+ // Skip sync adapters that don't provide contact data.
+ continue;
+ }
- // Look for the formatting details provided by each sync
- // adapter, using the authenticator to find general resources.
- final String type = sync.accountType;
- final AuthenticatorDescription auth = findAuthenticator(auths, type);
- if (auth == null) {
- Log.w(TAG, "No authenticator found for type=" + type + ", ignoring it.");
- continue;
- }
+ // Look for the formatting details provided by each sync
+ // adapter, using the authenticator to find general resources.
+ final String type = sync.accountType;
+ final AuthenticatorDescription auth = findAuthenticator(auths, type);
+ if (auth == null) {
+ Log.w(TAG, "No authenticator found for type=" + type + ", ignoring it.");
+ continue;
+ }
- AccountType accountType;
- if (GoogleAccountType.ACCOUNT_TYPE.equals(type)) {
- accountType = new GoogleAccountType(mContext, auth.packageName);
- } else if (ExchangeAccountType.isExchangeType(type)) {
- accountType = new ExchangeAccountType(mContext, auth.packageName, type);
+ AccountType accountType;
+ if (GoogleAccountType.ACCOUNT_TYPE.equals(type)) {
+ accountType = new GoogleAccountType(mContext, auth.packageName);
+ } else if (ExchangeAccountType.isExchangeType(type)) {
+ accountType = new ExchangeAccountType(mContext, auth.packageName, type);
+ } else {
+ // TODO: use syncadapter package instead, since it provides resources
+ Log.d(TAG, "Registering external account type=" + type
+ + ", packageName=" + auth.packageName);
+ accountType = new ExternalAccountType(mContext, auth.packageName, false);
+ }
+ if (!accountType.isInitialized()) {
+ if (accountType.isEmbedded()) {
+ throw new IllegalStateException("Problem initializing embedded type "
+ + accountType.getClass().getCanonicalName());
} else {
- // TODO: use syncadapter package instead, since it provides resources
- Log.d(TAG, "Registering external account type=" + type
- + ", packageName=" + auth.packageName);
- accountType = new ExternalAccountType(mContext, auth.packageName, false);
- }
- if (!accountType.isInitialized()) {
- if (accountType.isEmbedded()) {
- throw new IllegalStateException("Problem initializing embedded type "
- + accountType.getClass().getCanonicalName());
- } else {
- // Skip external account types that couldn't be initialized.
- continue;
- }
+ // Skip external account types that couldn't be initialized.
+ continue;
}
+ }
- accountType.accountType = auth.type;
- accountType.titleRes = auth.labelId;
- accountType.iconRes = auth.iconId;
-
- addAccountType(accountType, accountTypesByTypeAndDataSet, accountTypesByType);
+ accountType.accountType = auth.type;
+ accountType.titleRes = auth.labelId;
+ accountType.iconRes = auth.iconId;
- // Check to see if the account type knows of any other non-sync-adapter packages
- // that may provide other data sets of contact data.
- extensionPackages.addAll(accountType.getExtensionPackageNames());
- }
+ addAccountType(accountType, accountTypesByTypeAndDataSet, accountTypesByType);
- // If any extension packages were specified, process them as well.
- if (!extensionPackages.isEmpty()) {
- Log.d(TAG, "Registering " + extensionPackages.size() + " extension packages");
- for (String extensionPackage : extensionPackages) {
- ExternalAccountType accountType =
- new ExternalAccountType(mContext, extensionPackage, true);
- if (!accountType.isInitialized()) {
- // Skip external account types that couldn't be initialized.
- continue;
- }
- if (!accountType.hasContactsMetadata()) {
- Log.w(TAG, "Skipping extension package " + extensionPackage + " because"
- + " it doesn't have the CONTACTS_STRUCTURE metadata");
- continue;
- }
- if (TextUtils.isEmpty(accountType.accountType)) {
- Log.w(TAG, "Skipping extension package " + extensionPackage + " because"
- + " the CONTACTS_STRUCTURE metadata doesn't have the accountType"
- + " attribute");
- continue;
- }
- Log.d(TAG, "Registering extension package account type="
- + accountType.accountType + ", dataSet=" + accountType.dataSet
- + ", packageName=" + extensionPackage);
+ // Check to see if the account type knows of any other non-sync-adapter packages
+ // that may provide other data sets of contact data.
+ extensionPackages.addAll(accountType.getExtensionPackageNames());
+ }
- addAccountType(accountType, accountTypesByTypeAndDataSet, accountTypesByType);
+ // If any extension packages were specified, process them as well.
+ if (!extensionPackages.isEmpty()) {
+ Log.d(TAG, "Registering " + extensionPackages.size() + " extension packages");
+ for (String extensionPackage : extensionPackages) {
+ ExternalAccountType accountType =
+ new ExternalAccountType(mContext, extensionPackage, true);
+ if (!accountType.isInitialized()) {
+ // Skip external account types that couldn't be initialized.
+ continue;
}
+ if (!accountType.hasContactsMetadata()) {
+ Log.w(TAG, "Skipping extension package " + extensionPackage + " because"
+ + " it doesn't have the CONTACTS_STRUCTURE metadata");
+ continue;
+ }
+ if (TextUtils.isEmpty(accountType.accountType)) {
+ Log.w(TAG, "Skipping extension package " + extensionPackage + " because"
+ + " the CONTACTS_STRUCTURE metadata doesn't have the accountType"
+ + " attribute");
+ continue;
+ }
+ Log.d(TAG, "Registering extension package account type="
+ + accountType.accountType + ", dataSet=" + accountType.dataSet
+ + ", packageName=" + extensionPackage);
+
+ addAccountType(accountType, accountTypesByTypeAndDataSet, accountTypesByType);
}
- } catch (RemoteException e) {
- Log.w(TAG, "Problem loading accounts: " + e.toString());
}
timings.addSplit("Loaded account types");
// Map in accounts to associate the account names with each account type entry.
Account[] accounts = mAccountManager.getAccounts();
for (Account account : accounts) {
- boolean syncable = false;
- try {
- syncable = cs.getIsSyncable(account, ContactsContract.AUTHORITY) > 0;
- } catch (RemoteException e) {
- Log.e(TAG, "Cannot obtain sync flag for account: " + account, e);
- }
+ boolean syncable =
+ ContentResolver.getIsSyncable(account, ContactsContract.AUTHORITY) > 0;
if (syncable) {
List<AccountType> accountTypes = accountTypesByType.get(account.type);