Search in sources :

Example 96 with SyncAdapterType

use of android.content.SyncAdapterType in project android_packages_apps_Settings by DirtyUnicorns.

the class ChooseAccountActivity method getAuthoritiesForAccountType.

public ArrayList<String> getAuthoritiesForAccountType(String type) {
    if (mAccountTypeToAuthorities == null) {
        mAccountTypeToAuthorities = Maps.newHashMap();
        SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(mUserHandle.getIdentifier());
        for (int i = 0, n = syncAdapters.length; i < n; i++) {
            final SyncAdapterType sa = syncAdapters[i];
            ArrayList<String> authorities = mAccountTypeToAuthorities.get(sa.accountType);
            if (authorities == null) {
                authorities = new ArrayList<String>();
                mAccountTypeToAuthorities.put(sa.accountType, authorities);
            }
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.d(TAG, "added authority " + sa.authority + " to accountType " + sa.accountType);
            }
            authorities.add(sa.authority);
        }
    }
    return mAccountTypeToAuthorities.get(type);
}
Also used : SyncAdapterType(android.content.SyncAdapterType)

Example 97 with SyncAdapterType

use of android.content.SyncAdapterType in project android_packages_apps_Settings by DirtyUnicorns.

the class AccountSyncPreferenceControllerTest method updateSummary_adapterInvisible_shouldNotCount.

@Test
public void updateSummary_adapterInvisible_shouldNotCount() {
    SyncAdapterType syncAdapterType = new SyncAdapterType("authority", /* authority */
    "type1", /* accountType */
    false, /* userVisible */
    true);
    SyncAdapterType[] syncAdapters = { syncAdapterType };
    ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
    mController.updateSummary(mPreference);
    assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
}
Also used : SyncAdapterType(android.content.SyncAdapterType) Test(org.junit.Test)

Example 98 with SyncAdapterType

use of android.content.SyncAdapterType in project android_packages_apps_Settings by DirtyUnicorns.

the class AccountSyncPreferenceControllerTest method updateSummary_notSameAccountType_shouldNotCount.

@Test
public void updateSummary_notSameAccountType_shouldNotCount() {
    SyncAdapterType syncAdapterType = new SyncAdapterType("authority", /* authority */
    "type5", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType[] syncAdapters = { syncAdapterType };
    ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
    mController.updateSummary(mPreference);
    assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
}
Also used : SyncAdapterType(android.content.SyncAdapterType) Test(org.junit.Test)

Example 99 with SyncAdapterType

use of android.content.SyncAdapterType in project android_packages_apps_Settings by crdroidandroid.

the class ChooseAccountActivity method getAuthoritiesForAccountType.

public ArrayList<String> getAuthoritiesForAccountType(String type) {
    if (mAccountTypeToAuthorities == null) {
        mAccountTypeToAuthorities = Maps.newHashMap();
        SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(mUserHandle.getIdentifier());
        for (int i = 0, n = syncAdapters.length; i < n; i++) {
            final SyncAdapterType sa = syncAdapters[i];
            ArrayList<String> authorities = mAccountTypeToAuthorities.get(sa.accountType);
            if (authorities == null) {
                authorities = new ArrayList<String>();
                mAccountTypeToAuthorities.put(sa.accountType, authorities);
            }
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.d(TAG, "added authority " + sa.authority + " to accountType " + sa.accountType);
            }
            authorities.add(sa.authority);
        }
    }
    return mAccountTypeToAuthorities.get(type);
}
Also used : SyncAdapterType(android.content.SyncAdapterType)

Example 100 with SyncAdapterType

use of android.content.SyncAdapterType in project android_packages_apps_Settings by crdroidandroid.

the class AccountSyncPreferenceControllerTest method updateSummary_notSameAccountType_shouldNotCount.

@Test
public void updateSummary_notSameAccountType_shouldNotCount() {
    SyncAdapterType syncAdapterType = new SyncAdapterType("authority", /* authority */
    "type5", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType[] syncAdapters = { syncAdapterType };
    ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
    mController.updateSummary(mPreference);
    assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.account_sync_summary_all_off));
}
Also used : SyncAdapterType(android.content.SyncAdapterType) Test(org.junit.Test)

Aggregations

SyncAdapterType (android.content.SyncAdapterType)132 Test (org.junit.Test)50 RegisteredServicesCache (android.content.pm.RegisteredServicesCache)33 EndPoint (com.android.server.content.SyncStorageEngine.EndPoint)30 UserInfo (android.content.pm.UserInfo)17 Account (android.accounts.Account)13 PackageManager (android.content.pm.PackageManager)13 UserHandle (android.os.UserHandle)13 ArrayList (java.util.ArrayList)13 AccountAndUser (android.accounts.AccountAndUser)12 RemoteException (android.os.RemoteException)11 AuthenticatorDescription (android.accounts.AuthenticatorDescription)9 Bundle (android.os.Bundle)8 HashSet (java.util.HashSet)8 SyncStatusInfo (android.content.SyncStatusInfo)7 Preference (android.support.v7.preference.Preference)7 PackageInfo (android.content.pm.PackageInfo)6 List (java.util.List)6 RemoteCallback (android.os.RemoteCallback)5 VisibleForTesting (android.support.annotation.VisibleForTesting)5