use of android.content.SyncAdapterType in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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(mActivity.getString(R.string.account_sync_summary_some_on, 3, 4));
}
use of android.content.SyncAdapterType in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccountSyncPreferenceControllerTest method updateSummary_syncDisabled_shouldNotCount.
@Test
public void updateSummary_syncDisabled_shouldNotCount() {
SyncAdapterType syncAdapterType = new SyncAdapterType("authority", /* authority */
"type1", /* accountType */
true, /* userVisible */
true);
SyncAdapterType[] syncAdapters = { syncAdapterType };
ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
ShadowContentResolver.setSyncAutomatically("authority", false);
ShadowContentResolver.setMasterSyncAutomatically(3, true);
mController.updateSummary(mPreference);
assertThat(mPreference.getSummary()).isEqualTo(mActivity.getString(R.string.account_sync_summary_all_off));
}
use of android.content.SyncAdapterType in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ChooseAccountPreferenceControllerTest method updateAuthDescriptions_twoProvider_shouldAddTwoPreference.
@Test
public void updateAuthDescriptions_twoProvider_shouldAddTwoPreference() {
final AuthenticatorDescription authDesc = new AuthenticatorDescription("com.acct1", "com.android.settings", R.string.header_add_an_account, 0, 0, 0, false);
final AuthenticatorDescription authDesc2 = new AuthenticatorDescription("com.acct2", "com.android.settings", R.string.header_add_an_account, 0, 0, 0, false);
ShadowAccountManager.addAuthenticator(authDesc);
ShadowAccountManager.addAuthenticator(authDesc2);
final SyncAdapterType[] syncAdapters = { new SyncAdapterType("authority", /* authority */
"com.acct1", /* accountType */
false, /* userVisible */
true), new SyncAdapterType("authority2", /* authority */
"com.acct2", /* accountType */
false, /* userVisible */
true) };
ShadowContentResolver.setSyncAdapterTypes(syncAdapters);
doReturn("label").when(mController).getLabelForType(anyString());
doReturn("label2").when(mController).getLabelForType(anyString());
doReturn(new ColorDrawable()).when(mController).getDrawableForType(anyString());
doReturn(new ColorDrawable()).when(mController).getDrawableForType(anyString());
mController.initialize(null, null, new UserHandle(3), mActivity);
mController.displayPreference(mPreferenceScreen);
assertThat(mPreferenceScreen.getPreferenceCount()).isEqualTo(2);
}
use of android.content.SyncAdapterType in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AccountSyncSettings method updateAccountSwitches.
private void updateAccountSwitches() {
mInvisibleAdapters.clear();
SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(mUserHandle.getIdentifier());
ArrayList<SyncAdapterType> authorities = new ArrayList<>();
for (int i = 0, n = syncAdapters.length; i < n; i++) {
final SyncAdapterType sa = syncAdapters[i];
// Only keep track of sync adapters for this account
if (!sa.accountType.equals(mAccount.type))
continue;
if (sa.isUserVisible()) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "updateAccountSwitches: added authority " + sa.authority + " to accountType " + sa.accountType);
}
authorities.add(sa);
} else {
// keep track of invisible sync adapters, so sync now forces
// them to sync as well.
mInvisibleAdapters.add(sa);
}
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "looking for sync adapters that match account " + mAccount);
}
cacheRemoveAllPrefs(getPreferenceScreen());
getCachedPreference(EntityHeaderController.PREF_KEY_APP_HEADER);
for (int j = 0, m = authorities.size(); j < m; j++) {
final SyncAdapterType syncAdapter = authorities.get(j);
// We could check services here....
int syncState = ContentResolver.getIsSyncableAsUser(mAccount, syncAdapter.authority, mUserHandle.getIdentifier());
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, " found authority " + syncAdapter.authority + " " + syncState);
}
if (syncState > 0) {
final int uid;
try {
uid = getContext().getPackageManager().getPackageUidAsUser(syncAdapter.getPackageName(), mUserHandle.getIdentifier());
addSyncStateSwitch(mAccount, syncAdapter.authority, syncAdapter.getPackageName(), uid);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "No uid for package" + syncAdapter.getPackageName(), e);
}
}
}
removeCachedPrefs(getPreferenceScreen());
}
use of android.content.SyncAdapterType in project android_packages_apps_Settings by omnirom.
the class AccountSyncSettings method updateAccountSwitches.
private void updateAccountSwitches() {
mInvisibleAdapters.clear();
SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypesAsUser(mUserHandle.getIdentifier());
ArrayList<SyncAdapterType> authorities = new ArrayList<>();
for (int i = 0, n = syncAdapters.length; i < n; i++) {
final SyncAdapterType sa = syncAdapters[i];
// Only keep track of sync adapters for this account
if (!sa.accountType.equals(mAccount.type))
continue;
if (sa.isUserVisible()) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "updateAccountSwitches: added authority " + sa.authority + " to accountType " + sa.accountType);
}
authorities.add(sa);
} else {
// keep track of invisible sync adapters, so sync now forces
// them to sync as well.
mInvisibleAdapters.add(sa);
}
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "looking for sync adapters that match account " + mAccount);
}
cacheRemoveAllPrefs(getPreferenceScreen());
getCachedPreference(EntityHeaderController.PREF_KEY_APP_HEADER);
for (int j = 0, m = authorities.size(); j < m; j++) {
final SyncAdapterType syncAdapter = authorities.get(j);
// We could check services here....
int syncState = ContentResolver.getIsSyncableAsUser(mAccount, syncAdapter.authority, mUserHandle.getIdentifier());
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, " found authority " + syncAdapter.authority + " " + syncState);
}
if (syncState > 0) {
final int uid;
try {
uid = getContext().getPackageManager().getPackageUidAsUser(syncAdapter.getPackageName(), mUserHandle.getIdentifier());
addSyncStateSwitch(mAccount, syncAdapter.authority, syncAdapter.getPackageName(), uid);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "No uid for package" + syncAdapter.getPackageName(), e);
}
}
}
removeCachedPrefs(getPreferenceScreen());
}
Aggregations