use of android.content.SyncAdapterType in project android_packages_apps_Settings by LineageOS.
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));
}
use of android.content.SyncAdapterType in project android_packages_apps_Settings by LineageOS.
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 LineageOS.
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 LineageOS.
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));
}
use of android.content.SyncAdapterType in project android_packages_apps_Settings by DirtyUnicorns.
the class AccountSyncPreferenceController method updateSummary.
@VisibleForTesting
void updateSummary(Preference preference) {
if (mAccount == null) {
return;
}
final int userId = mUserHandle.getIdentifier();
final SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(userId);
int total = 0;
int enabled = 0;
if (syncAdapters != null) {
for (int i = 0, n = syncAdapters.length; i < n; i++) {
final SyncAdapterType sa = syncAdapters[i];
if (!sa.accountType.equals(mAccount.type) || !sa.isUserVisible()) {
continue;
}
final int syncState = ContentResolver.getIsSyncableAsUser(mAccount, sa.authority, userId);
if (syncState > 0) {
total++;
final boolean syncEnabled = ContentResolver.getSyncAutomaticallyAsUser(mAccount, sa.authority, userId);
final boolean oneTimeSyncMode = !ContentResolver.getMasterSyncAutomaticallyAsUser(userId);
if (oneTimeSyncMode || syncEnabled) {
enabled++;
}
}
}
}
if (enabled == 0) {
preference.setSummary(R.string.account_sync_summary_all_off);
} else if (enabled == total) {
preference.setSummary(R.string.account_sync_summary_all_on);
} else {
preference.setSummary(mContext.getString(R.string.account_sync_summary_some_on, enabled, total));
}
}
Aggregations