Search in sources :

Example 26 with JobSet

use of com.android.server.job.JobStore.JobSet in project android_frameworks_base by ResurrectionRemix.

the class JobStoreTest method testNonPersistedTaskIsNotPersisted.

/**
     * 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 = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(jsNonPersisted);
    b = new Builder(43, mComponent).setOverrideDeadline(10000).setPersisted(true);
    JobStatus jsPersisted = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(jsPersisted);
    Thread.sleep(IO_WAIT);
    final JobSet jobStatusSet = new JobSet();
    mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
    assertEquals("Job count is incorrect.", 1, jobStatusSet.size());
    JobStatus jobStatus = jobStatusSet.getAllJobs().iterator().next();
    assertEquals("Wrong job persisted.", 43, jobStatus.getJobId());
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) JobInfo(android.app.job.JobInfo) JobSet(com.android.server.job.JobStore.JobSet) Builder(android.app.job.JobInfo.Builder) Builder(android.app.job.JobInfo.Builder)

Example 27 with JobSet

use of com.android.server.job.JobStore.JobSet in project android_frameworks_base by ResurrectionRemix.

the class JobStoreTest method testWritingTaskWithExtras.

public void testWritingTaskWithExtras() throws Exception {
    JobInfo.Builder b = new Builder(8, mComponent).setRequiresDeviceIdle(true).setPeriodic(10000L).setRequiresCharging(true).setPersisted(true);
    PersistableBundle extras = new PersistableBundle();
    extras.putDouble("hello", 3.2);
    extras.putString("hi", "there");
    extras.putInt("into", 3);
    b.setExtras(extras);
    final JobInfo task = b.build();
    JobStatus taskStatus = JobStatus.createFromJobInfo(task, SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(taskStatus);
    Thread.sleep(IO_WAIT);
    final JobSet jobStatusSet = new JobSet();
    mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
    assertEquals("Incorrect # of persisted tasks.", 1, jobStatusSet.size());
    JobStatus loaded = jobStatusSet.getAllJobs().iterator().next();
    assertTasksEqual(task, loaded.getJob());
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) PersistableBundle(android.os.PersistableBundle) JobInfo(android.app.job.JobInfo) JobSet(com.android.server.job.JobStore.JobSet) Builder(android.app.job.JobInfo.Builder) Builder(android.app.job.JobInfo.Builder)

Example 28 with JobSet

use of com.android.server.job.JobStore.JobSet in project android_frameworks_base by ResurrectionRemix.

the class JobStoreTest method testPriorityPersisted.

public void testPriorityPersisted() throws Exception {
    JobInfo.Builder b = new Builder(92, mComponent).setOverrideDeadline(5000).setPriority(42).setPersisted(true);
    final JobStatus js = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(js);
    Thread.sleep(IO_WAIT);
    final JobSet jobStatusSet = new JobSet();
    mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
    JobStatus loaded = jobStatusSet.getAllJobs().iterator().next();
    assertEquals("Priority not correctly persisted.", 42, loaded.getPriority());
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) JobInfo(android.app.job.JobInfo) JobSet(com.android.server.job.JobStore.JobSet) Builder(android.app.job.JobInfo.Builder) Builder(android.app.job.JobInfo.Builder)

Example 29 with JobSet

use of com.android.server.job.JobStore.JobSet in project android_frameworks_base by crdroidandroid.

the class JobStoreTest method testWritingTaskWithExtras.

public void testWritingTaskWithExtras() throws Exception {
    JobInfo.Builder b = new Builder(8, mComponent).setRequiresDeviceIdle(true).setPeriodic(10000L).setRequiresCharging(true).setPersisted(true);
    PersistableBundle extras = new PersistableBundle();
    extras.putDouble("hello", 3.2);
    extras.putString("hi", "there");
    extras.putInt("into", 3);
    b.setExtras(extras);
    final JobInfo task = b.build();
    JobStatus taskStatus = JobStatus.createFromJobInfo(task, SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(taskStatus);
    Thread.sleep(IO_WAIT);
    final JobSet jobStatusSet = new JobSet();
    mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
    assertEquals("Incorrect # of persisted tasks.", 1, jobStatusSet.size());
    JobStatus loaded = jobStatusSet.getAllJobs().iterator().next();
    assertTasksEqual(task, loaded.getJob());
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) PersistableBundle(android.os.PersistableBundle) JobInfo(android.app.job.JobInfo) JobSet(com.android.server.job.JobStore.JobSet) Builder(android.app.job.JobInfo.Builder) Builder(android.app.job.JobInfo.Builder)

Example 30 with JobSet

use of com.android.server.job.JobStore.JobSet in project android_frameworks_base by crdroidandroid.

the class JobStoreTest method testNonPersistedTaskIsNotPersisted.

/**
     * 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 = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(jsNonPersisted);
    b = new Builder(43, mComponent).setOverrideDeadline(10000).setPersisted(true);
    JobStatus jsPersisted = JobStatus.createFromJobInfo(b.build(), SOME_UID, null, -1, null);
    mTaskStoreUnderTest.add(jsPersisted);
    Thread.sleep(IO_WAIT);
    final JobSet jobStatusSet = new JobSet();
    mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
    assertEquals("Job count is incorrect.", 1, jobStatusSet.size());
    JobStatus jobStatus = jobStatusSet.getAllJobs().iterator().next();
    assertEquals("Wrong job persisted.", 43, jobStatus.getJobId());
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus) JobInfo(android.app.job.JobInfo) JobSet(com.android.server.job.JobStore.JobSet) Builder(android.app.job.JobInfo.Builder) Builder(android.app.job.JobInfo.Builder)

Aggregations

JobInfo (android.app.job.JobInfo)32 Builder (android.app.job.JobInfo.Builder)32 JobSet (com.android.server.job.JobStore.JobSet)32 JobStatus (com.android.server.job.controllers.JobStatus)32 PersistableBundle (android.os.PersistableBundle)4