android.content.PeriodicSync Java Examples
The following examples show how to use
android.content.PeriodicSync.
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 |
@Override public List<PeriodicSync> getPeriodicSyncs(Account account, String providerName, ComponentName cname) { if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(providerName)) { throw new IllegalArgumentException("Authority must not be empty"); } mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { return getSyncManager().getPeriodicSyncs( new SyncStorageEngine.EndPoint(account, providerName, userId)); } finally { restoreCallingIdentity(identityToken); } }
Example #2
Source File: ContentService.java From AndroidComponentPlugin with Apache License 2.0 | 6 votes |
@Override public List<PeriodicSync> getPeriodicSyncs(Account account, String providerName, ComponentName cname) { if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(providerName)) { throw new IllegalArgumentException("Authority must not be empty"); } mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { return getSyncManager().getPeriodicSyncs( new SyncStorageEngine.EndPoint(account, providerName, userId)); } finally { restoreCallingIdentity(identityToken); } }
Example #3
Source File: ContentService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public List<PeriodicSync> getPeriodicSyncs(Account account, String providerName, ComponentName cname) { if (account == null) { throw new IllegalArgumentException("Account must not be null"); } if (TextUtils.isEmpty(providerName)) { throw new IllegalArgumentException("Authority must not be empty"); } mContext.enforceCallingOrSelfPermission(Manifest.permission.READ_SYNC_SETTINGS, "no permission to read the sync settings"); int userId = UserHandle.getCallingUserId(); long identityToken = clearCallingIdentity(); try { return getSyncManager().getPeriodicSyncs( new SyncStorageEngine.EndPoint(account, providerName, userId)); } finally { restoreCallingIdentity(identityToken); } }
Example #4
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Restore all periodic syncs read from persisted files. Used to restore periodic syncs * after an OS update. */ boolean restoreAllPeriodicSyncs() { if (mPeriodicSyncAddedListener == null) { return false; } synchronized (mAuthorities) { for (int i=0; i<mAuthorities.size(); i++) { AuthorityInfo authority = mAuthorities.valueAt(i); for (PeriodicSync periodicSync: authority.periodicSyncs) { mPeriodicSyncAddedListener.onPeriodicSyncAdded(authority.target, periodicSync.extras, periodicSync.period, periodicSync.flexTime); } authority.periodicSyncs.clear(); } writeAccountInfoLocked(); } return true; }
Example #5
Source File: SyncManager.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Get a list of periodic syncs corresponding to the given target. */ public List<PeriodicSync> getPeriodicSyncs(EndPoint target) { List<SyncOperation> ops = getAllPendingSyncs(); List<PeriodicSync> periodicSyncs = new ArrayList<PeriodicSync>(); for (SyncOperation op: ops) { if (op.isPeriodic && op.target.matchesSpec(target)) { periodicSyncs.add(new PeriodicSync(op.target.account, op.target.provider, op.extras, op.periodMillis / 1000, op.flexMillis / 1000)); } } return periodicSyncs; }
Example #6
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Copy constructor for making deep-ish copies. Only the bundles stored * in periodic syncs can make unexpected changes. * * @param toCopy AuthorityInfo to be copied. */ AuthorityInfo(AuthorityInfo toCopy) { target = toCopy.target; ident = toCopy.ident; enabled = toCopy.enabled; syncable = toCopy.syncable; backoffTime = toCopy.backoffTime; backoffDelay = toCopy.backoffDelay; delayUntil = toCopy.delayUntil; periodicSyncs = new ArrayList<PeriodicSync>(); for (PeriodicSync sync : toCopy.periodicSyncs) { // Still not a perfect copy, because we are just copying the mappings. periodicSyncs.add(new PeriodicSync(sync)); } }
Example #7
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
AuthorityInfo(EndPoint info, int id) { target = info; ident = id; enabled = SYNC_ENABLED_DEFAULT; periodicSyncs = new ArrayList<PeriodicSync>(); defaultInitialisation(); }
Example #8
Source File: Listactivity.java From ImapNote2 with GNU General Public License v3.0 | 5 votes |
@Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { ((TextView) this.accountSpinner.getSelectedView()).setBackgroundColor(0xFFB6B6B6); Account account = Listactivity.accounts[pos]; // Check periodic sync. If set to 86400 (once a day), set it to 900 (15 minutes) // this is due to bad upgrade to v4 which handles offline mode and syncing // Remove this code after V4.0 if version no more used List<PeriodicSync> currentSyncs = ContentResolver.getPeriodicSyncs (account, AUTHORITY); for (PeriodicSync onesync : currentSyncs) { if (onesync.period == 86400) { ContentResolver.setIsSyncable(account, AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, AUTHORITY, true); ContentResolver.addPeriodicSync(account, AUTHORITY, new Bundle(), 60); Toast.makeText(getApplicationContext(), "Recreating this account is recommended to manage sync interval. Set to 15 minutes in the meantime", Toast.LENGTH_LONG).show(); } } // End of code Listactivity.imapNotes2Account.SetAccountname(account.name); Listactivity.imapNotes2Account.SetUsername(Listactivity.accountManager.getUserData (account, "username")); String pwd = Listactivity.accountManager.getPassword(account); Listactivity.imapNotes2Account.SetPassword(pwd); Listactivity.imapNotes2Account.SetServer(Listactivity.accountManager.getUserData (account, "server")); Listactivity.imapNotes2Account.SetPortnum(Listactivity.accountManager.getUserData (account, "portnum")); Listactivity.imapNotes2Account.SetSecurity(Listactivity.accountManager.getUserData (account, "security")); Listactivity.imapNotes2Account.SetUsesticky(accountManager.getUserData (account, "usesticky")); Listactivity.imapNotes2Account.SetSyncinterval(Listactivity.accountManager.getUserData (account, "syncinterval")); Listactivity.imapNotes2Account.SetaccountHasChanged(); Listactivity.imapNotes2Account.SetAccount(account); this.RefreshList(); }