/*package*/ static void cleanUpOrphanedJob(Context context, int jobId) { /* * That's necessary if the database was deleted and jobs (especially the JobScheduler) are still around. * Then if a new job is being scheduled, it's possible that the new job has the ID of the old one. Here * we make sure, that no job is left in the system. */ for (JobApi jobApi : JobApi.values()) { if (jobApi.isSupported(context)) { try { jobApi.getProxy(context).cancel(jobId); } catch (Exception ignored) { // GCM API could crash if it's disabled, ignore crashes at this point and continue } } } }
/*package*/ Set<JobRequest> getAllJobRequests(@Nullable String tag, boolean includeStarted, boolean cleanUpTransient) { Set<JobRequest> requests = getJobStorage().getAllJobRequests(tag, includeStarted); if (cleanUpTransient) { Iterator<JobRequest> iterator = requests.iterator(); while (iterator.hasNext()) { JobRequest request = iterator.next(); if (request.isTransient() && !request.getJobApi().getProxy(mContext).isPlatformJobScheduled(request)) { getJobStorage().remove(request); iterator.remove(); } } } return requests; }
private void scheduleWithApi(JobRequest request, JobApi jobApi, boolean periodic, boolean flexSupport) { JobProxy proxy = getJobProxy(jobApi); if (periodic) { if (flexSupport) { proxy.plantPeriodicFlexSupport(request); } else { proxy.plantPeriodic(request); } } else { proxy.plantOneOff(request); } }
private void scheduleWithApi(JobRequest request, JobApi jobApi, boolean periodic, boolean flexSupport) { JobProxy proxy = getJobProxy(jobApi); if (periodic) { if (flexSupport) { proxy.plantPeriodicFlexSupport(request); } else { proxy.plantPeriodic(request); } } else { proxy.plantOneOff(request); } }
/** * @param jobId The unique ID of the pending {@link JobRequest}. * @return The {@link JobRequest} if it's pending or {@code null} otherwise. */ public JobRequest getJobRequest(int jobId) { JobRequest request = getJobRequest(jobId, false); if (request != null && request.isTransient() && !request.getJobApi().getProxy(mContext).isPlatformJobScheduled(request)) { getJobStorage().remove(request); return null; } else { return request; } }
private boolean cancelInner(@Nullable JobRequest request) { if (request != null) { CAT.i("Found pending job %s, canceling", request); getJobProxy(request.getJobApi()).cancel(request.getJobId()); getJobStorage().remove(request); request.setScheduledAt(0); // reset value return true; } else { return false; } }
reschedule = job == null; } else { reschedule = !manager.getJobProxy(request.getJobApi()).isPlatformJobScheduled(request);
/*package*/ static void cleanUpOrphanedJob(Context context, int jobId) { /* * That's necessary if the database was deleted and jobs (especially the JobScheduler) are still around. * Then if a new job is being scheduled, it's possible that the new job has the ID of the old one. Here * we make sure, that no job is left in the system. */ for (JobApi jobApi : JobApi.values()) { if (jobApi.isSupported(context)) { try { jobApi.getProxy(context).cancel(jobId); } catch (Exception ignored) { // GCM API could crash if it's disabled, ignore crashes at this point and continue } } } }
/*package*/ Set<JobRequest> getAllJobRequests(@Nullable String tag, boolean includeStarted, boolean cleanUpTransient) { Set<JobRequest> requests = mJobStorage.getAllJobRequests(tag, includeStarted); if (cleanUpTransient) { Iterator<JobRequest> iterator = requests.iterator(); while (iterator.hasNext()) { JobRequest request = iterator.next(); if (request.isTransient() && !request.getJobApi().getProxy(mContext).isPlatformJobScheduled(request)) { mJobStorage.remove(request); iterator.remove(); } } } return requests; }
private boolean cancelInner(@Nullable JobRequest request) { if (request != null) { CAT.i("Found pending job %s, canceling", request); getJobProxy(request.getJobApi()).cancel(request.getJobId()); getJobStorage().remove(request); request.setScheduledAt(0); // reset value return true; } else { return false; } }
/** * @param jobId The unique ID of the pending {@link JobRequest}. * @return The {@link JobRequest} if it's pending or {@code null} otherwise. */ public JobRequest getJobRequest(int jobId) { JobRequest request = getJobRequest(jobId, false); if (request != null && request.isTransient() && !request.getJobApi().getProxy(mContext).isPlatformJobScheduled(request)) { getJobStorage().remove(request); return null; } else { return request; } }
reschedule = job == null; } else { reschedule = !manager.getJobProxy(request.getJobApi()).isPlatformJobScheduled(request);