@Test @SmallTest @SdkSuppress(minSdkVersion = 23, maxSdkVersion = 23) public void testSystemJobScheduler_cancelsAllOnApi23() { mSystemJobScheduler.cancel(TEST_ID); verify(mJobScheduler, times(2)).cancel(anyInt()); }
@Override public void cancel(@NonNull String workSpecId) { List<JobInfo> allJobInfos = mJobScheduler.getAllPendingJobs(); if (allJobInfos != null) { for (JobInfo jobInfo : allJobInfos) { if (workSpecId.equals( jobInfo.getExtras().getString(SystemJobInfoConverter.EXTRA_WORK_SPEC_ID))) { mWorkManager.getWorkDatabase() .systemIdInfoDao() .removeSystemIdInfo(workSpecId); mJobScheduler.cancel(jobInfo.getId()); if (Build.VERSION.SDK_INT != 23) { return; } } } } }
SystemJobScheduler implements Scheduler { @Override public void cancel(@NonNull String workSpecId) { List<JobInfo> allJobInfos = mJobScheduler.getAllPendingJobs(); if (allJobInfos != null) { for (JobInfo jobInfo : allJobInfos) { if (workSpecId.equals( jobInfo.getExtras().getString(SystemJobInfoConverter.EXTRA_WORK_SPEC_ID))) { mWorkManager.getWorkDatabase() .systemIdInfoDao() .removeSystemIdInfo(workSpecId); mJobScheduler.cancel(jobInfo.getId()); if (Build.VERSION.SDK_INT != 23) { return; } } } } } }
SystemJobScheduler implements Scheduler { @Override public void cancel(@NonNull String workSpecId) { List<JobInfo> allJobInfos = mJobScheduler.getAllPendingJobs(); if (allJobInfos != null) { for (JobInfo jobInfo : allJobInfos) { if (workSpecId.equals( jobInfo.getExtras().getString(SystemJobInfoConverter.EXTRA_WORK_SPEC_ID))) { mWorkManager.getWorkDatabase() .systemIdInfoDao() .removeSystemIdInfo(workSpecId); mJobScheduler.cancel(jobInfo.getId()); if (Build.VERSION.SDK_INT != 23) { return; } } } } } SystemJobScheduler(@NonNull Context context, @NonNull WorkManagerImpl workManager); @VisibleForTesting  SystemJobScheduler(
            Context context,
            WorkManagerImpl workManager,
            JobScheduler jobScheduler,
            SystemJobInfoConverter systemJobInfoConverter); }
SystemJobScheduler implements Scheduler { @Override public void cancel(@NonNull String workSpecId) { List<JobInfo> allJobInfos = mJobScheduler.getAllPendingJobs(); if (allJobInfos != null) { for (JobInfo jobInfo : allJobInfos) { if (workSpecId.equals( jobInfo.getExtras().getString(SystemJobInfoConverter.EXTRA_WORK_SPEC_ID))) { mWorkManager.getWorkDatabase() .systemIdInfoDao() .removeSystemIdInfo(workSpecId); mJobScheduler.cancel(jobInfo.getId()); if (Build.VERSION.SDK_INT != 23) { return; } } } } } SystemJobScheduler(@NonNull Context context, @NonNull WorkManagerImpl workManager); @VisibleForTesting  SystemJobScheduler(
            Context context,
            WorkManagerImpl workManager,
            JobScheduler jobScheduler,
            SystemJobInfoConverter systemJobInfoConverter); @Override void schedule(WorkSpec... workSpecs); @VisibleForTesting void scheduleInternal(WorkSpec workSpec, int jobId); @Override void cancel(@NonNull String workSpecId); static void jobSchedulerCancelAll(@NonNull Context context); }
SystemJobScheduler implements Scheduler { @Override public void cancel(@NonNull String workSpecId) { List<JobInfo> allJobInfos = mJobScheduler.getAllPendingJobs(); if (allJobInfos != null) { for (JobInfo jobInfo : allJobInfos) { if (workSpecId.equals( jobInfo.getExtras().getString(SystemJobInfoConverter.EXTRA_WORK_SPEC_ID))) { mWorkManager.getWorkDatabase() .systemIdInfoDao() .removeSystemIdInfo(workSpecId); mJobScheduler.cancel(jobInfo.getId()); if (Build.VERSION.SDK_INT != 23) { return; } } } } } SystemJobScheduler(@NonNull Context context, @NonNull WorkManagerImpl workManager); @VisibleForTesting  SystemJobScheduler(
            Context context,
            WorkManagerImpl workManager,
            JobScheduler jobScheduler,
            SystemJobInfoConverter systemJobInfoConverter); @Override void schedule(WorkSpec... workSpecs); @VisibleForTesting void scheduleInternal(WorkSpec workSpec, int jobId); @Override void cancel(@NonNull String workSpecId); static void jobSchedulerCancelAll(@NonNull Context context);  }