Search in sources :

Example 51 with SyncAdapterType

use of android.content.SyncAdapterType in project platform_packages_apps_Settings by BlissRoms.

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

use of android.content.SyncAdapterType in project platform_packages_apps_Settings by BlissRoms.

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

use of android.content.SyncAdapterType in project VirtualApp by asLody.

the class VContentService method parseSyncAdapterType.

private SyncAdapterType parseSyncAdapterType(Resources res, AttributeSet set) {
    TypedArray obtainAttributes = res.obtainAttributes(set, R_Hide.styleable.SyncAdapter.get());
    try {
        String contentAuthority = obtainAttributes.getString(R_Hide.styleable.SyncAdapter_contentAuthority.get());
        String accountType = obtainAttributes.getString(R_Hide.styleable.SyncAdapter_accountType.get());
        if (contentAuthority == null || accountType == null) {
            obtainAttributes.recycle();
            return null;
        }
        boolean userVisible = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_userVisible.get(), true);
        boolean supportsUploading = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_supportsUploading.get(), true);
        boolean isAlwaysSyncable = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_isAlwaysSyncable.get(), true);
        boolean allowParallelSyncs = obtainAttributes.getBoolean(R_Hide.styleable.SyncAdapter_allowParallelSyncs.get(), true);
        String settingsActivity = obtainAttributes.getString(R_Hide.styleable.SyncAdapter_settingsActivity.get());
        SyncAdapterType type;
        if (SyncAdapterTypeN.ctor != null) {
            type = SyncAdapterTypeN.ctor.newInstance(contentAuthority, accountType, userVisible, supportsUploading, isAlwaysSyncable, allowParallelSyncs, settingsActivity, null);
            obtainAttributes.recycle();
            return type;
        }
        type = mirror.android.content.SyncAdapterType.ctor.newInstance(contentAuthority, accountType, userVisible, supportsUploading, isAlwaysSyncable, allowParallelSyncs, settingsActivity);
        obtainAttributes.recycle();
        return type;
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return null;
}
Also used : TypedArray(android.content.res.TypedArray) SyncAdapterType(android.content.SyncAdapterType)

Example 54 with SyncAdapterType

use of android.content.SyncAdapterType in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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(mActivity.getString(R.string.account_sync_summary_all_off));
}
Also used : SyncAdapterType(android.content.SyncAdapterType) Test(org.junit.Test)

Example 55 with SyncAdapterType

use of android.content.SyncAdapterType in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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(mActivity.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