Stop tracking ghost jobs.
Change I4a31cb1fd5e0a8997eddaed3ecb45a4309abfd59 fixed a problem that resulted in JobScheduler keeping around jobs that were finished and not rescheduled (ie. ghost jobs). Unfortunately, JS was telling controllers that these ghost jobs had started running, but then not telling them they had stopped running. Now, we log an error when we encounter a ghost job and make sure to tell controllers to stop tracking them. Bug: 228334264 Test: N/A Change-Id: I48e59319c86be2c0494ecdc31e907f2554d8492e
This commit is contained in:
@@ -1745,7 +1745,13 @@ public class JobSchedulerService extends com.android.server.SystemService
|
||||
|
||||
// Remove from store as well as controllers.
|
||||
final boolean removed = mJobs.remove(jobStatus, removeFromPersisted);
|
||||
if (removed && mReadyToRock) {
|
||||
if (!removed) {
|
||||
// We never create JobStatus objects for the express purpose of removing them, and this
|
||||
// method is only ever called for jobs that were saved in the JobStore at some point,
|
||||
// so if we can't find it, something went seriously wrong.
|
||||
Slog.wtfStack(TAG, "Job didn't exist in JobStore");
|
||||
}
|
||||
if (mReadyToRock) {
|
||||
for (int i = 0; i < mControllers.size(); i++) {
|
||||
StateController controller = mControllers.get(i);
|
||||
controller.maybeStopTrackingJobLocked(jobStatus, incomingJob, false);
|
||||
|
||||
@@ -992,6 +992,10 @@ public final class JobServiceContext implements ServiceConnection {
|
||||
if (mVerb == VERB_FINISHED) {
|
||||
return;
|
||||
}
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "Cleaning up " + mRunningJob.toShortString()
|
||||
+ " reschedule=" + reschedule + " reason=" + reason);
|
||||
}
|
||||
applyStoppedReasonLocked(reason);
|
||||
completedJob = mRunningJob;
|
||||
final int internalStopReason = mParams.getInternalStopReasonCode();
|
||||
|
||||
Reference in New Issue
Block a user