android.content.SyncInfo Java Examples
The following examples show how to use
android.content.SyncInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #2
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #3
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * 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); } }
Example #4
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * 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; }
Example #5
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #6
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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; }
Example #7
Source File: AccountUtil.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
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; }
Example #8
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
@Override public List<SyncInfo> getCurrentSyncs() { return getCurrentSyncsAsUser(UserHandle.getCallingUserId()); }
Example #9
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
@Override public List<SyncInfo> getCurrentSyncs() { return getCurrentSyncsAsUser(UserHandle.getCallingUserId()); }
Example #10
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public List<SyncInfo> getCurrentSyncs() { return getCurrentSyncsAsUser(UserHandle.getCallingUserId()); }
Example #11
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * 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); } }
Example #12
Source File: XContentResolver.java From XPrivacy with GNU General Public License v3.0 | 4 votes |
@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; } }