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

Commit f19c7029 authored by Kweku Adams's avatar Kweku Adams
Browse files

Ensure SyncManager doesn't schedule an EJ with a delay.

Expedited jobs are not allowed to be scheduled with explicit delays set
and callers will crash if they try to do so. SyncManager sets delays in
a variety of cases. Now, we demote an EJ to a regular job if a delay is
set for any reason.

Bug: 178852366
Test: atest ContentResolverTest (all)
Test: atest CtsSyncManagerTest
Test: atest SyncOperationTest
Test: atest SyncManagerTest
Test: atest SyncRequestTest
Change-Id: Ibf9e7b1ce640bdc3b1f3796bbedf24ca79856c26
parent e5a10560
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1525,6 +1525,10 @@ public class SyncManager {

        if (minDelay < 0) {
            minDelay = 0;
        } else if (minDelay > 0) {
            // We can't apply a delay to an EJ. If we want to delay it, we must demote it to a
            // regular job.
            syncOperation.scheduleEjAsRegularJob = true;
        }

        // Check if duplicate syncs are pending. If found, keep one with least expected run time.
@@ -1735,6 +1739,8 @@ public class SyncManager {
        }

        operation.enableBackoff();
        // Never run a rescheduled requested-EJ-sync as an EJ.
        operation.scheduleEjAsRegularJob = true;

        if (operation.hasDoNotRetry() && !syncResult.syncAlreadyInProgress) {
            // syncAlreadyInProgress flag is set by AbstractThreadedSyncAdapter. The sync adapter
@@ -3142,7 +3148,7 @@ public class SyncManager {
                scheduleSyncOperationH(op.createOneTimeSyncOperation(), delay);
            } else {
                // mSyncJobService.callJobFinished is async, so cancel the job to ensure we don't
                // find the this job in the pending jobs list while looking for duplicates
                // find this job in the pending jobs list while looking for duplicates
                // before scheduling it at a later time.
                cancelJob(op, "deferSyncH()");
                scheduleSyncOperationH(op, delay);