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()));
}
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));
}
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;
}
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;
}
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);
}
}
Aggregations