Loading services/core/java/com/android/server/job/JobStore.java +5 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,11 @@ public class JobStore { // Copy over the jobs so we can release the lock before writing. for (int i=0; i<mJobSet.size(); i++) { JobStatus jobStatus = mJobSet.valueAt(i); if (!jobStatus.isPersisted()){ continue; } JobStatus copy = new JobStatus(jobStatus.getJob(), jobStatus.getUid(), jobStatus.getEarliestRunTime(), jobStatus.getLatestRunTimeElapsed()); mStoreCopy.add(copy); Loading services/tests/servicestests/src/com/android/server/job/JobStoreTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,28 @@ public class JobStoreTest extends AndroidTestCase { loaded.getEarliestRunTime() <= newNowElapsed + TEN_SECONDS*2); } /** * Test that non persisted job is not written to disk. */ public void testNonPersistedTaskIsNotPersisted() throws Exception { JobInfo.Builder b = new Builder(42, mComponent) .setOverrideDeadline(10000) .setPersisted(false); JobStatus jsNonPersisted = new JobStatus(b.build(), SOME_UID); mTaskStoreUnderTest.add(jsNonPersisted); b = new Builder(43, mComponent) .setOverrideDeadline(10000) .setPersisted(true); JobStatus jsPersisted = new JobStatus(b.build(), SOME_UID); mTaskStoreUnderTest.add(jsPersisted); Thread.sleep(IO_WAIT); final ArraySet<JobStatus> jobStatusSet = new ArraySet<JobStatus>(); mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet); assertEquals("Job count is incorrect.", 1, jobStatusSet.size()); JobStatus jobStatus = jobStatusSet.iterator().next(); assertEquals("Wrong job persisted.", 43, jobStatus.getJobId()); } /** * Helper function to throw an error if the provided task and TaskStatus objects are not equal. */ Loading Loading
services/core/java/com/android/server/job/JobStore.java +5 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,11 @@ public class JobStore { // Copy over the jobs so we can release the lock before writing. for (int i=0; i<mJobSet.size(); i++) { JobStatus jobStatus = mJobSet.valueAt(i); if (!jobStatus.isPersisted()){ continue; } JobStatus copy = new JobStatus(jobStatus.getJob(), jobStatus.getUid(), jobStatus.getEarliestRunTime(), jobStatus.getLatestRunTimeElapsed()); mStoreCopy.add(copy); Loading
services/tests/servicestests/src/com/android/server/job/JobStoreTest.java +22 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,28 @@ public class JobStoreTest extends AndroidTestCase { loaded.getEarliestRunTime() <= newNowElapsed + TEN_SECONDS*2); } /** * Test that non persisted job is not written to disk. */ public void testNonPersistedTaskIsNotPersisted() throws Exception { JobInfo.Builder b = new Builder(42, mComponent) .setOverrideDeadline(10000) .setPersisted(false); JobStatus jsNonPersisted = new JobStatus(b.build(), SOME_UID); mTaskStoreUnderTest.add(jsNonPersisted); b = new Builder(43, mComponent) .setOverrideDeadline(10000) .setPersisted(true); JobStatus jsPersisted = new JobStatus(b.build(), SOME_UID); mTaskStoreUnderTest.add(jsPersisted); Thread.sleep(IO_WAIT); final ArraySet<JobStatus> jobStatusSet = new ArraySet<JobStatus>(); mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet); assertEquals("Job count is incorrect.", 1, jobStatusSet.size()); JobStatus jobStatus = jobStatusSet.iterator().next(); assertEquals("Wrong job persisted.", 43, jobStatus.getJobId()); } /** * Helper function to throw an error if the provided task and TaskStatus objects are not equal. */ Loading