Renaming AccountTypes to AccountTypeManager.

The intent is to turn it into a "system service" of sorts.

Change-Id: I047d70a2e59978c05916965ef0c0d9f18abc55e6
diff --git a/src/com/android/contacts/ContactsApplication.java b/src/com/android/contacts/ContactsApplication.java
index 8cbdfbf..4911fc0 100644
--- a/src/com/android/contacts/ContactsApplication.java
+++ b/src/com/android/contacts/ContactsApplication.java
@@ -16,7 +16,7 @@
 
 package com.android.contacts;
 
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.test.InjectedServices;
 
 import android.app.Application;
@@ -54,7 +54,7 @@
         // Priming caches to placate the StrictMode police
         Context context = getApplicationContext();
         PreferenceManager.getDefaultSharedPreferences(context);
-        AccountTypes.getInstance(context);
+        AccountTypeManager.getInstance(context);
 
         StrictMode.setThreadPolicy(
                 new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
diff --git a/src/com/android/contacts/SplitAggregateView.java b/src/com/android/contacts/SplitAggregateView.java
index 254b0be..d99ba85 100644
--- a/src/com/android/contacts/SplitAggregateView.java
+++ b/src/com/android/contacts/SplitAggregateView.java
@@ -17,7 +17,7 @@
 package com.android.contacts;
 
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 
 import android.content.Context;
 import android.content.pm.PackageManager;
@@ -73,7 +73,7 @@
 
     private final Uri mAggregateUri;
     private OnContactSelectedListener mListener;
-    private AccountTypes mAccountTypes;
+    private AccountTypeManager mAccountTypes;
 
     /**
      * Listener interface that gets the contact ID of the user-selected contact.
@@ -90,7 +90,7 @@
 
         mAggregateUri = aggregateUri;
 
-        mAccountTypes = AccountTypes.getInstance(context);
+        mAccountTypes = AccountTypeManager.getInstance(context);
 
         final List<RawContactInfo> list = loadData();
 
diff --git a/src/com/android/contacts/activities/ContactBrowserActivity.java b/src/com/android/contacts/activities/ContactBrowserActivity.java
index c202615..d155be0 100644
--- a/src/com/android/contacts/activities/ContactBrowserActivity.java
+++ b/src/com/android/contacts/activities/ContactBrowserActivity.java
@@ -40,7 +40,7 @@
 import com.android.contacts.list.ProviderStatusLoader;
 import com.android.contacts.list.ProviderStatusLoader.ProviderStatusListener;
 import com.android.contacts.list.StrequentContactListFragment;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.preference.ContactsPreferenceActivity;
 import com.android.contacts.util.AccountSelectionUtil;
 import com.android.contacts.util.AccountsListAdapter;
@@ -865,7 +865,7 @@
 
     private void createNewContact() {
         final ArrayList<Account> accounts =
-                AccountTypes.getInstance(this).getAccounts(true);
+                AccountTypeManager.getInstance(this).getAccounts(true);
         if (accounts.size() <= 1 || mAddContactImageView == null) {
             // No account to choose or no control to anchor the popup-menu to
             // ==> just go straight to the editor which will disambig if necessary
diff --git a/src/com/android/contacts/activities/ContactEditorActivity.java b/src/com/android/contacts/activities/ContactEditorActivity.java
index a76a2a0..04d0f44 100644
--- a/src/com/android/contacts/activities/ContactEditorActivity.java
+++ b/src/com/android/contacts/activities/ContactEditorActivity.java
@@ -22,7 +22,7 @@
 import com.android.contacts.editor.ContactEditorFragment.SaveMode;
 import com.android.contacts.interactions.ContactDeletionInteraction;
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.util.DialogManager;
 
 import android.accounts.Account;
@@ -216,7 +216,8 @@
 
         @Override
         public void onCustomCreateContactActivityRequested(Account account, Bundle intentExtras) {
-            final AccountTypes accountTypes = AccountTypes.getInstance(ContactEditorActivity.this);
+            final AccountTypeManager accountTypes =
+                    AccountTypeManager.getInstance(ContactEditorActivity.this);
             final AccountType accountType = accountTypes.getAccountType(account.type);
 
             Intent intent = new Intent();
@@ -238,7 +239,8 @@
         @Override
         public void onCustomEditContactActivityRequested(Account account, Uri rawContactUri,
                 Bundle intentExtras, boolean redirect) {
-            final AccountTypes accountTypes = AccountTypes.getInstance(ContactEditorActivity.this);
+            final AccountTypeManager accountTypes =
+                    AccountTypeManager.getInstance(ContactEditorActivity.this);
             final AccountType accountType = accountTypes.getAccountType(account.type);
 
             Intent intent = new Intent();
diff --git a/src/com/android/contacts/detail/ContactDetailFragment.java b/src/com/android/contacts/detail/ContactDetailFragment.java
index e56be7b..039ce2b 100644
--- a/src/com/android/contacts/detail/ContactDetailFragment.java
+++ b/src/com/android/contacts/detail/ContactDetailFragment.java
@@ -29,7 +29,7 @@
 import com.android.contacts.model.AccountType;
 import com.android.contacts.model.AccountType.DataKind;
 import com.android.contacts.model.AccountType.EditType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.util.Constants;
 import com.android.contacts.util.DataStatus;
 import com.android.contacts.util.DateUtils;
@@ -361,7 +361,7 @@
 
         mWritableRawContactIds.clear();
 
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
 
         // Build up method entries
         if (mContactData == null) {
@@ -1132,7 +1132,7 @@
             }
             case Directory.EXPORT_SUPPORT_ANY_ACCOUNT: {
                 final ArrayList<Account> accounts =
-                        AccountTypes.getInstance(mContext).getAccounts(true);
+                        AccountTypeManager.getInstance(mContext).getAccounts(true);
                 if (accounts.isEmpty()) {
                     createCopy(null);
                     return;  // Don't show a dialog.
diff --git a/src/com/android/contacts/editor/AggregationSuggestionView.java b/src/com/android/contacts/editor/AggregationSuggestionView.java
index da17bca..5403731 100644
--- a/src/com/android/contacts/editor/AggregationSuggestionView.java
+++ b/src/com/android/contacts/editor/AggregationSuggestionView.java
@@ -20,7 +20,7 @@
 import com.android.contacts.editor.AggregationSuggestionEngine.RawContact;
 import com.android.contacts.editor.AggregationSuggestionEngine.Suggestion;
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.google.android.collect.Lists;
 
 import android.content.Context;
@@ -115,7 +115,7 @@
             return false;
         }
 
-        AccountTypes accountTypes = AccountTypes.getInstance(getContext());
+        AccountTypeManager accountTypes = AccountTypeManager.getInstance(getContext());
         for (RawContact rawContact : mRawContacts) {
             String accountType = rawContact.accountType;
             if (accountType == null) {
diff --git a/src/com/android/contacts/editor/ContactEditorFragment.java b/src/com/android/contacts/editor/ContactEditorFragment.java
index 50d2578..e104bc5 100644
--- a/src/com/android/contacts/editor/ContactEditorFragment.java
+++ b/src/com/android/contacts/editor/ContactEditorFragment.java
@@ -24,9 +24,8 @@
 import com.android.contacts.activities.JoinContactActivity;
 import com.android.contacts.editor.AggregationSuggestionEngine.Suggestion;
 import com.android.contacts.editor.Editor.EditorListener;
-import com.android.contacts.editor.ExternalRawContactEditorView.Listener;
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.model.EntityDelta;
 import com.android.contacts.model.EntityDelta.ValuesDelta;
 import com.android.contacts.model.EntityDeltaList;
@@ -383,7 +382,7 @@
             Entity entity = entities.get(0);
             ContentValues entityValues = entity.getEntityValues();
             String type = entityValues.getAsString(RawContacts.ACCOUNT_TYPE);
-            AccountType accountType = AccountTypes.getInstance(mContext).getAccountType(type);
+            AccountType accountType = AccountTypeManager.getInstance(mContext).getAccountType(type);
             if (accountType.getEditContactActivityClassName() != null) {
                 if (mListener != null) {
                     String name = entityValues.getAsString(RawContacts.ACCOUNT_NAME);
@@ -434,7 +433,7 @@
             return;
         }
 
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         for (EntityDelta state : mState) {
             final String accountType = state.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
             final AccountType type = accountTypes.getAccountType(accountType);
@@ -447,7 +446,8 @@
     }
 
     private void selectAccountAndCreateContact() {
-        final ArrayList<Account> accounts = AccountTypes.getInstance(mContext).getAccounts(true);
+        final ArrayList<Account> accounts =
+                AccountTypeManager.getInstance(mContext).getAccounts(true);
         // No Accounts available.  Create a phone-local contact.
         if (accounts.isEmpty()) {
             createContact(null);
@@ -471,7 +471,7 @@
      *     be created.
      */
     private void createContact(Account account) {
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         final AccountType accountType =
                 accountTypes.getAccountType(account != null ? account.type : null);
 
@@ -528,7 +528,7 @@
 
         final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         int size = mState.size();
         for (int i = 0; i < size; i++) {
             // TODO ensure proper ordering of entities in the list
@@ -669,7 +669,7 @@
         // If we just started creating a new contact and haven't added any data, it's too
         // early to do a join
         if (mState.size() == 1 && mState.get(0).isContactInsert()) {
-            final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+            final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
             EntityModifier.trimEmpty(mState, accountTypes);
             if (mState.buildDiff().isEmpty()) {
                 Toast.makeText(getActivity(), R.string.toast_join_with_empty_contact,
@@ -775,7 +775,7 @@
         mStatus = Status.SAVING;
 
         // Trim any empty fields, and RawContacts, before persisting
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         EntityModifier.trimEmpty(mState, accountTypes);
 
         if (mState.buildDiff().isEmpty()) {
@@ -818,7 +818,7 @@
     }
 
     private boolean revert() {
-        final AccountTypes accountType = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountType = AccountTypeManager.getInstance(mContext);
         if (mState.buildDiff().isEmpty()) {
             doRevertAction();
         } else {
@@ -934,7 +934,7 @@
      * Returns true if there is at least one writable raw contact in the current contact.
      */
     private boolean isContactWritable() {
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         int size = mState.size();
         for (int i = 0; i < size; i++) {
             ValuesDelta values = mState.get(i).getValues();
@@ -1021,7 +1021,7 @@
                 return 0;
             }
 
-            final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+            final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
             String accountType2 = one.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
             final AccountType type1 = accountTypes.getAccountType(accountType2);
             accountType2 = two.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
diff --git a/src/com/android/contacts/interactions/ContactDeletionInteraction.java b/src/com/android/contacts/interactions/ContactDeletionInteraction.java
index 654c8cf..0030845 100644
--- a/src/com/android/contacts/interactions/ContactDeletionInteraction.java
+++ b/src/com/android/contacts/interactions/ContactDeletionInteraction.java
@@ -19,7 +19,7 @@
 import com.android.contacts.ContactSaveService;
 import com.android.contacts.R;
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.google.android.collect.Sets;
 
 import android.app.Activity;
@@ -143,7 +143,7 @@
         HashSet<Long>  readOnlyRawContacts = Sets.newHashSet();
         HashSet<Long>  writableRawContacts = Sets.newHashSet();
 
-        AccountTypes accountTypes = AccountTypes.getInstance(getActivity());
+        AccountTypeManager accountTypes = AccountTypeManager.getInstance(getActivity());
         cursor.moveToPosition(-1);
         while (cursor.moveToNext()) {
             final long rawContactId = cursor.getLong(COLUMN_INDEX_RAW_CONTACT_ID);
diff --git a/src/com/android/contacts/interactions/ImportExportInteraction.java b/src/com/android/contacts/interactions/ImportExportInteraction.java
index 418882e..1774946 100644
--- a/src/com/android/contacts/interactions/ImportExportInteraction.java
+++ b/src/com/android/contacts/interactions/ImportExportInteraction.java
@@ -17,7 +17,7 @@
 package com.android.contacts.interactions;
 
 import com.android.contacts.R;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.util.AccountSelectionUtil;
 import com.android.contacts.vcard.ExportVCardActivity;
 
@@ -199,7 +199,7 @@
         // - more than one accounts -> ask the user
         // - just one account -> use the account without asking the user
         // - no account -> use phone-local storage without asking the user
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         final List<Account> accountList = accountTypes.getAccounts(true);
         final int size = accountList.size();
         if (size > 1) {
diff --git a/src/com/android/contacts/interactions/PhoneNumberInteraction.java b/src/com/android/contacts/interactions/PhoneNumberInteraction.java
index c130b3a..1a43c9a 100644
--- a/src/com/android/contacts/interactions/PhoneNumberInteraction.java
+++ b/src/com/android/contacts/interactions/PhoneNumberInteraction.java
@@ -23,7 +23,7 @@
 import com.android.contacts.model.AccountType;
 import com.android.contacts.model.AccountType.DataKind;
 import com.android.contacts.model.AccountType.StringInflater;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -128,11 +128,11 @@
      * A list adapter that populates the list of contact's phone numbers.
      */
     private class PhoneItemAdapter extends ArrayAdapter<PhoneItem> {
-        private final AccountTypes mAccountTypes;
+        private final AccountTypeManager mAccountTypes;
 
         public PhoneItemAdapter(Context context) {
             super(context, R.layout.phone_disambig_item, android.R.id.text2);
-            mAccountTypes = AccountTypes.getInstance(context);
+            mAccountTypes = AccountTypeManager.getInstance(context);
         }
 
         @Override
diff --git a/src/com/android/contacts/list/ContactListFilterLoader.java b/src/com/android/contacts/list/ContactListFilterLoader.java
index 5aaf2df..82749ff 100644
--- a/src/com/android/contacts/list/ContactListFilterLoader.java
+++ b/src/com/android/contacts/list/ContactListFilterLoader.java
@@ -17,7 +17,7 @@
 package com.android.contacts.list;
 
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 
 import android.accounts.Account;
 import android.content.AsyncTaskLoader;
@@ -76,7 +76,7 @@
 
         ArrayList<ContactListFilter> results = new ArrayList<ContactListFilter>();
         Context context = getContext();
-        final AccountTypes accountTypes = AccountTypes.getInstance(context);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context);
         ArrayList<Account> accounts = accountTypes.getAccounts(false);
         for (Account account : accounts) {
             AccountType accountType = accountTypes.getAccountType(account.type);
diff --git a/src/com/android/contacts/list/CustomContactListFilterActivity.java b/src/com/android/contacts/list/CustomContactListFilterActivity.java
index 03f9b89..f2fb40a 100644
--- a/src/com/android/contacts/list/CustomContactListFilterActivity.java
+++ b/src/com/android/contacts/list/CustomContactListFilterActivity.java
@@ -19,7 +19,7 @@
 import com.android.contacts.ContactsSearchManager;
 import com.android.contacts.R;
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.model.EntityDelta.ValuesDelta;
 import com.android.contacts.model.GoogleAccountType;
 import com.android.contacts.preference.ContactsPreferences;
@@ -154,7 +154,7 @@
 
     /**
      * Background operation to build set of {@link AccountDisplay} for each
-     * {@link AccountTypes#getAccounts(boolean)} that provides groups.
+     * {@link AccountTypeManager#getAccounts(boolean)} that provides groups.
      */
     private static class QueryGroupsTask extends
             WeakAsyncTask<Void, Void, AccountSet, CustomContactListFilterActivity> {
@@ -166,7 +166,7 @@
         protected AccountSet doInBackground(CustomContactListFilterActivity target,
                 Void... params) {
             final Context context = target;
-            final AccountTypes accountTypes = AccountTypes.getInstance(context);
+            final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context);
             final ContentResolver resolver = context.getContentResolver();
 
             // Inflate groups entry for each account
@@ -503,7 +503,7 @@
     protected static class DisplayAdapter extends BaseExpandableListAdapter {
         private Context mContext;
         private LayoutInflater mInflater;
-        private AccountTypes mAccountTypes;
+        private AccountTypeManager mAccountTypes;
         private AccountSet mAccounts;
 
         private boolean mChildWithPhones = false;
@@ -511,7 +511,7 @@
         public DisplayAdapter(Context context) {
             mContext = context;
             mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-            mAccountTypes = AccountTypes.getInstance(context);
+            mAccountTypes = AccountTypeManager.getInstance(context);
         }
 
         public void setAccounts(AccountSet accounts) {
diff --git a/src/com/android/contacts/model/AccountType.java b/src/com/android/contacts/model/AccountType.java
index 365e17e..456b27b 100644
--- a/src/com/android/contacts/model/AccountType.java
+++ b/src/com/android/contacts/model/AccountType.java
@@ -143,7 +143,7 @@
     /**
      * Find the {@link DataKind} for a specific MIME-type, if it's handled by
      * this data source. If you may need a fallback {@link DataKind}, use
-     * {@link AccountTypes#getKindOrFallback(String, String, Context)}.
+     * {@link AccountTypeManager#getKindOrFallback(String, String, Context)}.
      */
     public DataKind getKindForMimetype(String mimeType) {
         return this.mMimeKinds.get(mimeType);
diff --git a/src/com/android/contacts/model/AccountTypes.java b/src/com/android/contacts/model/AccountTypeManager.java
similarity index 95%
rename from src/com/android/contacts/model/AccountTypes.java
rename to src/com/android/contacts/model/AccountTypeManager.java
index d9b692d..4355986 100644
--- a/src/com/android/contacts/model/AccountTypes.java
+++ b/src/com/android/contacts/model/AccountTypeManager.java
@@ -19,7 +19,6 @@
 import com.android.contacts.model.AccountType.DataKind;
 import com.google.android.collect.Lists;
 import com.google.android.collect.Maps;
-import com.google.android.collect.Sets;
 import com.google.i18n.phonenumbers.PhoneNumberUtil;
 
 import android.accounts.Account;
@@ -41,14 +40,12 @@
 import android.os.RemoteException;
 import android.os.SystemClock;
 import android.provider.ContactsContract;
-import android.text.TextUtils;
 import android.util.Log;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Locale;
 import java.util.concurrent.CountDownLatch;
 
@@ -56,7 +53,7 @@
  * Singleton holder for all parsed {@link AccountType} available on the
  * system, typically filled through {@link PackageManager} queries.
  */
-public class AccountTypes extends BroadcastReceiver
+public class AccountTypeManager extends BroadcastReceiver
         implements OnAccountsUpdateListener, SyncStatusObserver {
     private static final String TAG = "ContactAccountTypes";
 
@@ -78,7 +75,7 @@
     /* A latch that ensures that asynchronous initialization completes before data is used */
     private volatile CountDownLatch mInitializationLatch = new CountDownLatch(1);
 
-    private static AccountTypes sInstance = null;
+    private static AccountTypeManager sInstance = null;
 
     private static final Comparator<Account> ACCOUNT_COMPARATOR = new Comparator<Account>() {
 
@@ -93,24 +90,24 @@
     };
 
     /**
-     * Requests the singleton instance of {@link AccountTypes} with data bound from
+     * Requests the singleton instance of {@link AccountTypeManager} with data bound from
      * the available authenticators. This method can safely be called from the UI thread.
      */
-    public static synchronized AccountTypes getInstance(Context context) {
+    public static synchronized AccountTypeManager getInstance(Context context) {
         if (sInstance == null) {
-            sInstance = new AccountTypes(context.getApplicationContext());
+            sInstance = new AccountTypeManager(context.getApplicationContext());
         }
         return sInstance;
     }
 
-    public static void injectAccountTypes(AccountTypes injectedAccountTypes) {
+    public static void injectAccountTypes(AccountTypeManager injectedAccountTypes) {
         sInstance = injectedAccountTypes;
     }
 
     /**
      * Internal constructor that only performs initial parsing.
      */
-    private AccountTypes(Context context) {
+    private AccountTypeManager(Context context) {
         mContext = context;
         mAccountManager = AccountManager.get(mContext);
 
@@ -154,7 +151,7 @@
     }
 
     /** @hide exposed for unit tests */
-    public AccountTypes(AccountType... accountTypes) {
+    public AccountTypeManager(AccountType... accountTypes) {
         for (AccountType accountType : accountTypes) {
             mAccountTypes.put(accountType.accountType, accountType);
         }
diff --git a/src/com/android/contacts/model/EntityModifier.java b/src/com/android/contacts/model/EntityModifier.java
index 84364fb..c58d813 100644
--- a/src/com/android/contacts/model/EntityModifier.java
+++ b/src/com/android/contacts/model/EntityModifier.java
@@ -350,11 +350,11 @@
 
     /**
      * Processing to trim any empty {@link ValuesDelta} and {@link EntityDelta}
-     * from the given {@link EntityDeltaList}, assuming the given {@link AccountTypes}
+     * from the given {@link EntityDeltaList}, assuming the given {@link AccountTypeManager}
      * dictates the structure for various fields. This method ignores rows not
      * described by the {@link AccountType}.
      */
-    public static void trimEmpty(EntityDeltaList set, AccountTypes accountTypes) {
+    public static void trimEmpty(EntityDeltaList set, AccountTypeManager accountTypes) {
         for (EntityDelta state : set) {
             final String accountType = state.getValues().getAsString(RawContacts.ACCOUNT_TYPE);
             final AccountType source = accountTypes.getAccountType(accountType);
diff --git a/src/com/android/contacts/quickcontact/QuickContactWindow.java b/src/com/android/contacts/quickcontact/QuickContactWindow.java
index afeb2a9..ce7580c 100644
--- a/src/com/android/contacts/quickcontact/QuickContactWindow.java
+++ b/src/com/android/contacts/quickcontact/QuickContactWindow.java
@@ -21,7 +21,7 @@
 import com.android.contacts.ContactSaveService;
 import com.android.contacts.R;
 import com.android.contacts.model.AccountType.DataKind;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.util.Constants;
 import com.android.contacts.util.DataStatus;
 import com.android.contacts.util.NotifyingAsyncQueryHandler;
@@ -654,7 +654,7 @@
         mDefaultsMap.clear();
 
         final DataStatus status = new DataStatus();
-        final AccountTypes accountTypes = AccountTypes.getInstance(mContext);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(mContext);
         final ImageView photoView = (ImageView)mHeader.findViewById(R.id.photo);
 
         Bitmap photoBitmap = null;
diff --git a/src/com/android/contacts/util/AccountSelectionUtil.java b/src/com/android/contacts/util/AccountSelectionUtil.java
index febdc49..46d20b8 100644
--- a/src/com/android/contacts/util/AccountSelectionUtil.java
+++ b/src/com/android/contacts/util/AccountSelectionUtil.java
@@ -33,7 +33,7 @@
 
 import com.android.contacts.R;
 import com.android.contacts.model.AccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 
 import java.util.List;
 
@@ -87,7 +87,7 @@
     public static Dialog getSelectAccountDialog(Context context, int resId,
             DialogInterface.OnClickListener onClickListener,
             DialogInterface.OnCancelListener onCancelListener) {
-        final AccountTypes accountTypes = AccountTypes.getInstance(context);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context);
         final List<Account> writableAccountList = accountTypes.getAccounts(true);
 
         Log.i(LOG_TAG, "The number of available accounts: " + writableAccountList.size());
diff --git a/src/com/android/contacts/util/AccountsListAdapter.java b/src/com/android/contacts/util/AccountsListAdapter.java
index 4832bc0..8dbfc8d 100644
--- a/src/com/android/contacts/util/AccountsListAdapter.java
+++ b/src/com/android/contacts/util/AccountsListAdapter.java
@@ -17,7 +17,7 @@
 package com.android.contacts.util;
 
 import com.android.contacts.R;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.model.AccountType;
 
 import android.accounts.Account;
@@ -37,12 +37,12 @@
 public final class AccountsListAdapter extends BaseAdapter {
     private final LayoutInflater mInflater;
     private final List<Account> mAccounts;
-    private final AccountTypes mAccountTypes;
+    private final AccountTypeManager mAccountTypes;
     private final Context mContext;
 
     public AccountsListAdapter(Context context, boolean writableOnly) {
         mContext = context;
-        mAccountTypes = AccountTypes.getInstance(context);
+        mAccountTypes = AccountTypeManager.getInstance(context);
         mAccounts = mAccountTypes.getAccounts(writableOnly);
         mInflater = LayoutInflater.from(context);
     }
diff --git a/src/com/android/contacts/vcard/ImportVCardActivity.java b/src/com/android/contacts/vcard/ImportVCardActivity.java
index 67e3797..e417d09 100644
--- a/src/com/android/contacts/vcard/ImportVCardActivity.java
+++ b/src/com/android/contacts/vcard/ImportVCardActivity.java
@@ -17,7 +17,7 @@
 package com.android.contacts.vcard;
 
 import com.android.contacts.R;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.util.AccountSelectionUtil;
 import com.android.vcard.VCardEntryCounter;
 import com.android.vcard.VCardInterpreterCollection;
@@ -769,7 +769,7 @@
         if (!TextUtils.isEmpty(accountName) && !TextUtils.isEmpty(accountType)) {
             mAccount = new Account(accountName, accountType);
         } else {
-            final AccountTypes accountTypes = AccountTypes.getInstance(this);
+            final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this);
             final List<Account> accountList = accountTypes.getAccounts(true);
             if (accountList.size() == 0) {
                 mAccount = null;
diff --git a/src/com/android/contacts/vcard/SelectAccountActivity.java b/src/com/android/contacts/vcard/SelectAccountActivity.java
index 91e6902..203a205 100644
--- a/src/com/android/contacts/vcard/SelectAccountActivity.java
+++ b/src/com/android/contacts/vcard/SelectAccountActivity.java
@@ -24,7 +24,7 @@
 import android.util.Log;
 
 import com.android.contacts.R;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.util.AccountSelectionUtil;
 
 import java.util.List;
@@ -56,7 +56,7 @@
         // - just one account -> use the account without asking the user
         // - no account -> use phone-local storage without asking the user
         final int resId = R.string.import_from_sdcard;
-        final AccountTypes accountTypes = AccountTypes.getInstance(this);
+        final AccountTypeManager accountTypes = AccountTypeManager.getInstance(this);
         final List<Account> accountList = accountTypes.getAccounts(true);
         if (accountList.size() == 0) {
             Log.w(LOG_TAG, "Account does not exist");
diff --git a/tests/src/com/android/contacts/EntityModifierTests.java b/tests/src/com/android/contacts/EntityModifierTests.java
index 349d260..95aa567 100644
--- a/tests/src/com/android/contacts/EntityModifierTests.java
+++ b/tests/src/com/android/contacts/EntityModifierTests.java
@@ -24,7 +24,7 @@
 import com.android.contacts.model.EntityDelta;
 import com.android.contacts.model.EntityModifier;
 import com.android.contacts.model.EntityDeltaList;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.model.AccountType.DataKind;
 import com.android.contacts.model.AccountType.EditType;
 import com.android.contacts.model.EntityDelta.ValuesDelta;
@@ -145,10 +145,10 @@
     }
 
     /**
-     * Build {@link AccountTypes} instance.
+     * Build {@link AccountTypeManager} instance.
      */
-    protected AccountTypes getAccountTypes(AccountType... sources) {
-        return new AccountTypes(sources);
+    protected AccountTypeManager getAccountTypes(AccountType... types) {
+        return new AccountTypeManager(types);
     }
 
     /**
@@ -497,9 +497,9 @@
     }
 
     public void testTrimInsertEmpty() {
-        final AccountType source = getAccountType();
-        final AccountTypes sources = getAccountTypes(source);
-        final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
+        final AccountType accountType = getAccountType();
+        final AccountTypeManager accountTypes = getAccountTypes(accountType);
+        final DataKind kindPhone = accountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
         // Try creating a contact without any child entries
@@ -517,16 +517,16 @@
         }
 
         // Trim empty rows and try again, expecting no insert
-        EntityModifier.trimEmpty(set, sources);
+        EntityModifier.trimEmpty(set, accountTypes);
         diff.clear();
         state.buildDiff(diff);
         assertEquals("Unexpected operations", 0, diff.size());
     }
 
     public void testTrimInsertInsert() {
-        final AccountType source = getAccountType();
-        final AccountTypes sources = getAccountTypes(source);
-        final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
+        final AccountType accountType = getAccountType();
+        final AccountTypeManager accountTypes = getAccountTypes(accountType);
+        final DataKind kindPhone = accountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
         // Try creating a contact with single empty entry
@@ -550,16 +550,16 @@
         }
 
         // Trim empty rows and try again, expecting silence
-        EntityModifier.trimEmpty(set, sources);
+        EntityModifier.trimEmpty(set, accountTypes);
         diff.clear();
         state.buildDiff(diff);
         assertEquals("Unexpected operations", 0, diff.size());
     }
 
     public void testTrimUpdateRemain() {
-        final AccountType source = getAccountType();
-        final AccountTypes sources = getAccountTypes(source);
-        final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
+        final AccountType accountType = getAccountType();
+        final AccountTypeManager accountTypes = getAccountTypes(accountType);
+        final DataKind kindPhone = accountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
         // Build "before" with two phone numbers
@@ -606,7 +606,7 @@
         }
 
         // Now run trim, which should turn that update into delete
-        EntityModifier.trimEmpty(set, sources);
+        EntityModifier.trimEmpty(set, accountTypes);
         diff.clear();
         state.buildDiff(diff);
         assertEquals("Unexpected operations", 3, diff.size());
@@ -628,9 +628,9 @@
     }
 
     public void testTrimUpdateUpdate() {
-        final AccountType source = getAccountType();
-        final AccountTypes sources = getAccountTypes(source);
-        final DataKind kindPhone = source.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
+        final AccountType accountType = getAccountType();
+        final AccountTypeManager accountTypes = getAccountTypes(accountType);
+        final DataKind kindPhone = accountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE);
         final EditType typeHome = EntityModifier.getType(kindPhone, Phone.TYPE_HOME);
 
         // Build "before" with two phone numbers
@@ -671,7 +671,7 @@
         }
 
         // Now run trim, which should turn into deleting the whole contact
-        EntityModifier.trimEmpty(set, sources);
+        EntityModifier.trimEmpty(set, accountTypes);
         diff.clear();
         state.buildDiff(diff);
         assertEquals("Unexpected operations", 1, diff.size());
@@ -683,8 +683,7 @@
     }
 
     public void testParseExtrasExistingName() {
-        final AccountType source = getAccountType();
-        final DataKind kindName = source.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE);
+        final AccountType accountType = getAccountType();
 
         // Build "before" name
         final ContentValues first = new ContentValues();
@@ -696,15 +695,14 @@
         final EntityDelta state = getEntity(TEST_ID, first);
         final Bundle extras = new Bundle();
         extras.putString(Insert.NAME, TEST_NAME2);
-        EntityModifier.parseExtras(mContext, source, state, extras);
+        EntityModifier.parseExtras(mContext, accountType, state, extras);
 
         final int nameCount = state.getMimeEntriesCount(StructuredName.CONTENT_ITEM_TYPE, true);
         assertEquals("Unexpected names", 1, nameCount);
     }
 
     public void testParseExtrasIgnoreLimit() {
-        final AccountType source = getAccountType();
-        final DataKind kindIm = source.getKindForMimetype(Im.CONTENT_ITEM_TYPE);
+        final AccountType accountType = getAccountType();
 
         // Build "before" IM
         final ContentValues first = new ContentValues();
@@ -715,37 +713,38 @@
         final EntityDelta state = getEntity(TEST_ID, first);
         final int beforeCount = state.getMimeEntries(Im.CONTENT_ITEM_TYPE).size();
 
-        // We should ignore data that doesn't fit source rules, since source
+        // We should ignore data that doesn't fit account type rules, since account type
         // only allows single Im
         final Bundle extras = new Bundle();
         extras.putInt(Insert.IM_PROTOCOL, Im.PROTOCOL_GOOGLE_TALK);
         extras.putString(Insert.IM_HANDLE, TEST_IM);
-        EntityModifier.parseExtras(mContext, source, state, extras);
+        EntityModifier.parseExtras(mContext, accountType, state, extras);
 
         final int afterCount = state.getMimeEntries(Im.CONTENT_ITEM_TYPE).size();
-        assertEquals("Broke source rules", beforeCount, afterCount);
+        assertEquals("Broke account type rules", beforeCount, afterCount);
     }
 
     public void testParseExtrasIgnoreUnhandled() {
-        final AccountType source = getAccountType();
+        final AccountType accountType = getAccountType();
         final EntityDelta state = getEntity(TEST_ID);
 
-        // We should silently ignore types unsupported by source
+        // We should silently ignore types unsupported by account type
         final Bundle extras = new Bundle();
         extras.putString(Insert.POSTAL, TEST_POSTAL);
-        EntityModifier.parseExtras(mContext, source, state, extras);
+        EntityModifier.parseExtras(mContext, accountType, state, extras);
 
-        assertNull("Broke source rules", state.getMimeEntries(StructuredPostal.CONTENT_ITEM_TYPE));
+        assertNull("Broke accoun type rules",
+                state.getMimeEntries(StructuredPostal.CONTENT_ITEM_TYPE));
     }
 
     public void testParseExtrasJobTitle() {
-        final AccountType source = getAccountType();
+        final AccountType accountType = getAccountType();
         final EntityDelta state = getEntity(TEST_ID);
 
         // Make sure that we create partial Organizations
         final Bundle extras = new Bundle();
         extras.putString(Insert.JOB_TITLE, TEST_NAME);
-        EntityModifier.parseExtras(mContext, source, state, extras);
+        EntityModifier.parseExtras(mContext, accountType, state, extras);
 
         final int count = state.getMimeEntries(Organization.CONTENT_ITEM_TYPE).size();
         assertEquals("Expected to create organization", 1, count);
diff --git a/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java b/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java
index d507741..d361536 100644
--- a/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java
+++ b/tests/src/com/android/contacts/interactions/ContactDeletionInteractionTest.java
@@ -18,11 +18,11 @@
 
 import com.android.contacts.ContactsApplication;
 import com.android.contacts.R;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 import com.android.contacts.test.FragmentTestActivity;
 import com.android.contacts.test.InjectedServices;
 import com.android.contacts.tests.mocks.ContactsMockContext;
-import com.android.contacts.tests.mocks.MockAccountTypes;
+import com.android.contacts.tests.mocks.MockAccountTypeManager;
 import com.android.contacts.tests.mocks.MockContentProvider;
 import com.android.contacts.tests.mocks.MockContentProvider.Query;
 
@@ -72,38 +72,38 @@
         InjectedServices services = new InjectedServices();
         services.setContentResolver(mContext.getContentResolver());
         ContactsApplication.injectContentResolver(services);
-        AccountTypes.injectAccountTypes(new MockAccountTypes());
+        AccountTypeManager.injectAccountTypes(new MockAccountTypeManager());
         mContactsProvider = mContext.getContactsProvider();
     }
 
     @Override
     protected void tearDown() throws Exception {
         ContactsApplication.injectContentResolver(null);
-        AccountTypes.injectAccountTypes(null);
+        AccountTypeManager.injectAccountTypes(null);
         super.tearDown();
     }
 
     public void testSingleWritableRawContact() {
-        expectQuery().returnRow(1, MockAccountTypes.WRITABLE_ACCOUNT_TYPE, 13, "foo");
+        expectQuery().returnRow(1, MockAccountTypeManager.WRITABLE_ACCOUNT_TYPE, 13, "foo");
         assertWithMessageId(R.string.deleteConfirmation);
     }
 
     public void testReadOnlyRawContacts() {
-        expectQuery().returnRow(1, MockAccountTypes.READONLY_ACCOUNT_TYPE, 13, "foo");
+        expectQuery().returnRow(1, MockAccountTypeManager.READONLY_ACCOUNT_TYPE, 13, "foo");
         assertWithMessageId(R.string.readOnlyContactWarning);
     }
 
     public void testMixOfWritableAndReadOnlyRawContacts() {
         expectQuery()
-                .returnRow(1, MockAccountTypes.WRITABLE_ACCOUNT_TYPE, 13, "foo")
-                .returnRow(2, MockAccountTypes.READONLY_ACCOUNT_TYPE, 13, "foo");
+                .returnRow(1, MockAccountTypeManager.WRITABLE_ACCOUNT_TYPE, 13, "foo")
+                .returnRow(2, MockAccountTypeManager.READONLY_ACCOUNT_TYPE, 13, "foo");
         assertWithMessageId(R.string.readOnlyContactDeleteConfirmation);
     }
 
     public void testMultipleWritableRawContacts() {
         expectQuery()
-                .returnRow(1, MockAccountTypes.WRITABLE_ACCOUNT_TYPE, 13, "foo")
-                .returnRow(2, MockAccountTypes.WRITABLE_ACCOUNT_TYPE, 13, "foo");
+                .returnRow(1, MockAccountTypeManager.WRITABLE_ACCOUNT_TYPE, 13, "foo")
+                .returnRow(2, MockAccountTypeManager.WRITABLE_ACCOUNT_TYPE, 13, "foo");
         assertWithMessageId(R.string.multipleContactDeleteConfirmation);
     }
 
diff --git a/tests/src/com/android/contacts/tests/mocks/MockAccountTypes.java b/tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java
similarity index 89%
rename from tests/src/com/android/contacts/tests/mocks/MockAccountTypes.java
rename to tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java
index 8cc82c6..626fe3e 100644
--- a/tests/src/com/android/contacts/tests/mocks/MockAccountTypes.java
+++ b/tests/src/com/android/contacts/tests/mocks/MockAccountTypeManager.java
@@ -17,12 +17,12 @@
 
 import com.android.contacts.model.AccountType;
 import com.android.contacts.model.FallbackAccountType;
-import com.android.contacts.model.AccountTypes;
+import com.android.contacts.model.AccountTypeManager;
 
 /**
- * A mock {@link AccountTypes} class.
+ * A mock {@link AccountTypeManager} class.
  */
-public class MockAccountTypes extends AccountTypes {
+public class MockAccountTypeManager extends AccountTypeManager {
 
     public static final String WRITABLE_ACCOUNT_TYPE = "writable";
     public static final String READONLY_ACCOUNT_TYPE = "readonly";