Merge "Allow both AOSP and Google account types for Exchange" into jb-mr1-dev
diff --git a/src/com/android/contacts/model/AccountTypeManager.java b/src/com/android/contacts/model/AccountTypeManager.java
index 64f3a91..b4a3e2b 100644
--- a/src/com/android/contacts/model/AccountTypeManager.java
+++ b/src/com/android/contacts/model/AccountTypeManager.java
@@ -410,8 +410,8 @@
                 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
diff --git a/src/com/android/contacts/model/account/ExchangeAccountType.java b/src/com/android/contacts/model/account/ExchangeAccountType.java
index 5ca3308..28b1f5c 100644
--- a/src/com/android/contacts/model/account/ExchangeAccountType.java
+++ b/src/com/android/contacts/model/account/ExchangeAccountType.java
@@ -41,10 +41,11 @@
 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;
 
@@ -70,6 +71,10 @@
         }
     }
 
+    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,
diff --git a/tests/src/com/android/contacts/RawContactModifierTests.java b/tests/src/com/android/contacts/RawContactModifierTests.java
index 9254a7e..8046ed6 100644
--- a/tests/src/com/android/contacts/RawContactModifierTests.java
+++ b/tests/src/com/android/contacts/RawContactModifierTests.java
@@ -77,6 +77,8 @@
     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();
@@ -770,7 +772,7 @@
 
     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());
@@ -806,7 +808,7 @@
 
     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());
@@ -846,7 +848,7 @@
     }
 
     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);
 
@@ -891,7 +893,7 @@
 
     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();
@@ -913,7 +915,7 @@
     }
 
     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);
 
@@ -948,11 +950,11 @@
 
     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(), ""));
     }
 
@@ -980,7 +982,7 @@
 
     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();
@@ -1012,7 +1014,7 @@
 
     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();
@@ -1062,7 +1064,7 @@
 
     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();
@@ -1129,7 +1131,7 @@
 
     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.
@@ -1207,7 +1209,7 @@
 
     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();