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
This commit is contained in:
Kweku Adams
2021-04-30 14:16:14 -07:00
parent f9c4ee1fd3
commit d23ce9610b
3 changed files with 7 additions and 6 deletions

View File

@@ -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");
}

View File

@@ -1478,12 +1478,11 @@ 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()) {
syncOperation.scheduleEjAsRegularJob = true;
}
// 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

View File

@@ -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;
}