@Test public void testDispatchImmediately() { activityMonitor.startActivity(); dispatcher.dispatch(jobInfo); Intent intent = shadowOf(RuntimeEnvironment.application).getNextStartedService(); Intent expectedIntent = AirshipService.createIntent(context, jobInfo, null); assertEquals(expectedIntent.getAction(), intent.getAction()); assertEquals(expectedIntent.getComponent(), intent.getComponent()); assertBundlesEquals(expectedIntent.getExtras(), intent.getExtras()); }
public void dispatch(@NonNull JobInfo jobInfo) { try { if (requiresScheduling(jobInfo)) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); return; } try { getScheduler().cancel(context, jobInfo.getId()); context.startService(AirshipService.createIntent(context, jobInfo, null)); } catch (SecurityException | IllegalStateException ex) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); } } catch (SchedulerException e) { Logger.error(e, "Scheduler failed to schedule jobInfo"); if (useFallbackScheduler()) { dispatch(jobInfo); } } }
JobDispatcher { public void dispatch(@NonNull JobInfo jobInfo) { try { if (requiresScheduling(jobInfo)) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); return; } try { getScheduler().cancel(context, jobInfo.getId()); context.startService(AirshipService.createIntent(context, jobInfo, null)); } catch (SecurityException | IllegalStateException ex) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); } } catch (SchedulerException e) { Logger.error(e, "Scheduler failed to schedule jobInfo"); if (useFallbackScheduler()) { dispatch(jobInfo); } } } }
JobDispatcher { public void dispatch(@NonNull JobInfo jobInfo) { try { if (requiresScheduling(jobInfo)) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); return; } try { getScheduler().cancel(context, jobInfo.getId()); context.startService(AirshipService.createIntent(context, jobInfo, null)); } catch (SecurityException | IllegalStateException ex) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); } } catch (SchedulerException e) { Logger.error(e, "Scheduler failed to schedule jobInfo"); if (useFallbackScheduler()) { dispatch(jobInfo); } } } private  JobDispatcher(@NonNull Context context); @VisibleForTesting  JobDispatcher(@NonNull Context context, SchedulerFactory schedulerFactory, ActivityMonitor activityMonitor); }
JobDispatcher { public void dispatch(@NonNull JobInfo jobInfo) { try { if (requiresScheduling(jobInfo)) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); return; } try { getScheduler().cancel(context, jobInfo.getId()); context.startService(AirshipService.createIntent(context, jobInfo, null)); } catch (SecurityException | IllegalStateException ex) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); } } catch (SchedulerException e) { Logger.error(e, "Scheduler failed to schedule jobInfo"); if (useFallbackScheduler()) { dispatch(jobInfo); } } } private  JobDispatcher(@NonNull Context context); @VisibleForTesting  JobDispatcher(@NonNull Context context, SchedulerFactory schedulerFactory, ActivityMonitor activityMonitor); @NonNull static JobDispatcher shared(@NonNull Context context); void dispatch(@NonNull JobInfo jobInfo); void cancel(int jobId); }
JobDispatcher { public void dispatch(@NonNull JobInfo jobInfo) { try { if (requiresScheduling(jobInfo)) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); return; } try { getScheduler().cancel(context, jobInfo.getId()); context.startService(AirshipService.createIntent(context, jobInfo, null)); } catch (SecurityException | IllegalStateException ex) { getScheduler().schedule(context, jobInfo, getScheduleId(jobInfo.getId())); } } catch (SchedulerException e) { Logger.error(e, "Scheduler failed to schedule jobInfo"); if (useFallbackScheduler()) { dispatch(jobInfo); } } } private  JobDispatcher(@NonNull Context context); @VisibleForTesting  JobDispatcher(@NonNull Context context, SchedulerFactory schedulerFactory, ActivityMonitor activityMonitor); @NonNull static JobDispatcher shared(@NonNull Context context); void dispatch(@NonNull JobInfo jobInfo); void cancel(int jobId);  }