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

Commit 9243d9ca authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix sync back-off

CL Ifb2fc5207 affected multiple different scenario:
a) When a sync finished successfully
b) When a sync finished with a failure
c) When a sync is canceled by the sync manager

Among those, c) was the actual fix for b/63773598, and the change was supposed
to not change the actual behavior of a) and b).

However it turned out it was breaking b) by interfering back-off scheduling.

This change will revert Ifb2fc5207 for a) and b) to restore the original
behavior with keeping the fix fo C.

Bug: 63773598
Bug: 64597061
Test: Manual test with test app.
Change-Id: I34e5945a7a67d55cd6138f758e97d724d4b9d4b5
parent b60e1c03
Loading
Loading
Loading
Loading
+20 −9
Original line number Diff line number Diff line
@@ -3354,12 +3354,6 @@ public class SyncManager {
            int downstreamActivity;
            int upstreamActivity;

            if (!syncOperation.isPeriodic) {
                // mSyncJobService.jobFinidhed is async, we need to ensure that this job is
                // removed from JobScheduler's pending jobs list before moving forward and
                // potentially rescheduling all pending jobs to respect new backoff values.
                getJobScheduler().cancel(syncOperation.jobId);
            }
            mLogger.log("runSyncFinishedOrCanceledH() op=", syncOperation, " result=", syncResult);

            if (syncResult != null) {
@@ -3368,6 +3362,16 @@ public class SyncManager {
                            + syncOperation + ", result " + syncResult);
                }

                // In the non-canceled case, close the active sync context before doing the rest
                // of the stuff.
                closeActiveSyncContext(activeSyncContext);

                // Note this part is probably okay to do before closeActiveSyncContext()...
                // But moved here to restore OC-dev's behavior.  See b/64597061.
                if (!syncOperation.isPeriodic) {
                    getJobScheduler().cancel(syncOperation.jobId);
                }

                if (!syncResult.hasError()) {
                    historyMessage = SyncStorageEngine.MESG_SUCCESS;
                    // TODO: set these correctly when the SyncResult is extended to include it
@@ -3404,6 +3408,11 @@ public class SyncManager {
                if (isLoggable) {
                    Slog.v(TAG, "runSyncFinishedOrCanceled [canceled]: " + syncOperation);
                }

                if (!syncOperation.isPeriodic) {
                    getJobScheduler().cancel(syncOperation.jobId);
                }

                if (activeSyncContext.mSyncAdapter != null) {
                    try {
                        mLogger.log("Calling cancelSync for runSyncFinishedOrCanceled ",
@@ -3418,10 +3427,10 @@ public class SyncManager {
                historyMessage = SyncStorageEngine.MESG_CANCELED;
                downstreamActivity = 0;
                upstreamActivity = 0;
            }

            // Close and unbind the service.  Don't use activeSyncContext.mSyncAdapter after this.
                // In the cancel sync case, close it after calling cancelSync().
                closeActiveSyncContext(activeSyncContext);
            }

            stopSyncEvent(activeSyncContext.mHistoryRowId, syncOperation, historyMessage,
                    upstreamActivity, downstreamActivity, elapsedTime);
@@ -3457,6 +3466,8 @@ public class SyncManager {
                        + activeSyncContext.toString());
            }
            mSyncHandler.removeMessages(SyncHandler.MESSAGE_MONITOR_SYNC, activeSyncContext);

            mLogger.log("closeActiveSyncContext: ", activeSyncContext);
        }

        /**