Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bca793f authored by Rubin Xu's avatar Rubin Xu
Browse files

Remove temporary workaround of restoring periodic syncs.

Bug: 28052438
Change-Id: Ic10070043c6431fd0a1a0346d8a6f1294dc27c41
parent 2c548e0e
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -1402,24 +1402,12 @@ public class SyncManager {
        }
    }

    private void restoreLostPeriodicSyncsIfNeeded(int userId) {
        List<SyncOperation> periodicSyncs = new ArrayList<SyncOperation>();
        for (SyncOperation sync : getAllPendingSyncs()) {
            if (sync.isPeriodic && sync.target.userId == userId) {
                periodicSyncs.add(sync);
            }
        }
        mSyncStorageEngine.restorePeriodicSyncsIfNeededForUser(userId, periodicSyncs);
    }

    private void onUserUnlocked(int userId) {
        // Make sure that accounts we're about to use are valid.
        AccountManagerService.getSingleton().validateAccounts(userId);

        mSyncAdapters.invalidateCache(userId);

        restoreLostPeriodicSyncsIfNeeded(userId);

        EndPoint target = new EndPoint(null, null, userId);
        updateRunningAccounts(target);

+0 −29
Original line number Diff line number Diff line
@@ -826,35 +826,6 @@ public class SyncStorageEngine extends Handler {
        return true;
    }

    /**
     * STOPSHIP This is a temporary workaround and should be removed before shipping: b/28052438
     */
    void restorePeriodicSyncsIfNeededForUser(int userHandle, List<SyncOperation> periodicSyncs) {
        if (mPeriodicSyncAddedListener == null) {
            return;
        }
        synchronized (mAuthorities) {
            for (int i = 0; i < mAuthorities.size(); i++) {
                AuthorityInfo authority = mAuthorities.valueAt(i);
                if (authority.target.userId == userHandle && authority.enabled) {
                    boolean periodicSyncAlreadyExists = false;
                    for (SyncOperation sync : periodicSyncs) {
                        if (authority.target.matchesSpec(sync.target)) {
                            periodicSyncAlreadyExists = true;
                            break;
                        }
                    }
                    // The periodic sync must have been lost due to previous bug.
                    if (!periodicSyncAlreadyExists) {
                        mPeriodicSyncAddedListener.onPeriodicSyncAdded(authority.target,
                                new Bundle(), DEFAULT_POLL_FREQUENCY_SECONDS,
                                calculateDefaultFlexTime(DEFAULT_POLL_FREQUENCY_SECONDS));
                    }
                }
            }
        }
    }

    public void setMasterSyncAutomatically(boolean flag, int userId) {
        synchronized (mAuthorities) {
            Boolean auto = mMasterSyncAutomatically.get(userId);