@Test public void testOnStartCommand_handlesStartJob_validRequest() throws Exception { JobService service = spy(new ExampleJobService()); Job jobSpec = TestUtil.getBuilderWithNoopValidator() .setTag("tag") .setService(ExampleJobService.class) .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL) .setTrigger(Trigger.NOW) .setLifetime(Lifetime.FOREVER) .build(); countDownLatch = new CountDownLatch(1); Bundle jobSpecData = getJobCoder().encode(jobSpec, new Bundle()); IRemoteJobService remoteJobService = IRemoteJobService.Stub.asInterface(service.onBind(new Intent(JobService.ACTION_EXECUTE))); remoteJobService.start(jobSpecData, noopCallback); flush(service); assertTrue("Expected job to run to completion", countDownLatch.await(5, TimeUnit.SECONDS)); }
@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; }