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);
}
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));
}
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));
}
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));
}
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));
}
Aggregations