Loading services/core/java/com/android/server/job/JobSchedulerService.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -330,7 +330,7 @@ public class JobSchedulerService extends com.android.server.SystemService private void cancelJobImpl(JobStatus cancelled) { private void cancelJobImpl(JobStatus cancelled) { if (DEBUG) Slog.d(TAG, "CANCEL: " + cancelled.toShortString()); if (DEBUG) Slog.d(TAG, "CANCEL: " + cancelled.toShortString()); stopTrackingJob(cancelled); stopTrackingJob(cancelled, true /* writeBack */); synchronized (mJobs) { synchronized (mJobs) { // Remove from pending queue. // Remove from pending queue. mPendingJobs.remove(cancelled); mPendingJobs.remove(cancelled); Loading Loading @@ -509,12 +509,12 @@ public class JobSchedulerService extends com.android.server.SystemService * Called when we want to remove a JobStatus object that we've finished executing. Returns the * Called when we want to remove a JobStatus object that we've finished executing. Returns the * object removed. * object removed. */ */ private boolean stopTrackingJob(JobStatus jobStatus) { private boolean stopTrackingJob(JobStatus jobStatus, boolean writeBack) { boolean removed; boolean removed; boolean rocking; boolean rocking; synchronized (mJobs) { synchronized (mJobs) { // Remove from store as well as controllers. // Remove from store as well as controllers. removed = mJobs.remove(jobStatus); removed = mJobs.remove(jobStatus, writeBack); rocking = mReadyToRock; rocking = mReadyToRock; } } if (removed && rocking) { if (removed && rocking) { Loading Loading @@ -645,7 +645,9 @@ public class JobSchedulerService extends com.android.server.SystemService if (DEBUG) { if (DEBUG) { Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule); Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule); } } if (!stopTrackingJob(jobStatus)) { // Do not write back immediately if this is a periodic job. The job may get lost if system // shuts down before it is added back. if (!stopTrackingJob(jobStatus, !jobStatus.getJob().isPeriodic())) { if (DEBUG) { if (DEBUG) { Slog.d(TAG, "Could not find job to remove. Was job removed while executing?"); Slog.d(TAG, "Could not find job to remove. Was job removed while executing?"); } } Loading services/core/java/com/android/server/job/JobStore.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -159,9 +159,10 @@ public class JobStore { /** /** * Remove the provided job. Will also delete the job if it was persisted. * Remove the provided job. Will also delete the job if it was persisted. * @param writeBack If true, the job will be deleted (if it was persisted) immediately. * @return Whether or not the job existed to be removed. * @return Whether or not the job existed to be removed. */ */ public boolean remove(JobStatus jobStatus) { public boolean remove(JobStatus jobStatus, boolean writeBack) { boolean removed = mJobSet.remove(jobStatus); boolean removed = mJobSet.remove(jobStatus); if (!removed) { if (!removed) { if (DEBUG) { if (DEBUG) { Loading @@ -169,7 +170,7 @@ public class JobStore { } } return false; return false; } } if (jobStatus.isPersisted()) { if (writeBack && jobStatus.isPersisted()) { maybeWriteStatusToDiskAsync(); maybeWriteStatusToDiskAsync(); } } return removed; return removed; Loading Loading
services/core/java/com/android/server/job/JobSchedulerService.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -330,7 +330,7 @@ public class JobSchedulerService extends com.android.server.SystemService private void cancelJobImpl(JobStatus cancelled) { private void cancelJobImpl(JobStatus cancelled) { if (DEBUG) Slog.d(TAG, "CANCEL: " + cancelled.toShortString()); if (DEBUG) Slog.d(TAG, "CANCEL: " + cancelled.toShortString()); stopTrackingJob(cancelled); stopTrackingJob(cancelled, true /* writeBack */); synchronized (mJobs) { synchronized (mJobs) { // Remove from pending queue. // Remove from pending queue. mPendingJobs.remove(cancelled); mPendingJobs.remove(cancelled); Loading Loading @@ -509,12 +509,12 @@ public class JobSchedulerService extends com.android.server.SystemService * Called when we want to remove a JobStatus object that we've finished executing. Returns the * Called when we want to remove a JobStatus object that we've finished executing. Returns the * object removed. * object removed. */ */ private boolean stopTrackingJob(JobStatus jobStatus) { private boolean stopTrackingJob(JobStatus jobStatus, boolean writeBack) { boolean removed; boolean removed; boolean rocking; boolean rocking; synchronized (mJobs) { synchronized (mJobs) { // Remove from store as well as controllers. // Remove from store as well as controllers. removed = mJobs.remove(jobStatus); removed = mJobs.remove(jobStatus, writeBack); rocking = mReadyToRock; rocking = mReadyToRock; } } if (removed && rocking) { if (removed && rocking) { Loading Loading @@ -645,7 +645,9 @@ public class JobSchedulerService extends com.android.server.SystemService if (DEBUG) { if (DEBUG) { Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule); Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule); } } if (!stopTrackingJob(jobStatus)) { // Do not write back immediately if this is a periodic job. The job may get lost if system // shuts down before it is added back. if (!stopTrackingJob(jobStatus, !jobStatus.getJob().isPeriodic())) { if (DEBUG) { if (DEBUG) { Slog.d(TAG, "Could not find job to remove. Was job removed while executing?"); Slog.d(TAG, "Could not find job to remove. Was job removed while executing?"); } } Loading
services/core/java/com/android/server/job/JobStore.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -159,9 +159,10 @@ public class JobStore { /** /** * Remove the provided job. Will also delete the job if it was persisted. * Remove the provided job. Will also delete the job if it was persisted. * @param writeBack If true, the job will be deleted (if it was persisted) immediately. * @return Whether or not the job existed to be removed. * @return Whether or not the job existed to be removed. */ */ public boolean remove(JobStatus jobStatus) { public boolean remove(JobStatus jobStatus, boolean writeBack) { boolean removed = mJobSet.remove(jobStatus); boolean removed = mJobSet.remove(jobStatus); if (!removed) { if (!removed) { if (DEBUG) { if (DEBUG) { Loading @@ -169,7 +170,7 @@ public class JobStore { } } return false; return false; } } if (jobStatus.isPersisted()) { if (writeBack && jobStatus.isPersisted()) { maybeWriteStatusToDiskAsync(); maybeWriteStatusToDiskAsync(); } } return removed; return removed; Loading