@Test @SmallTest public void testCancelWorkById() { WorkSpecDao workSpecDao = mDatabase.workSpecDao(); OneTimeWorkRequest work0 = new OneTimeWorkRequest.Builder(TestWorker.class).build(); OneTimeWorkRequest work1 = new OneTimeWorkRequest.Builder(TestWorker.class).build(); insertWorkSpecAndTags(work0); insertWorkSpecAndTags(work1); mWorkManagerImpl.synchronous().cancelWorkByIdSync(work0.getId()); assertThat(workSpecDao.getState(work0.getStringId()), is(CANCELLED)); assertThat(workSpecDao.getState(work1.getStringId()), is(not(CANCELLED))); }
@Override public void cancelWorkById(@NonNull UUID id) { mTaskExecutor.executeOnBackgroundThread(CancelWorkRunnable.forId(id, this)); }
WorkManagerImpl extends WorkManager implements SynchronousWorkManager { @Override public void cancelWorkById(@NonNull UUID id) { mTaskExecutor.executeOnBackgroundThread(CancelWorkRunnable.forId(id, this)); } }
WorkManagerImpl extends WorkManager implements SynchronousWorkManager { @Override public void cancelWorkById(@NonNull UUID id) { mTaskExecutor.executeOnBackgroundThread(CancelWorkRunnable.forId(id, this)); } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  WorkManagerImpl(
            @NonNull Context context,
            @NonNull Configuration configuration); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  WorkManagerImpl(
            @NonNull Context context,
            @NonNull Configuration configuration,
            boolean useTestDatabase); }
