@Test @SmallTest public void testGreedyScheduler_stopsWorkWhenConstraintsNotMet() { mGreedyScheduler.onAllConstraintsNotMet(Collections.singletonList(TEST_ID)); verify(mWorkManagerImpl).stopWork(TEST_ID); }
@Override public synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds) { for (String workSpecId : workSpecIds) { Log.d(TAG, String.format("Constraints not met: Cancelling work ID %s", workSpecId)); mWorkManagerImpl.stopWork(workSpecId); } }
GreedyScheduler implements Scheduler, WorkConstraintsCallback, ExecutionListener { @Override public synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds) { for (String workSpecId : workSpecIds) { Log.d(TAG, String.format("Constraints not met: Cancelling work ID %s", workSpecId)); mWorkManagerImpl.stopWork(workSpecId); } } }
GreedyScheduler implements Scheduler, WorkConstraintsCallback, ExecutionListener { @Override public synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds) { for (String workSpecId : workSpecIds) { Log.d(TAG, String.format("Constraints not met: Cancelling work ID %s", workSpecId)); mWorkManagerImpl.stopWork(workSpecId); } } GreedyScheduler(Context context, WorkManagerImpl workManagerImpl); @VisibleForTesting  GreedyScheduler(WorkManagerImpl workManagerImpl,
            WorkConstraintsTracker workConstraintsTracker); }
GreedyScheduler implements Scheduler, WorkConstraintsCallback, ExecutionListener { @Override public synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds) { for (String workSpecId : workSpecIds) { Log.d(TAG, String.format("Constraints not met: Cancelling work ID %s", workSpecId)); mWorkManagerImpl.stopWork(workSpecId); } } GreedyScheduler(Context context, WorkManagerImpl workManagerImpl); @VisibleForTesting  GreedyScheduler(WorkManagerImpl workManagerImpl,
            WorkConstraintsTracker workConstraintsTracker); @Override synchronized void schedule(WorkSpec... workSpecs); @Override synchronized void cancel(@NonNull String workSpecId); @Override synchronized void onAllConstraintsMet(@NonNull List<String> workSpecIds); @Override synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds); @Override synchronized void onExecuted(@NonNull String workSpecId,
            boolean isSuccessful,
            boolean needsReschedule); }
GreedyScheduler implements Scheduler, WorkConstraintsCallback, ExecutionListener { @Override public synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds) { for (String workSpecId : workSpecIds) { Log.d(TAG, String.format("Constraints not met: Cancelling work ID %s", workSpecId)); mWorkManagerImpl.stopWork(workSpecId); } } GreedyScheduler(Context context, WorkManagerImpl workManagerImpl); @VisibleForTesting  GreedyScheduler(WorkManagerImpl workManagerImpl,
            WorkConstraintsTracker workConstraintsTracker); @Override synchronized void schedule(WorkSpec... workSpecs); @Override synchronized void cancel(@NonNull String workSpecId); @Override synchronized void onAllConstraintsMet(@NonNull List<String> workSpecIds); @Override synchronized void onAllConstraintsNotMet(@NonNull List<String> workSpecIds); @Override synchronized void onExecuted(@NonNull String workSpecId,
            boolean isSuccessful,
            boolean needsReschedule);  }