@Test(expected = IllegalArgumentException.class) public void testSchedulerForUnknownTagShouldFail() { jobScheduler.getSchedulerForTag(application, "unknown"); }
@RestrictTo(RestrictTo.Scope.LIBRARY) Scheduler getSchedulerForTag(Context context, String tag) { Scheduler scheduler = schedulers.get(tag); if (scheduler == null) { switch (tag) { case JobSchedulerSchedulerV28.TAG: scheduler = new JobSchedulerSchedulerV28(context); break; case JobSchedulerSchedulerV26.TAG: scheduler = new JobSchedulerSchedulerV26(context); break; case JobSchedulerSchedulerV24.TAG: scheduler = new JobSchedulerSchedulerV24(context); break; case JobSchedulerSchedulerV21.TAG: scheduler = new JobSchedulerSchedulerV21(context); break; case GcmScheduler.TAG: scheduler = new GcmScheduler(context); break; case AlarmScheduler.TAG: scheduler = new AlarmScheduler(context); break; default: throw new IllegalArgumentException("Missing scheduler for tag " + tag); } schedulers.put(tag, scheduler); } return scheduler; }
JobScheduler { @RestrictTo(RestrictTo.Scope.LIBRARY) Scheduler getSchedulerForTag(Context context, String tag) { Scheduler scheduler = schedulers.get(tag); if (scheduler == null) { switch (tag) { case JobSchedulerSchedulerV28.TAG: scheduler = new JobSchedulerSchedulerV28(context); break; case JobSchedulerSchedulerV26.TAG: scheduler = new JobSchedulerSchedulerV26(context); break; case JobSchedulerSchedulerV24.TAG: scheduler = new JobSchedulerSchedulerV24(context); break; case JobSchedulerSchedulerV21.TAG: scheduler = new JobSchedulerSchedulerV21(context); break; case GcmScheduler.TAG: scheduler = new GcmScheduler(context); break; case AlarmScheduler.TAG: scheduler = new AlarmScheduler(context); break; default: throw new IllegalArgumentException("Missing scheduler for tag " + tag); } schedulers.put(tag, scheduler); } return scheduler; } }
JobScheduler { @RestrictTo(RestrictTo.Scope.LIBRARY) Scheduler getSchedulerForTag(Context context, String tag) { Scheduler scheduler = schedulers.get(tag); if (scheduler == null) { switch (tag) { case JobSchedulerSchedulerV28.TAG: scheduler = new JobSchedulerSchedulerV28(context); break; case JobSchedulerSchedulerV26.TAG: scheduler = new JobSchedulerSchedulerV26(context); break; case JobSchedulerSchedulerV24.TAG: scheduler = new JobSchedulerSchedulerV24(context); break; case JobSchedulerSchedulerV21.TAG: scheduler = new JobSchedulerSchedulerV21(context); break; case GcmScheduler.TAG: scheduler = new GcmScheduler(context); break; case AlarmScheduler.TAG: scheduler = new AlarmScheduler(context); break; default: throw new IllegalArgumentException("Missing scheduler for tag " + tag); } schedulers.put(tag, scheduler); } return scheduler; } private  JobScheduler(Context context); }
JobScheduler { @RestrictTo(RestrictTo.Scope.LIBRARY) Scheduler getSchedulerForTag(Context context, String tag) { Scheduler scheduler = schedulers.get(tag); if (scheduler == null) { switch (tag) { case JobSchedulerSchedulerV28.TAG: scheduler = new JobSchedulerSchedulerV28(context); break; case JobSchedulerSchedulerV26.TAG: scheduler = new JobSchedulerSchedulerV26(context); break; case JobSchedulerSchedulerV24.TAG: scheduler = new JobSchedulerSchedulerV24(context); break; case JobSchedulerSchedulerV21.TAG: scheduler = new JobSchedulerSchedulerV21(context); break; case GcmScheduler.TAG: scheduler = new GcmScheduler(context); break; case AlarmScheduler.TAG: scheduler = new AlarmScheduler(context); break; default: throw new IllegalArgumentException("Missing scheduler for tag " + tag); } schedulers.put(tag, scheduler); } return scheduler; } private  JobScheduler(Context context); static synchronized JobScheduler get(Context context); int schedule(JobInfo job); void cancel(int jobId); void cancelAll(); @NonNull List<JobInfo> getAllPendingJobs(); @Nullable JobInfo getPendingJob(int jobId); @RestrictTo(RestrictTo.Scope.LIBRARY) void onJobCompleted(int jobId, boolean needsReschedule); @RestrictTo(RestrictTo.Scope.LIBRARY) List<JobStatus> getJobsByScheduler(String scheduler); @RestrictTo(RestrictTo.Scope.LIBRARY) JobStatus getJob(int jobId); @RestrictTo(RestrictTo.Scope.LIBRARY) void addJob(JobStatus jobStatus); @RestrictTo(RestrictTo.Scope.LIBRARY) void removeJob(int jobId); }
JobScheduler { @RestrictTo(RestrictTo.Scope.LIBRARY) Scheduler getSchedulerForTag(Context context, String tag) { Scheduler scheduler = schedulers.get(tag); if (scheduler == null) { switch (tag) { case JobSchedulerSchedulerV28.TAG: scheduler = new JobSchedulerSchedulerV28(context); break; case JobSchedulerSchedulerV26.TAG: scheduler = new JobSchedulerSchedulerV26(context); break; case JobSchedulerSchedulerV24.TAG: scheduler = new JobSchedulerSchedulerV24(context); break; case JobSchedulerSchedulerV21.TAG: scheduler = new JobSchedulerSchedulerV21(context); break; case GcmScheduler.TAG: scheduler = new GcmScheduler(context); break; case AlarmScheduler.TAG: scheduler = new AlarmScheduler(context); break; default: throw new IllegalArgumentException("Missing scheduler for tag " + tag); } schedulers.put(tag, scheduler); } return scheduler; } private  JobScheduler(Context context); static synchronized JobScheduler get(Context context); int schedule(JobInfo job); void cancel(int jobId); void cancelAll(); @NonNull List<JobInfo> getAllPendingJobs(); @Nullable JobInfo getPendingJob(int jobId); @RestrictTo(RestrictTo.Scope.LIBRARY) void onJobCompleted(int jobId, boolean needsReschedule); @RestrictTo(RestrictTo.Scope.LIBRARY) List<JobStatus> getJobsByScheduler(String scheduler); @RestrictTo(RestrictTo.Scope.LIBRARY) JobStatus getJob(int jobId); @RestrictTo(RestrictTo.Scope.LIBRARY) void addJob(JobStatus jobStatus); @RestrictTo(RestrictTo.Scope.LIBRARY) void removeJob(int jobId); static final int RESULT_FAILURE; static final int RESULT_SUCCESS; }