Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03eaa114 authored by Marc Blank's avatar Marc Blank Committed by Android (Google) Code Review
Browse files

Merge "Allow both AOSP and Google account types for Exchange" into jb-mr1-dev

parents 3215711c de8a6640
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+8 −3
Original line number Diff line number Diff line
@@ -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;

@@ -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,
+14 −12
Original line number Diff line number Diff line
@@ -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();
@@ -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());
@@ -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());
@@ -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);

@@ -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();
@@ -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);

@@ -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(), ""));
    }

@@ -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();
@@ -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();
@@ -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();
@@ -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.
@@ -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();