private void maybeQueueReadyJobsForExecutionLockedH(){
  int chargingCount=0;
  int idleCount=0;
  int backoffCount=0;
  int connectivityCount=0;
  List<JobStatus> runnableJobs=new ArrayList<JobStatus>();
  ArraySet<JobStatus> jobs=mJobs.getJobs();
  for (int i=0; i < jobs.size(); i++) {
    JobStatus job=jobs.valueAt(i);
    if (isReadyToBeExecutedLocked(job)) {
      if (job.getNumFailures() > 0) {
        backoffCount++;
      }
      if (job.hasIdleConstraint()) {
        idleCount++;
      }
      if (job.hasConnectivityConstraint() || job.hasUnmeteredConstraint()) {
        connectivityCount++;
      }
      if (job.hasChargingConstraint()) {
        chargingCount++;
      }
      runnableJobs.add(job);
    }
 else     if (isReadyToBeCancelledLocked(job)) {
      stopJobOnServiceContextLocked(job);
    }
  }
  if (backoffCount > 0 || idleCount >= MIN_IDLE_COUNT || connectivityCount >= MIN_CONNECTIVITY_COUNT || chargingCount >= MIN_CHARGING_COUNT || runnableJobs.size() >= MIN_READY_JOBS_COUNT) {
    for (int i=0; i < runnableJobs.size(); i++) {
      mPendingJobs.add(runnableJobs.get(i));
    }
  }
}

private void maybeQueueReadyJobsForExecutionLockedH ( ) { int chargingCount = 0 ; int idleCount = 0 ; int backoffCount = 0 ; int connectivityCount = 0 ; List < JobStatus > runnableJobs = new ArrayList < JobStatus > ( ) ; ArraySet < JobStatus > jobs = mJobs . getJobs ( ) ; for ( int i = 0 ; i < jobs . size ( ) ; i ++ ) { JobStatus job = jobs . valueAt ( i ) ; if ( isReadyToBeExecutedLocked ( job ) ) { if ( job . getNumFailures ( ) > 0 ) { backoffCount ++ ; } if ( job . hasIdleConstraint ( ) ) { idleCount ++ ; } if ( job . hasConnectivityConstraint ( ) || job . hasUnmeteredConstraint ( ) ) { connectivityCount ++ ; } if ( job . hasChargingConstraint ( ) ) { chargingCount ++ ; } runnableJobs . add ( job ) ; } else if ( isReadyToBeCancelledLocked ( job ) ) { stopJobOnServiceContextLocked ( job ) ; } } if ( backoffCount > 0 || idleCount >= MIN_IDLE_COUNT || connectivityCount >= MIN_CONNECTIVITY_COUNT || chargingCount >= MIN_CHARGING_COUNT || runnableJobs . size ( ) >= MIN_READY_JOBS_COUNT ) { for ( int i = 0 ; i < runnableJobs . size ( ) ; i ++ ) { mPendingJobs . add ( runnableJobs . get ( i ) ) ; } } }
the state of at least one job has changed . here is where we could enforce various policies on when we want to execute jobs . right now the policy is such : if > 1 of the ready jobs is idle mode we send all of them off if more than 2 network connectivity jobs are ready we send them all off . if more than 4 jobs total are ready we send them all off . todo : it would be nice to consolidate these sort of high - level policies somewhere .
