类android.content.SyncInfo源码实例Demo

下面列出了怎么用android.content.SyncInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: AndroidComponentPlugin   文件: ContentService.java
/**
 * If the user id supplied is different to the calling user, the caller must hold the
 * INTERACT_ACROSS_USERS_FULL permission.
 */
@Override
public List<SyncInfo> getCurrentSyncsAsUser(int userId) {
    enforceCrossUserPermission(userId,
            "no permission to read the sync settings for user " + userId);
    mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
            "no permission to read the sync stats");

    final boolean canAccessAccounts =
        mContext.checkCallingOrSelfPermission(Manifest.permission.GET_ACCOUNTS)
            == PackageManager.PERMISSION_GRANTED;
    long identityToken = clearCallingIdentity();
    try {
        return getSyncManager().getSyncStorageEngine()
            .getCurrentSyncsCopy(userId, canAccessAccounts);
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
 
源代码2 项目: AndroidComponentPlugin   文件: ContentService.java
/**
 * If the user id supplied is different to the calling user, the caller must hold the
 * INTERACT_ACROSS_USERS_FULL permission.
 */
@Override
public List<SyncInfo> getCurrentSyncsAsUser(int userId) {
    enforceCrossUserPermission(userId,
            "no permission to read the sync settings for user " + userId);
    mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
            "no permission to read the sync stats");

    final boolean canAccessAccounts =
        mContext.checkCallingOrSelfPermission(Manifest.permission.GET_ACCOUNTS)
            == PackageManager.PERMISSION_GRANTED;
    long identityToken = clearCallingIdentity();
    try {
        return getSyncManager().getSyncStorageEngine()
            .getCurrentSyncsCopy(userId, canAccessAccounts);
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
 
源代码3 项目: android_9.0.0_r45   文件: ContentService.java
/**
 * If the user id supplied is different to the calling user, the caller must hold the
 * INTERACT_ACROSS_USERS_FULL permission.
 */
@Override
public List<SyncInfo> getCurrentSyncsAsUser(int userId) {
    enforceCrossUserPermission(userId,
            "no permission to read the sync settings for user " + userId);
    mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_STATS,
            "no permission to read the sync stats");

    final boolean canAccessAccounts =
        mContext.checkCallingOrSelfPermission(Manifest.permission.GET_ACCOUNTS)
            == PackageManager.PERMISSION_GRANTED;
    long identityToken = clearCallingIdentity();
    try {
        return getSyncManager().getSyncStorageEngine()
            .getCurrentSyncsCopy(userId, canAccessAccounts);
    } finally {
        restoreCallingIdentity(identityToken);
    }
}
 
源代码4 项目: android_9.0.0_r45   文件: SyncStorageEngine.java
/**
 * Returns true if there is currently a sync operation being actively processed for the given
 * target.
 */
public boolean isSyncActive(EndPoint info) {
    synchronized (mAuthorities) {
        for (SyncInfo syncInfo : getCurrentSyncs(info.userId)) {
            AuthorityInfo ainfo = getAuthority(syncInfo.authorityId);
            if (ainfo != null && ainfo.target.matchesSpec(info)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码5 项目: android_9.0.0_r45   文件: SyncStorageEngine.java
/**
 * Called to indicate that a previously active sync is no longer active.
 */
public void removeActiveSync(SyncInfo syncInfo, int userId) {
    synchronized (mAuthorities) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Slog.v(TAG, "removeActiveSync: account=" + syncInfo.account
                    + " user=" + userId
                    + " auth=" + syncInfo.authority);
        }
        getCurrentSyncs(userId).remove(syncInfo);
    }

    reportActiveChange();
}
 
源代码6 项目: android_9.0.0_r45   文件: SyncStorageEngine.java
private List<SyncInfo> getCurrentSyncsLocked(int userId) {
    ArrayList<SyncInfo> syncs = mCurrentSyncs.get(userId);
    if (syncs == null) {
        syncs = new ArrayList<SyncInfo>();
        mCurrentSyncs.put(userId, syncs);
    }
    return syncs;
}
 
源代码7 项目: android_maplib   文件: AccountUtil.java
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;
}
 
源代码8 项目: AndroidComponentPlugin   文件: ContentService.java
@Override
public List<SyncInfo> getCurrentSyncs() {
    return getCurrentSyncsAsUser(UserHandle.getCallingUserId());
}
 
源代码9 项目: AndroidComponentPlugin   文件: ContentService.java
@Override
public List<SyncInfo> getCurrentSyncs() {
    return getCurrentSyncsAsUser(UserHandle.getCallingUserId());
}
 
源代码10 项目: android_9.0.0_r45   文件: ContentService.java
@Override
public List<SyncInfo> getCurrentSyncs() {
    return getCurrentSyncsAsUser(UserHandle.getCallingUserId());
}
 
源代码11 项目: android_9.0.0_r45   文件: SyncStorageEngine.java
/**
 * Return a list of the currently active syncs. Note that the returned
 * items are the real, live active sync objects, so be careful what you do
 * with it.
 */
private List<SyncInfo> getCurrentSyncs(int userId) {
    synchronized (mAuthorities) {
        return getCurrentSyncsLocked(userId);
    }
}
 
源代码12 项目: 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;
	}
}
 
 类所在包
 同包方法