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

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

Fix EJ syncs.

1. Only downgrade an EJ that doesn't have the IGNORE_BACKOFF extra when
   we are actually attempting to back off the job.
2. Allow EJs to have the FLAG_EXEMPT_FROM_APP_STANDBY flag since that
   can only be set by the system and won't cause issues.

Also propagate the scheduleEjAsRegularJob bit through the job extras to
help with debugging.

Bug: 178852366
Test: atest ContentResolverTest (all)
Test: atest CtsJobSchedulerTestCases:JobInfoTest
Test: atest CtsSyncManagerTest
Test: atest SyncOperationTest
Test: atest SyncManagerTest
Test: atest SyncRequestTest
Change-Id: I133d089a4d770a3cc37df72f8b38d234b24077df
parent f9c4ee1f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1697,7 +1697,7 @@ public class JobInfo implements Parcelable {
                throw new IllegalArgumentException("An expedited job cannot be periodic");
            }
            if ((constraintFlags & ~CONSTRAINT_FLAG_STORAGE_NOT_LOW) != 0
                    || (flags & ~FLAG_EXPEDITED) != 0) {
                    || (flags & ~(FLAG_EXPEDITED | FLAG_EXEMPT_FROM_APP_STANDBY)) != 0) {
                throw new IllegalArgumentException(
                        "An expedited job can only have network and storage-not-low constraints");
            }
+4 −5
Original line number Diff line number Diff line
@@ -1478,13 +1478,12 @@ public class SyncManager {
                        + logSafe(syncOperation.target));
                backoff = new Pair<Long, Long>(SyncStorageEngine.NOT_IN_BACKOFF_MODE,
                        SyncStorageEngine.NOT_IN_BACKOFF_MODE);
            } else {
            } else if (backoff.first != SyncStorageEngine.NOT_IN_BACKOFF_MODE) {
                // if an EJ is being backed-off but doesn't have SYNC_EXTRAS_IGNORE_BACKOFF set,
                // reschedule it as a regular job
                if (syncOperation.isScheduledAsExpeditedJob()) {
                // reschedule it as a regular job. Immediately downgrade here in case minDelay is
                // set to 0.
                syncOperation.scheduleEjAsRegularJob = true;
            }
            }
            long now = SystemClock.elapsedRealtime();
            long backoffDelay = backoff.first == SyncStorageEngine.NOT_IN_BACKOFF_MODE ? 0
                    : backoff.first - now;
+2 −0
Original line number Diff line number Diff line
@@ -258,6 +258,7 @@ public class SyncOperation {
        jobInfoExtras.putLong("expectedRuntime", expectedRuntime);
        jobInfoExtras.putInt("retries", retries);
        jobInfoExtras.putInt("syncExemptionFlag", syncExemptionFlag);
        jobInfoExtras.putBoolean("ejDowngradedToRegular", scheduleEjAsRegularJob);
        return jobInfoExtras;
    }

@@ -325,6 +326,7 @@ public class SyncOperation {
        op.jobId = jobExtras.getInt("jobId");
        op.expectedRuntime = jobExtras.getLong("expectedRuntime");
        op.retries = jobExtras.getInt("retries");
        op.scheduleEjAsRegularJob = jobExtras.getBoolean("ejDowngradedToRegular");
        return op;
    }