WorkManagerImpl extends WorkManager implements SynchronousWorkManager { @Override public void cancelWorkById(@NonNull UUID id) { mTaskExecutor.executeOnBackgroundThread(CancelWorkRunnable.forId(id, this)); } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  WorkManagerImpl(
            @NonNull Context context,
            @NonNull Configuration configuration); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  WorkManagerImpl(
            @NonNull Context context,
            @NonNull Configuration configuration,
            boolean useTestDatabase); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) static void setDelegate(WorkManagerImpl delegate); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) static WorkManagerImpl getInstance(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) static void initialize(@NonNull Context context, @NonNull Configuration configuration); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) Context getApplicationContext(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) WorkDatabase getWorkDatabase(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull Configuration getConfiguration(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull List<Scheduler> getSchedulers(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull Processor getProcessor(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull TaskExecutor getTaskExecutor(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull Preferences getPreferences(); @Override void enqueue(@NonNull List<? extends WorkRequest> workRequests); @Override void enqueueSync(@NonNull WorkRequest... workRequest); @Override void enqueueSync(@NonNull List<? extends WorkRequest> workRequest); @Override WorkContinuation beginWith(@NonNull List<OneTimeWorkRequest> work); @Override WorkContinuation beginUniqueWork(
            @NonNull String uniqueWorkName,
            @NonNull ExistingWorkPolicy existingWorkPolicy,
            @NonNull List<OneTimeWorkRequest> work); @Override void enqueueUniquePeriodicWork(
            @NonNull String uniqueWorkName,
            @NonNull ExistingPeriodicWorkPolicy existingPeriodicWorkPolicy,
            @NonNull PeriodicWorkRequest periodicWork); @Override void enqueueUniquePeriodicWorkSync(
            @NonNull String uniqueWorkName,
            @NonNull ExistingPeriodicWorkPolicy existingPeriodicWorkPolicy,
            @NonNull PeriodicWorkRequest periodicWork); @Override void cancelWorkById(@NonNull UUID id); @Override @WorkerThread void cancelWorkByIdSync(@NonNull UUID id); @Override void cancelAllWorkByTag(@NonNull final String tag); @Override @WorkerThread void cancelAllWorkByTagSync(@NonNull String tag); @Override void cancelUniqueWork(@NonNull String uniqueWorkName); @Override @WorkerThread void cancelUniqueWorkSync(@NonNull String uniqueWorkName); @Override void cancelAllWork(); @Override @WorkerThread void cancelAllWorkSync(); @Override LiveData<Long> getLastCancelAllTimeMillis(); @Override long getLastCancelAllTimeMillisSync(); @Override void pruneWork(); @Override @WorkerThread void pruneWorkSync(); @Override LiveData<WorkStatus> getStatusById(@NonNull UUID id); @Override @WorkerThread @Nullable WorkStatus getStatusByIdSync(@NonNull UUID id); @Override LiveData<List<WorkStatus>> getStatusesByTag(@NonNull String tag); @Override List<WorkStatus> getStatusesByTagSync(@NonNull String tag); @Override LiveData<List<WorkStatus>> getStatusesForUniqueWork(@NonNull String uniqueWorkName); @Override List<WorkStatus> getStatusesForUniqueWorkSync(@NonNull String uniqueWorkName); @Override SynchronousWorkManager synchronous(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void startWork(String workSpecId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void startWork(String workSpecId, Extras.RuntimeExtras runtimeExtras); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void stopWork(String workSpecId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void rescheduleEligibleWork(); }
WorkManagerImpl extends WorkManager implements SynchronousWorkManager { @Override public void cancelWorkById(@NonNull UUID id) { mTaskExecutor.executeOnBackgroundThread(CancelWorkRunnable.forId(id, this)); } @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  WorkManagerImpl(
            @NonNull Context context,
            @NonNull Configuration configuration); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  WorkManagerImpl(
            @NonNull Context context,
            @NonNull Configuration configuration,
            boolean useTestDatabase); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) static void setDelegate(WorkManagerImpl delegate); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) static WorkManagerImpl getInstance(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) static void initialize(@NonNull Context context, @NonNull Configuration configuration); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) Context getApplicationContext(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) WorkDatabase getWorkDatabase(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull Configuration getConfiguration(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull List<Scheduler> getSchedulers(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull Processor getProcessor(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull TaskExecutor getTaskExecutor(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @NonNull Preferences getPreferences(); @Override void enqueue(@NonNull List<? extends WorkRequest> workRequests); @Override void enqueueSync(@NonNull WorkRequest... workRequest); @Override void enqueueSync(@NonNull List<? extends WorkRequest> workRequest); @Override WorkContinuation beginWith(@NonNull List<OneTimeWorkRequest> work); @Override WorkContinuation beginUniqueWork(
            @NonNull String uniqueWorkName,
            @NonNull ExistingWorkPolicy existingWorkPolicy,
            @NonNull List<OneTimeWorkRequest> work); @Override void enqueueUniquePeriodicWork(
            @NonNull String uniqueWorkName,
            @NonNull ExistingPeriodicWorkPolicy existingPeriodicWorkPolicy,
            @NonNull PeriodicWorkRequest periodicWork); @Override void enqueueUniquePeriodicWorkSync(
            @NonNull String uniqueWorkName,
            @NonNull ExistingPeriodicWorkPolicy existingPeriodicWorkPolicy,
            @NonNull PeriodicWorkRequest periodicWork); @Override void cancelWorkById(@NonNull UUID id); @Override @WorkerThread void cancelWorkByIdSync(@NonNull UUID id); @Override void cancelAllWorkByTag(@NonNull final String tag); @Override @WorkerThread void cancelAllWorkByTagSync(@NonNull String tag); @Override void cancelUniqueWork(@NonNull String uniqueWorkName); @Override @WorkerThread void cancelUniqueWorkSync(@NonNull String uniqueWorkName); @Override void cancelAllWork(); @Override @WorkerThread void cancelAllWorkSync(); @Override LiveData<Long> getLastCancelAllTimeMillis(); @Override long getLastCancelAllTimeMillisSync(); @Override void pruneWork(); @Override @WorkerThread void pruneWorkSync(); @Override LiveData<WorkStatus> getStatusById(@NonNull UUID id); @Override @WorkerThread @Nullable WorkStatus getStatusByIdSync(@NonNull UUID id); @Override LiveData<List<WorkStatus>> getStatusesByTag(@NonNull String tag); @Override List<WorkStatus> getStatusesByTagSync(@NonNull String tag); @Override LiveData<List<WorkStatus>> getStatusesForUniqueWork(@NonNull String uniqueWorkName); @Override List<WorkStatus> getStatusesForUniqueWorkSync(@NonNull String uniqueWorkName); @Override SynchronousWorkManager synchronous(); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void startWork(String workSpecId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void startWork(String workSpecId, Extras.RuntimeExtras runtimeExtras); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void stopWork(String workSpecId); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) void rescheduleEligibleWork(); static final int MAX_PRE_JOB_SCHEDULER_API_LEVEL; static final int MIN_JOB_SCHEDULER_API_LEVEL; }