Search in sources :

Example 21 with JobStatus

use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by ResurrectionRemix.

the class JobSchedulerService method onJobCompleted.

// JobCompletedListener implementations.
/**
     * A job just finished executing. We fetch the
     * {@link com.android.server.job.controllers.JobStatus} from the store and depending on
     * whether we want to reschedule we readd it to the controllers.
     * @param jobStatus Completed job.
     * @param needsReschedule Whether the implementing class should reschedule this job.
     */
@Override
public void onJobCompleted(JobStatus jobStatus, boolean needsReschedule) {
    if (DEBUG) {
        Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule);
    }
    // shuts down before it is added back.
    if (!stopTrackingJob(jobStatus, null, !jobStatus.getJob().isPeriodic())) {
        if (DEBUG) {
            Slog.d(TAG, "Could not find job to remove. Was job removed while executing?");
        }
        // We still want to check for jobs to execute, because this job may have
        // scheduled a new job under the same job id, and now we can run it.
        mHandler.obtainMessage(MSG_CHECK_JOB_GREEDY).sendToTarget();
        return;
    }
    // that may cause ordering problems if the app removes jobStatus while in here.
    if (needsReschedule) {
        JobStatus rescheduled = getRescheduleJobForFailure(jobStatus);
        startTrackingJob(rescheduled, jobStatus);
    } else if (jobStatus.getJob().isPeriodic()) {
        JobStatus rescheduledPeriodic = getRescheduleJobForPeriodic(jobStatus);
        startTrackingJob(rescheduledPeriodic, jobStatus);
    }
    reportActive();
    mHandler.obtainMessage(MSG_CHECK_JOB_GREEDY).sendToTarget();
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Example 22 with JobStatus

use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by ResurrectionRemix.

the class JobSchedulerService method cancelJobsForUser.

void cancelJobsForUser(int userHandle) {
    List<JobStatus> jobsForUser;
    synchronized (mLock) {
        jobsForUser = mJobs.getJobsByUser(userHandle);
    }
    for (int i = 0; i < jobsForUser.size(); i++) {
        JobStatus toRemove = jobsForUser.get(i);
        cancelJobImpl(toRemove, null);
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Example 23 with JobStatus

use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by ResurrectionRemix.

the class JobSchedulerService method noteJobsPending.

void noteJobsPending(List<JobStatus> jobs) {
    for (int i = jobs.size() - 1; i >= 0; i--) {
        JobStatus job = jobs.get(i);
        mJobPackageTracker.notePending(job);
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Example 24 with JobStatus

use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by ResurrectionRemix.

the class JobSchedulerService method onDeviceIdleStateChanged.

@Override
public void onDeviceIdleStateChanged(boolean deviceIdle) {
    synchronized (mLock) {
        if (deviceIdle) {
            // except those using the idle exemption flag.
            for (int i = 0; i < mActiveServices.size(); i++) {
                JobServiceContext jsc = mActiveServices.get(i);
                final JobStatus executing = jsc.getRunningJob();
                if (executing != null && (executing.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0) {
                    jsc.cancelExecutingJob(JobParameters.REASON_DEVICE_IDLE);
                }
            }
        } else {
            // When coming out of idle, allow thing to start back up.
            if (mReadyToRock) {
                if (mLocalDeviceIdleController != null) {
                    if (!mReportedActive) {
                        mReportedActive = true;
                        mLocalDeviceIdleController.setJobsActive(true);
                    }
                }
            }
            mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget();
        }
    }
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Example 25 with JobStatus

use of com.android.server.job.controllers.JobStatus in project android_frameworks_base by ResurrectionRemix.

the class JobSchedulerService method isCurrentlyActiveLocked.

/**
     * @param job JobStatus we are querying against.
     * @return Whether or not the job represented by the status object is currently being run or
     * is pending.
     */
private boolean isCurrentlyActiveLocked(JobStatus job) {
    for (int i = 0; i < mActiveServices.size(); i++) {
        JobServiceContext serviceContext = mActiveServices.get(i);
        // The 'unsafe' direct-internal-reference running-job inspector is okay to
        // use here because we are already holding the necessary lock *and* we
        // immediately discard the returned object reference, if any; we return
        // only a boolean state indicator to the caller.
        final JobStatus running = serviceContext.getRunningJobUnsafeLocked();
        if (running != null && running.matches(job.getUid(), job.getJobId())) {
            return true;
        }
    }
    return false;
}
Also used : JobStatus(com.android.server.job.controllers.JobStatus)

Aggregations

JobStatus (com.android.server.job.controllers.JobStatus)122 JobInfo (android.app.job.JobInfo)42 Builder (android.app.job.JobInfo.Builder)32 JobSet (com.android.server.job.JobStore.JobSet)32 RemoteException (android.os.RemoteException)25 StateController (com.android.server.job.controllers.StateController)10 IntentFilter (android.content.IntentFilter)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 PowerManager (android.os.PowerManager)5 WorkSource (android.os.WorkSource)5 DeviceIdleController (com.android.server.DeviceIdleController)5 JobStatusFunctor (com.android.server.job.JobStore.JobStatusFunctor)5 ArrayList (java.util.ArrayList)5 PersistableBundle (android.os.PersistableBundle)4