Search in sources :

Example 36 with JobInfo

use of android.app.job.JobInfo in project android-job by evernote.

the class JobProxy21 method plantPeriodicFlexSupport.

@Override
public void plantPeriodicFlexSupport(JobRequest request) {
    long startMs = Common.getStartMsSupportFlex(request);
    long endMs = Common.getEndMsSupportFlex(request);
    JobInfo jobInfo = createBuilderOneOff(createBaseBuilder(request), startMs, endMs).build();
    int scheduleResult = schedule(jobInfo);
    mCat.d("Schedule periodic (flex support) jobInfo %s, %s, start %s, end %s, flex %s", scheduleResultToString(scheduleResult), request, JobUtil.timeToString(startMs), JobUtil.timeToString(endMs), JobUtil.timeToString(request.getFlexMs()));
}
Also used : JobInfo(android.app.job.JobInfo)

Example 37 with JobInfo

use of android.app.job.JobInfo in project android-job by evernote.

the class JobProxy21 method plantOneOff.

@Override
public void plantOneOff(JobRequest request) {
    long startMs = Common.getStartMs(request);
    long endMs = Common.getEndMs(request);
    JobInfo jobInfo = createBuilderOneOff(createBaseBuilder(request), startMs, endMs).build();
    int scheduleResult = schedule(jobInfo);
    mCat.d("Schedule one-off jobInfo %s, %s, start %s, end %s, reschedule count %d", scheduleResultToString(scheduleResult), request, JobUtil.timeToString(startMs), JobUtil.timeToString(endMs), Common.getRescheduleCount(request));
}
Also used : JobInfo(android.app.job.JobInfo)

Example 38 with JobInfo

use of android.app.job.JobInfo in project muzei by romannurik.

the class TaskQueueService method maybeRetryDownloadDueToGainedConnectivity.

public static Intent maybeRetryDownloadDueToGainedConnectivity(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
        List<JobInfo> pendingJobs = jobScheduler.getAllPendingJobs();
        for (JobInfo pendingJob : pendingJobs) {
            if (pendingJob.getId() == LOAD_ARTWORK_JOB_ID) {
                return TaskQueueService.getDownloadCurrentArtworkIntent(context);
            }
        }
        return null;
    }
    return (PreferenceManager.getDefaultSharedPreferences(context).getInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, 0) > 0) ? TaskQueueService.getDownloadCurrentArtworkIntent(context) : null;
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo)

Example 39 with JobInfo

use of android.app.job.JobInfo in project platform_frameworks_base by android.

the class ProvisionObserver method isDeferredForProvision.

/**
     * Static utility function to schedule a job to execute upon the change of content URI
     * {@link android.provider.Settings.Global#DEVICE_PROVISIONED DEVICE_PROVISIONED}.
     * @param context The context used to retrieve the {@link ComponentName} and system services
     * @return true carrier actions are deferred due to phone provisioning process, false otherwise
     */
public static boolean isDeferredForProvision(Context context, Intent intent) {
    if (isProvisioned(context)) {
        return false;
    }
    int jobId;
    switch(intent.getAction()) {
        case TelephonyIntents.ACTION_CARRIER_SIGNAL_REDIRECTED:
            jobId = PROVISION_OBSERVER_REEVALUATION_JOB_ID;
            break;
        default:
            return false;
    }
    final JobScheduler jobScheduler = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
    final JobInfo job = new JobInfo.Builder(jobId, new ComponentName(context, ProvisionObserver.class)).addTriggerContentUri(new JobInfo.TriggerContentUri(Settings.Global.getUriFor(Settings.Global.DEVICE_PROVISIONED), 0)).setTriggerContentUpdateDelay(CONTENT_UPDATE_DELAY_MS).setTriggerContentMaxDelay(CONTENT_MAX_DELAY_MS).build();
    jobScheduler.schedule(job);
    return true;
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo) ComponentName(android.content.ComponentName)

Example 40 with JobInfo

use of android.app.job.JobInfo in project platform_frameworks_base by android.

the class NekoService method registerJobIfNeeded.

public static void registerJobIfNeeded(Context context, long intervalMinutes) {
    JobScheduler jss = context.getSystemService(JobScheduler.class);
    JobInfo info = jss.getPendingJob(JOB_ID);
    if (info == null) {
        registerJob(context, intervalMinutes);
    }
}
Also used : JobScheduler(android.app.job.JobScheduler) JobInfo(android.app.job.JobInfo)

Aggregations

JobInfo (android.app.job.JobInfo)66 JobStatus (com.android.server.job.controllers.JobStatus)22 JobScheduler (android.app.job.JobScheduler)13 Builder (android.app.job.JobInfo.Builder)12 JobSet (com.android.server.job.JobStore.JobSet)12 ArrayList (java.util.ArrayList)10 ComponentName (android.content.ComponentName)8 Event (com.android.server.job.MockPriorityJobService.TestEnvironment.Event)8 Test (org.junit.Test)7 PersistableBundle (android.os.PersistableBundle)6 NotificationManager (android.app.NotificationManager)5 JobSchedulerInternal (com.android.server.job.JobSchedulerInternal)5 StateController (com.android.server.job.controllers.StateController)5 JobParameters (android.app.job.JobParameters)1 ConnectivityManager (android.net.ConnectivityManager)1 NonNull (android.support.annotation.NonNull)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1