/** * Attempts to perform data synchronization. * * @param syncResult (optional) the sync result object to update with statistics. * @param account the account associated with this sync * @return Whether or not the synchronization made any changes to the data. */ public boolean performSync(SyncResult syncResult, Account account, Bundle extras) { final boolean remoteSync = extras.getBoolean(SyncAdapter.EXTRA_SYNC_REMOTE, true); // remote sync consists of these operations, which we try one by one (and tolerate // individual failures on each) String[] apisToPerform = remoteSync ? new String[] {Api.API_TOPICS_LATEST, Api.API_TOPICS_HOT} : new String[] {extras.getString(Api.ARG_API_NAME)}; for (String api : apisToPerform) { try { sync(api, extras); } catch (Throwable throwable) { throwable.printStackTrace(); EventBus.getDefault().postSticky(new ExceptionEvent(mContext.getString(R.string.err_io))); LOGE(TAG, "Error performing remote sync."); increaseIoExceptions(syncResult); } } int operations = mDataHandler.getContentProviderOperationsDone(); if (syncResult != null && syncResult.stats != null) { syncResult.stats.numEntries += operations; syncResult.stats.numUpdates += operations; } LOGD( TAG, "SYNC STATS:\n" + " * Account synced: " + (account == null ? "null" : account.name) + "\n" + " * Content provider operations: " + operations); return true; }