@Test public void stop_withCallback_done() throws Exception { StoppableJobService service = spy(new StoppableJobService( true)); JobInvocation job = new Builder() .setTag("Tag") .setTrigger(Trigger.NOW) .setService(StoppableJobService.class.getName()) .build(); Bundle jobSpecData = getJobCoder().encode(job, new Bundle()); FutureSettingJobCallback callback = new FutureSettingJobCallback(); IRemoteJobService.Stub.asInterface(service.onBind(null)).start(jobSpecData, callback); IRemoteJobService.Stub.asInterface(service.onBind(null)).stop(jobSpecData, true); flush(service); assertEquals(1, service.getNumberOfStopRequestsReceived()); callback.verifyCalledWithJobAndResult(job, JobService.RESULT_FAIL_RETRY); }
@Nullable @Override @MainThread public final IBinder onBind(Intent intent) { return binder; }
JobService extends Service { @Nullable @Override @MainThread public final IBinder onBind(Intent intent) { return binder; } }
JobService extends Service { @Nullable @Override @MainThread public final IBinder onBind(Intent intent) { return binder; }  }
JobService extends Service { @Nullable @Override @MainThread public final IBinder onBind(Intent intent) { return binder; }  @MainThread abstract boolean onStartJob(@NonNull JobParameters job); @MainThread abstract boolean onStopJob(@NonNull JobParameters job); @AnyThread final void jobFinished(@NonNull JobParameters job, boolean needsReschedule); @Override @MainThread final int onStartCommand(Intent intent, int flags, int startId); @Nullable @Override @MainThread final IBinder onBind(Intent intent); @Override @MainThread final boolean onUnbind(Intent intent); @Override @MainThread final void onRebind(Intent intent); @Override @MainThread final void onStart(Intent intent, int startId); @Override @MainThread final void onConfigurationChanged(Configuration newConfig); @Override @MainThread final void onTaskRemoved(Intent rootIntent); }
JobService extends Service { @Nullable @Override @MainThread public final IBinder onBind(Intent intent) { return binder; }  @MainThread abstract boolean onStartJob(@NonNull JobParameters job); @MainThread abstract boolean onStopJob(@NonNull JobParameters job); @AnyThread final void jobFinished(@NonNull JobParameters job, boolean needsReschedule); @Override @MainThread final int onStartCommand(Intent intent, int flags, int startId); @Nullable @Override @MainThread final IBinder onBind(Intent intent); @Override @MainThread final boolean onUnbind(Intent intent); @Override @MainThread final void onRebind(Intent intent); @Override @MainThread final void onStart(Intent intent, int startId); @Override @MainThread final void onConfigurationChanged(Configuration newConfig); @Override @MainThread final void onTaskRemoved(Intent rootIntent); static final int RESULT_SUCCESS; static final int RESULT_FAIL_RETRY; static final int RESULT_FAIL_NORETRY; }