diff options
author | Makoto Onuki <omakoto@google.com> | 2017-08-15 14:56:47 -0700 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-08-17 06:07:31 +0000 |
commit | 92b424749346b860fb043dd831746a0b0d3a3e4b (patch) | |
tree | a064d4b5e5d906a5b6ba8c93089636001148d24f | |
parent | bf39d1ad15b30150d4bb08df6f63d5fec4e4dacc (diff) | |
download | base-92b424749346b860fb043dd831746a0b0d3a3e4b.tar.gz |
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
(cherry picked from commit 9243d9ca063d9ceb3d8a71f242e1e2facd122383)
-rw-r--r-- | services/core/java/com/android/server/content/SyncManager.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/content/SyncManager.java b/services/core/java/com/android/server/content/SyncManager.java index f41aa5f7993c..a9c0cb0fb661 100644 --- a/services/core/java/com/android/server/content/SyncManager.java +++ b/services/core/java/com/android/server/content/SyncManager.java @@ -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. - closeActiveSyncContext(activeSyncContext); + // 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); } /** |