use of com.android.server.job.controllers.JobStatus in project platform_frameworks_base by android.
the class JobSchedulerService method reportActive.
void reportActive() {
// active is true if pending queue contains jobs OR some job is running.
boolean active = mPendingJobs.size() > 0;
if (mPendingJobs.size() <= 0) {
for (int i = 0; i < mActiveServices.size(); i++) {
final JobServiceContext jsc = mActiveServices.get(i);
final JobStatus job = jsc.getRunningJob();
if (job != null && (job.getJob().getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0 && !job.dozeWhitelisted) {
// We will report active if we have a job running and it is not an exception
// due to being in the foreground or whitelisted.
active = true;
break;
}
}
}
if (mReportedActive != active) {
mReportedActive = active;
if (mLocalDeviceIdleController != null) {
mLocalDeviceIdleController.setJobsActive(active);
}
}
}
use of com.android.server.job.controllers.JobStatus in project platform_frameworks_base by android.
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());
}
use of com.android.server.job.controllers.JobStatus in project platform_frameworks_base by android.
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());
}
use of com.android.server.job.controllers.JobStatus in project platform_frameworks_base by android.
the class JobStoreTest method testMaybeWriteStatusToDisk.
public void testMaybeWriteStatusToDisk() throws Exception {
int taskId = 5;
// 20s
long runByMillis = 20000L;
// 2s
long runFromMillis = 2000L;
// 10s
long initialBackoff = 10000L;
final JobInfo task = new Builder(taskId, mComponent).setRequiresCharging(true).setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY).setBackoffCriteria(initialBackoff, JobInfo.BACKOFF_POLICY_EXPONENTIAL).setOverrideDeadline(runByMillis).setMinimumLatency(runFromMillis).setPersisted(true).build();
final JobStatus ts = JobStatus.createFromJobInfo(task, SOME_UID, null, -1, null);
mTaskStoreUnderTest.add(ts);
Thread.sleep(IO_WAIT);
// Manually load tasks from xml file.
final JobSet jobStatusSet = new JobSet();
mTaskStoreUnderTest.readJobMapFromDisk(jobStatusSet);
assertEquals("Didn't get expected number of persisted tasks.", 1, jobStatusSet.size());
final JobStatus loadedTaskStatus = jobStatusSet.getAllJobs().get(0);
assertTasksEqual(task, loadedTaskStatus.getJob());
assertTrue("JobStore#contains invalid.", mTaskStoreUnderTest.containsJob(ts));
assertEquals("Different uids.", SOME_UID, loadedTaskStatus.getUid());
compareTimestampsSubjectToIoLatency("Early run-times not the same after read.", ts.getEarliestRunTime(), loadedTaskStatus.getEarliestRunTime());
compareTimestampsSubjectToIoLatency("Late run-times not the same after read.", ts.getLatestRunTimeElapsed(), loadedTaskStatus.getLatestRunTimeElapsed());
}
use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by ResurrectionRemix.
the class JobStoreTest method testWritingTaskWithSourcePackage.
public void testWritingTaskWithSourcePackage() throws Exception {
JobInfo.Builder b = new Builder(8, mComponent).setRequiresDeviceIdle(true).setPeriodic(10000L).setRequiresCharging(true).setPersisted(true);
JobStatus taskStatus = JobStatus.createFromJobInfo(b.build(), SOME_UID, "com.google.android.gms", 0, 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();
assertEquals("Source package not equal.", loaded.getSourcePackageName(), taskStatus.getSourcePackageName());
assertEquals("Source user not equal.", loaded.getSourceUserId(), taskStatus.getSourceUserId());
}
Aggregations