Search in sources :

Example 41 with SyncAdapterType

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

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

Example 42 with SyncAdapterType

use of android.content.SyncAdapterType in project VirtualXposed by android-hacker.

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

use of android.content.SyncAdapterType in project VirtualXposed by android-hacker.

the class VContentService method generateServicesMap.

private void generateServicesMap(List<ResolveInfo> services, Map<String, SyncAdapterInfo> map, RegisteredServicesParser accountParser) {
    for (ResolveInfo info : services) {
        XmlResourceParser parser = accountParser.getParser(mContext, info.serviceInfo, "android.content.SyncAdapter");
        if (parser != null) {
            try {
                AttributeSet attributeSet = Xml.asAttributeSet(parser);
                int type;
                while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && type != XmlPullParser.START_TAG) {
                // Nothing to do
                }
                if ("sync-adapter".equals(parser.getName())) {
                    SyncAdapterType adapterType = parseSyncAdapterType(accountParser.getResources(mContext, info.serviceInfo.applicationInfo), attributeSet);
                    if (adapterType != null) {
                        String key = adapterType.accountType + "/" + adapterType.authority;
                        map.put(key, new SyncAdapterInfo(adapterType, info.serviceInfo));
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) XmlResourceParser(android.content.res.XmlResourceParser) AttributeSet(android.util.AttributeSet) SyncAdapterType(android.content.SyncAdapterType)

Example 44 with SyncAdapterType

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

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)

Example 45 with SyncAdapterType

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

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(mContext.getString(R.string.account_sync_summary_all_off));
}
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