Search in sources :

Example 36 with SyncAdapterType

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

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 37 with SyncAdapterType

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

the class AccountSyncPreferenceControllerTest method updateSummary_multipleSyncAdapters_shouldSetSummary.

@Test
public void updateSummary_multipleSyncAdapters_shouldSetSummary() {
    SyncAdapterType syncAdapterType1 = new SyncAdapterType("authority1", /* authority */
    "type1", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType syncAdapterType2 = new SyncAdapterType("authority2", /* authority */
    "type1", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType syncAdapterType3 = new SyncAdapterType("authority3", /* authority */
    "type1", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType syncAdapterType4 = new SyncAdapterType("authority4", /* authority */
    "type1", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType[] syncAdapters = { syncAdapterType1, syncAdapterType2, syncAdapterType3, syncAdapterType4 };
    ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
    ShadowContentResolver.setSyncAutomatically("authority4", false);
    mController.updateSummary(mPreference);
    assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.account_sync_summary_some_on, 3, 4));
}
Also used : SyncAdapterType(android.content.SyncAdapterType) Test(org.junit.Test)

Example 38 with SyncAdapterType

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

the class AccountSyncPreferenceControllerTest method updateSummary_notSyncable_shouldNotCount.

@Test
public void updateSummary_notSyncable_shouldNotCount() {
    SyncAdapterType syncAdapterType = new SyncAdapterType("authority", /* authority */
    "type1", /* accountType */
    true, /* userVisible */
    true);
    SyncAdapterType[] syncAdapters = { syncAdapterType };
    ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
    ShadowContentResolver.setSyncable("authority", 0);
    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 39 with SyncAdapterType

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

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 40 with SyncAdapterType

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

the class AccountSyncPreferenceControllerTest method updateSummary_syncEnabled_shouldCount.

@Test
public void updateSummary_syncEnabled_shouldCount() {
    SyncAdapterType syncAdapterType = new SyncAdapterType("authority", /* authority */
    "type1", /* 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_on));
}
Also used : SyncAdapterType(android.content.SyncAdapterType) Test(org.junit.Test)

Aggregations

SyncAdapterType (android.content.SyncAdapterType)127 Test (org.junit.Test)46 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 ArrayList (java.util.ArrayList)13 AccountAndUser (android.accounts.AccountAndUser)12 RemoteException (android.os.RemoteException)11 UserHandle (android.os.UserHandle)9 Bundle (android.os.Bundle)8 Preference (android.support.v7.preference.Preference)8 HashSet (java.util.HashSet)8 SyncStatusInfo (android.content.SyncStatusInfo)7 PackageInfo (android.content.pm.PackageInfo)6 VisibleForTesting (android.support.annotation.VisibleForTesting)6 List (java.util.List)6 AuthenticatorDescription (android.accounts.AuthenticatorDescription)5 RemoteCallback (android.os.RemoteCallback)5