/*package*/ void updateStats(boolean incFailureCount, boolean updateLastRun) { ContentValues contentValues = new ContentValues(); if (incFailureCount) { mFailureCount++; contentValues.put(JobStorage.COLUMN_NUM_FAILURES, mFailureCount); } if (updateLastRun) { mLastRun = JobConfig.getClock().currentTimeMillis(); contentValues.put(JobStorage.COLUMN_LAST_RUN, mLastRun); } JobManager.instance().getJobStorage().update(this, contentValues); }
calendar.setTimeInMillis(JobConfig.getClock().currentTimeMillis());
/** * Cancel this request if it has been scheduled. Note that if the job isn't periodic, then the * time passed since the job has been scheduled is subtracted from the time frame. For example * a job should run between 4 and 6 seconds from now. You cancel the scheduled job after 2 * seconds, then the job will run between 2 and 4 seconds after it's been scheduled again. * * @return A builder to modify the parameters. */ public Builder cancelAndEdit() { // create a temporary variable, because .cancel() will reset mScheduledAt long scheduledAt = mScheduledAt; JobManager.instance().cancel(getJobId()); Builder builder = new Builder(this.mBuilder); mStarted = false; if (!isPeriodic()) { long offset = JobConfig.getClock().currentTimeMillis() - scheduledAt; long minValue = 1L; // 1ms builder.setExecutionWindow(Math.max(minValue, getStartMs() - offset), Math.max(minValue, getEndMs() - offset)); } return builder; }
protected void plantOneOffFlexSupport(JobRequest request, AlarmManager alarmManager, PendingIntent pendingIntent) { long triggerAtMs = JobConfig.getClock().currentTimeMillis() + Common.getAverageDelayMsSupportFlex(request); alarmManager.set(AlarmManager.RTC, triggerAtMs, pendingIntent); mCat.d("Scheduled repeating alarm (flex support), %s, interval %s, flex %s", request, JobUtil.timeToString(request.getIntervalMs()), JobUtil.timeToString(request.getFlexMs())); }
boolean flexSupport = periodic && jobApi.isFlexSupport() && request.getFlexMs() < request.getIntervalMs(); request.setScheduledAt(JobConfig.getClock().currentTimeMillis()); request.setFlexSupport(flexSupport); getJobStorage().put(request);
/*package*/ void updateStats(boolean incFailureCount, boolean updateLastRun) { ContentValues contentValues = new ContentValues(); if (incFailureCount) { mFailureCount++; contentValues.put(JobStorage.COLUMN_NUM_FAILURES, mFailureCount); } if (updateLastRun) { mLastRun = JobConfig.getClock().currentTimeMillis(); contentValues.put(JobStorage.COLUMN_LAST_RUN, mLastRun); } JobManager.instance().getJobStorage().update(this, contentValues); }
calendar.setTimeInMillis(JobConfig.getClock().currentTimeMillis());
/** * Cancel this request if it has been scheduled. Note that if the job isn't periodic, then the * time passed since the job has been scheduled is subtracted from the time frame. For example * a job should run between 4 and 6 seconds from now. You cancel the scheduled job after 2 * seconds, then the job will run between 2 and 4 seconds after it's been scheduled again. * * @return A builder to modify the parameters. */ public Builder cancelAndEdit() { // create a temporary variable, because .cancel() will reset mScheduledAt long scheduledAt = mScheduledAt; JobManager.instance().cancel(getJobId()); Builder builder = new Builder(this.mBuilder); mStarted = false; if (!isPeriodic()) { long offset = JobConfig.getClock().currentTimeMillis() - scheduledAt; long minValue = 1L; // 1ms builder.setExecutionWindow(Math.max(minValue, getStartMs() - offset), Math.max(minValue, getEndMs() - offset)); } return builder; }
protected void plantOneOffFlexSupport(JobRequest request, AlarmManager alarmManager, PendingIntent pendingIntent) { long triggerAtMs = JobConfig.getClock().currentTimeMillis() + Common.getAverageDelayMsSupportFlex(request); alarmManager.set(AlarmManager.RTC, triggerAtMs, pendingIntent); mCat.d("Scheduled repeating alarm (flex support), %s, interval %s, flex %s", request, JobUtil.timeToString(request.getIntervalMs()), JobUtil.timeToString(request.getFlexMs())); }
boolean flexSupport = periodic && jobApi.isFlexSupport() && request.getFlexMs() < request.getIntervalMs(); request.setScheduledAt(JobConfig.getClock().currentTimeMillis()); request.setFlexSupport(flexSupport); mJobStorage.put(request);