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

Commit 82c5c424 authored by Fred Quintana's avatar Fred Quintana
Browse files

fix a bug where if a syncmanager gets back a SyncAlreadyInProgress error

it immediately reschedules another sync, thus burning up the battery if
the sync is in progress for a while.

http://b/issue?id=2477901
parent 96d92f19
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -819,7 +819,7 @@ public class SyncManager implements OnAccountsUpdateListener {
            }
            }
            scheduleSyncOperation(new SyncOperation(operation.account, operation.syncSource,
            scheduleSyncOperation(new SyncOperation(operation.account, operation.syncSource,
                    operation.authority, operation.extras,
                    operation.authority, operation.extras,
                    DELAY_RETRY_SYNC_IN_PROGRESS_IN_SECONDS));
                    DELAY_RETRY_SYNC_IN_PROGRESS_IN_SECONDS * 1000));
        } else if (syncResult.hasSoftError()) {
        } else if (syncResult.hasSoftError()) {
            if (isLoggable) {
            if (isLoggable) {
                Log.d(TAG, "retrying sync operation because it encountered a soft error: "
                Log.d(TAG, "retrying sync operation because it encountered a soft error: "
+3 −3
Original line number Original line Diff line number Diff line
@@ -19,7 +19,7 @@ public class SyncOperation implements Comparable {
    public SyncStorageEngine.PendingOperation pendingOperation;
    public SyncStorageEngine.PendingOperation pendingOperation;


    public SyncOperation(Account account, int source, String authority, Bundle extras,
    public SyncOperation(Account account, int source, String authority, Bundle extras,
            long delay) {
            long delayInMs) {
        this.account = account;
        this.account = account;
        this.syncSource = source;
        this.syncSource = source;
        this.authority = authority;
        this.authority = authority;
@@ -33,12 +33,12 @@ public class SyncOperation implements Comparable {
        removeFalseExtra(ContentResolver.SYNC_EXTRAS_EXPEDITED);
        removeFalseExtra(ContentResolver.SYNC_EXTRAS_EXPEDITED);
        removeFalseExtra(ContentResolver.SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS);
        removeFalseExtra(ContentResolver.SYNC_EXTRAS_OVERRIDE_TOO_MANY_DELETIONS);
        final long now = SystemClock.elapsedRealtime();
        final long now = SystemClock.elapsedRealtime();
        if (delay < 0) {
        if (delayInMs < 0) {
            this.expedited = true;
            this.expedited = true;
            this.earliestRunTime = now;
            this.earliestRunTime = now;
        } else {
        } else {
            this.expedited = false;
            this.expedited = false;
            this.earliestRunTime = now + delay;
            this.earliestRunTime = now + delayInMs;
        }
        }
        this.key = toKey();
        this.key = toKey();
    }
    }