Loading src/com/android/contacts/model/AccountTypeManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -410,8 +410,8 @@ class AccountTypeManagerImpl extends AccountTypeManager AccountType accountType; if (GoogleAccountType.ACCOUNT_TYPE.equals(type)) { accountType = new GoogleAccountType(mContext, auth.packageName); } else if (ExchangeAccountType.ACCOUNT_TYPE.equals(type)) { accountType = new ExchangeAccountType(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 Loading src/com/android/contacts/model/account/ExchangeAccountType.java +8 −3 Original line number Diff line number Diff line Loading @@ -41,10 +41,11 @@ import java.util.Locale; public class ExchangeAccountType extends BaseAccountType { private static final String TAG = "ExchangeAccountType"; public static final String ACCOUNT_TYPE = "com.android.exchange"; public static final String ACCOUNT_TYPE_AOSP = "com.android.exchange"; public static final String ACCOUNT_TYPE_GOOGLE = "com.google.android.exchange"; public ExchangeAccountType(Context context, String authenticatorPackageName) { this.accountType = ACCOUNT_TYPE; public ExchangeAccountType(Context context, String authenticatorPackageName, String type) { this.accountType = type; this.resourcePackageName = null; this.syncAdapterPackageName = authenticatorPackageName; Loading @@ -70,6 +71,10 @@ public class ExchangeAccountType extends BaseAccountType { } } public static boolean isExchangeType(String type) { return ACCOUNT_TYPE_AOSP.equals(type) || ACCOUNT_TYPE_GOOGLE.equals(type); } @Override protected DataKind addDataKindStructuredName(Context context) throws DefinitionException { DataKind kind = addKind(new DataKind(StructuredName.CONTENT_ITEM_TYPE, Loading tests/src/com/android/contacts/RawContactModifierTests.java +14 −12 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ public class RawContactModifierTests extends AndroidTestCase { private static final String TEST_ACCOUNT_NAME = "unittest@example.com"; private static final String TEST_ACCOUNT_TYPE = "com.example.unittest"; private static final String EXCHANGE_ACCT_TYPE = "com.android.exchange"; @Override public void setUp() { mContext = getContext(); Loading Loading @@ -770,7 +772,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateWithDisplayNameFromGoogleToExchange1() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE); ContactsMockContext context = new ContactsMockContext(getContext()); Loading Loading @@ -806,7 +808,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateWithDisplayNameFromGoogleToExchange2() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE); ContactsMockContext context = new ContactsMockContext(getContext()); Loading Loading @@ -846,7 +848,7 @@ public class RawContactModifierTests extends AndroidTestCase { } public void testMigrateWithStructuredNameFromExchangeToGoogle() { AccountType oldAccountType = new ExchangeAccountType(getContext(), ""); AccountType oldAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); AccountType newAccountType = new GoogleAccountType(getContext(), ""); DataKind kind = newAccountType.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE); Loading Loading @@ -891,7 +893,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigratePostalFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(StructuredPostal.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading @@ -913,7 +915,7 @@ public class RawContactModifierTests extends AndroidTestCase { } public void testMigratePostalFromExchangeToGoogle() { AccountType oldAccountType = new ExchangeAccountType(getContext(), ""); AccountType oldAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); AccountType newAccountType = new GoogleAccountType(getContext(), ""); DataKind kind = newAccountType.getKindForMimetype(StructuredPostal.CONTENT_ITEM_TYPE); Loading Loading @@ -948,11 +950,11 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateEventFromGoogleToExchange1() { testMigrateEventCommon(new GoogleAccountType(getContext(), ""), new ExchangeAccountType(getContext(), "")); new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE)); } public void testMigrateEventFromExchangeToGoogle() { testMigrateEventCommon(new ExchangeAccountType(getContext(), ""), testMigrateEventCommon(new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE), new GoogleAccountType(getContext(), "")); } Loading Loading @@ -980,7 +982,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateEventFromGoogleToExchange2() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Event.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading @@ -1012,7 +1014,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateEmailFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Email.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading @@ -1062,7 +1064,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateImFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Im.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading @@ -1129,7 +1131,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigratePhoneFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE); // Create 5 numbers. Loading Loading @@ -1207,7 +1209,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateOrganizationFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Organization.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading
src/com/android/contacts/model/AccountTypeManager.java +2 −2 Original line number Diff line number Diff line Loading @@ -410,8 +410,8 @@ class AccountTypeManagerImpl extends AccountTypeManager AccountType accountType; if (GoogleAccountType.ACCOUNT_TYPE.equals(type)) { accountType = new GoogleAccountType(mContext, auth.packageName); } else if (ExchangeAccountType.ACCOUNT_TYPE.equals(type)) { accountType = new ExchangeAccountType(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 Loading
src/com/android/contacts/model/account/ExchangeAccountType.java +8 −3 Original line number Diff line number Diff line Loading @@ -41,10 +41,11 @@ import java.util.Locale; public class ExchangeAccountType extends BaseAccountType { private static final String TAG = "ExchangeAccountType"; public static final String ACCOUNT_TYPE = "com.android.exchange"; public static final String ACCOUNT_TYPE_AOSP = "com.android.exchange"; public static final String ACCOUNT_TYPE_GOOGLE = "com.google.android.exchange"; public ExchangeAccountType(Context context, String authenticatorPackageName) { this.accountType = ACCOUNT_TYPE; public ExchangeAccountType(Context context, String authenticatorPackageName, String type) { this.accountType = type; this.resourcePackageName = null; this.syncAdapterPackageName = authenticatorPackageName; Loading @@ -70,6 +71,10 @@ public class ExchangeAccountType extends BaseAccountType { } } public static boolean isExchangeType(String type) { return ACCOUNT_TYPE_AOSP.equals(type) || ACCOUNT_TYPE_GOOGLE.equals(type); } @Override protected DataKind addDataKindStructuredName(Context context) throws DefinitionException { DataKind kind = addKind(new DataKind(StructuredName.CONTENT_ITEM_TYPE, Loading
tests/src/com/android/contacts/RawContactModifierTests.java +14 −12 Original line number Diff line number Diff line Loading @@ -77,6 +77,8 @@ public class RawContactModifierTests extends AndroidTestCase { private static final String TEST_ACCOUNT_NAME = "unittest@example.com"; private static final String TEST_ACCOUNT_TYPE = "com.example.unittest"; private static final String EXCHANGE_ACCT_TYPE = "com.android.exchange"; @Override public void setUp() { mContext = getContext(); Loading Loading @@ -770,7 +772,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateWithDisplayNameFromGoogleToExchange1() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE); ContactsMockContext context = new ContactsMockContext(getContext()); Loading Loading @@ -806,7 +808,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateWithDisplayNameFromGoogleToExchange2() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE); ContactsMockContext context = new ContactsMockContext(getContext()); Loading Loading @@ -846,7 +848,7 @@ public class RawContactModifierTests extends AndroidTestCase { } public void testMigrateWithStructuredNameFromExchangeToGoogle() { AccountType oldAccountType = new ExchangeAccountType(getContext(), ""); AccountType oldAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); AccountType newAccountType = new GoogleAccountType(getContext(), ""); DataKind kind = newAccountType.getKindForMimetype(StructuredName.CONTENT_ITEM_TYPE); Loading Loading @@ -891,7 +893,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigratePostalFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(StructuredPostal.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading @@ -913,7 +915,7 @@ public class RawContactModifierTests extends AndroidTestCase { } public void testMigratePostalFromExchangeToGoogle() { AccountType oldAccountType = new ExchangeAccountType(getContext(), ""); AccountType oldAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); AccountType newAccountType = new GoogleAccountType(getContext(), ""); DataKind kind = newAccountType.getKindForMimetype(StructuredPostal.CONTENT_ITEM_TYPE); Loading Loading @@ -948,11 +950,11 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateEventFromGoogleToExchange1() { testMigrateEventCommon(new GoogleAccountType(getContext(), ""), new ExchangeAccountType(getContext(), "")); new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE)); } public void testMigrateEventFromExchangeToGoogle() { testMigrateEventCommon(new ExchangeAccountType(getContext(), ""), testMigrateEventCommon(new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE), new GoogleAccountType(getContext(), "")); } Loading Loading @@ -980,7 +982,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateEventFromGoogleToExchange2() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Event.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading @@ -1012,7 +1014,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateEmailFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Email.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading @@ -1062,7 +1064,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateImFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Im.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading Loading @@ -1129,7 +1131,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigratePhoneFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Phone.CONTENT_ITEM_TYPE); // Create 5 numbers. Loading Loading @@ -1207,7 +1209,7 @@ public class RawContactModifierTests extends AndroidTestCase { public void testMigrateOrganizationFromGoogleToExchange() { AccountType oldAccountType = new GoogleAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), ""); AccountType newAccountType = new ExchangeAccountType(getContext(), "", EXCHANGE_ACCT_TYPE); DataKind kind = newAccountType.getKindForMimetype(Organization.CONTENT_ITEM_TYPE); RawContactDelta oldState = new RawContactDelta(); Loading