Java 类android.content.SyncInfo 实例源码

项目:android-wg-planer    文件:SyncStatusManager.java   
@SuppressWarnings("deprecation")
private static boolean isSyncActive(Account account, String authority) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        for (SyncInfo syncInfo : ContentResolver.getCurrentSyncs()) {
            if (syncInfo.account.equals(account) && syncInfo.authority.equals(authority)) {
                return true;
            }
        }
        return false;
    } else {
        SyncInfo currentSync = ContentResolver.getCurrentSync();
        return currentSync != null && currentSync.account.equals(account) && currentSync.authority.equals(authority);
    }
}
项目:android_maplib    文件:AccountUtil.java   
public static boolean isSyncActive(Account account, String authority) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return isSyncActiveHoneycomb(account, authority);
    } else {
        SyncInfo currentSync = ContentResolver.getCurrentSync();
        return currentSync != null && currentSync.account.equals(account) && currentSync.authority.equals(authority);
    }
}
项目:android_maplib    文件:AccountUtil.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static boolean isSyncActiveHoneycomb(Account account, String authority) {
    for (SyncInfo syncInfo : ContentResolver.getCurrentSyncs()) {
        if (syncInfo.account.equals(account) && syncInfo.authority.equals(authority)) {
            return true;
        }
    }
    return false;
}
项目:XPrivacy    文件:XContentResolver.java   
@Override
protected void after(XParam param) throws Throwable {
    switch (mMethod) {
    case getCurrentSync:
        if (isRestricted(param))
            param.setResult(null);
        break;

    case getCurrentSyncs:
        if (isRestricted(param))
            param.setResult(new ArrayList<SyncInfo>());
        break;

    case getSyncAdapterTypes:
        if (isRestricted(param))
            param.setResult(new SyncAdapterType[0]);
        break;

    case openAssetFileDescriptor:
    case openFileDescriptor:
    case openInputStream:
    case openOutputStream:
    case openTypedAssetFileDescriptor:
    case openAssetFile:
    case openFile:
        if (param.args.length > 0 && param.args[0] instanceof Uri) {
            String uri = ((Uri) param.args[0]).toString();
            if (isRestrictedExtra(param, uri))
                param.setThrowable(new FileNotFoundException("XPrivacy"));
        }
        break;

    case Srv_call:
        handleCallAfter(param);
        break;

    case query:
    case Srv_query:
        handleUriAfter(param);
        break;

    case Srv_getCurrentSyncs:
    case Srv_getCurrentSyncsAsUser:
        if (param.getResult() != null)
            if (isRestricted(param)) {
                int uid = Binder.getCallingUid();
                @SuppressWarnings("unchecked")
                List<SyncInfo> listSync = (List<SyncInfo>) param.getResult();
                List<SyncInfo> listFiltered = new ArrayList<SyncInfo>();
                for (SyncInfo sync : listSync)
                    if (XAccountManager.isAccountAllowed(sync.account, uid))
                        listFiltered.add(sync);
                param.setResult(listFiltered);
            }
        break;
    }
}
项目:smarper    文件:XContentResolver.java   
@Override
protected void after(XParam param) throws Throwable {
    switch (mMethod) {
    case getCurrentSync:
        if (isRestricted(param))
            param.setResult(null);
        break;

    case getCurrentSyncs:
        if (isRestricted(param))
            param.setResult(new ArrayList<SyncInfo>());
        break;

    case getSyncAdapterTypes:
        if (isRestricted(param))
            param.setResult(new SyncAdapterType[0]);
        break;

    case openAssetFileDescriptor:
    case openFileDescriptor:
    case openInputStream:
    case openOutputStream:
    case openTypedAssetFileDescriptor:
    case openAssetFile:
    case openFile:
        if (param.args.length > 0 && param.args[0] instanceof Uri) {
            String uri = ((Uri) param.args[0]).toString();

            switch(getRestrictStateExtra(param, uri)){
                case 0:
                    //Log.d("Smarper-Storage", "XContentResolver, " + mMethod + ": " + uri + " allowed");
                    break;
                case 1:

                    if (!SmarperUtil.forbiddenPathsInitialized)
                        SmarperUtil.initializeForbiddenPaths();

                    if (uri.startsWith(SmarperUtil.moviesURI.toString()) || uri.startsWith(SmarperUtil.dcimURI.toString()) || uri.startsWith(SmarperUtil.picturesURI.toString()) || uri.startsWith(SmarperUtil.musicURI.toString())){
                        param.setThrowable(new FileNotFoundException("XPrivacy"));
                        //Log.d("Smarper-Storage", "XContentResolver, " + mMethod + ": Obfuscating " + uri);
                    }
                    else{
                        //
                        //Log.d("Smarper-Storage", "ContentResolver: " + uri + " not in public folders list, not obfuscated!");
                    }
                    break;
                case 2:
                    param.setThrowable(new FileNotFoundException("XPrivacy"));
                    break;

            }

        }
        break;

    case Srv_call:
        handleCallAfter(param);
        break;

    case query:
    case Srv_query:
        handleUriAfter(param);
        break;

    case Srv_getCurrentSyncs:
    case Srv_getCurrentSyncsAsUser:
        if (param.getResult() != null)
            if (isRestricted(param)) {
                int uid = Binder.getCallingUid();
                @SuppressWarnings("unchecked")
                List<SyncInfo> listSync = (List<SyncInfo>) param.getResult();
                List<SyncInfo> listFiltered = new ArrayList<SyncInfo>();
                for (SyncInfo sync : listSync)
                    if (XAccountManager.isAccountAllowed(sync.account, uid))
                        listFiltered.add(sync);
                param.setResult(listFiltered);
            }
        break;
    }
}
项目:xprivacy-mod    文件:XContentResolver.java   
@Override
protected void after(XParam param) throws Throwable {
    switch (mMethod) {
    case getCurrentSync:
        if (isRestricted(param))
            param.setResult(null);
        break;

    case getCurrentSyncs:
        if (isRestricted(param))
            param.setResult(new ArrayList<SyncInfo>());
        break;

    case getSyncAdapterTypes:
        if (isRestricted(param))
            param.setResult(new SyncAdapterType[0]);
        break;

    case openAssetFileDescriptor:
    case openFileDescriptor:
    case openInputStream:
    case openOutputStream:
    case openTypedAssetFileDescriptor:
    case openAssetFile:
    case openFile:
        if (param.args.length > 0 && param.args[0] instanceof Uri) {
            String uri = ((Uri) param.args[0]).toString();
            if (isRestrictedExtra(param, uri))
                param.setThrowable(new FileNotFoundException("XPrivacy"));
        }
        break;

    case Srv_call:
        handleCallAfter(param);
        break;

    case query:
    case Srv_query:
        handleUriAfter(param);
        break;

    case Srv_getCurrentSyncs:
    case Srv_getCurrentSyncsAsUser:
        if (param.getResult() != null)
            if (isRestricted(param)) {
                int uid = Binder.getCallingUid();
                @SuppressWarnings("unchecked")
                List<SyncInfo> listSync = (List<SyncInfo>) param.getResult();
                List<SyncInfo> listFiltered = new ArrayList<SyncInfo>();
                for (SyncInfo sync : listSync)
                    if (XAccountManager.isAccountAllowed(sync.account, uid))
                        listFiltered.add(sync);
                param.setResult(listFiltered);
            }
        break;
    }
}
项目:ntsync-android    文件:HoneycombHelper.java   
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static List<SyncInfo> getCurrentSyncs() {
    return ContentResolver.getCurrentSyncs();
}