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

Commit 85f81a6b authored by Makoto Onuki's avatar Makoto Onuki Committed by android-build-merger
Browse files

Merge "Fix sync back-off" into oc-dr1-dev

am: 9fd497cd

Change-Id: I3b64f7eed95f3fb1670e9fdf4f3825b1deeddfad
parents 7d0dcbb1 9fd497cd
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);
        }

        /**