Source:
protected boolean handleIntentEvenIfNoBootstrapperPresent(Intent intent) { if (intent.hasExtra(SensorbergServiceMessage.EXTRA_GENERIC_TYPE)) { int type = intent.getIntExtra(SensorbergServiceMessage.EXTRA_GENERIC_TYPE, -1); switch (type) { case SensorbergServiceMessage.MSG_SHUTDOWN: { Logger.log.serviceHandlesMessage(SensorbergServiceMessage.stringFrom(type)); MinimalBootstrapper minimalBootstrapper = bootstrapper != null ? bootstrapper : new MinimalBootstrapper(serviceScheduler); SensorbergServiceConfiguration.removeConfigurationFromDisk(fileManager); ScannerBroadcastReceiver.setManifestReceiverEnabled(false, this); GenericBroadcastReceiver.setManifestReceiverEnabled(false, this); minimalBootstrapper.unscheduleAllPendingActions(); minimalBootstrapper.stopScanning(); minimalBootstrapper.stopAllScheduledOperations(); bootstrapper = null; return SHUTDOWN_SERVICE; } case SensorbergServiceMessage.MSG_LIST_OF_BEACONS: { final Messenger messenger = intent.getParcelableExtra(SensorbergServiceMessage.MSG_LIST_OF_BEACONS_MESSENGER); final long milliseconds = intent.getLongExtra(SensorbergServiceMessage.MSG_LIST_OF_BEACONS_MILLIS, -1); ArrayList<BeaconId> beaconIds = map(SugarScan.latestEnterEvents(clock.now() - milliseconds), BeaconId.FROM_SUGAR_SCAN); if (bootstrapper != null) { beaconIds.addAll(bootstrapper.scanner.getCurrentBeacons()); } Message message = Message.obtain(); message.what = SensorbergServiceMessage.MSG_LIST_OF_BEACONS; Bundle bundle = new Bundle(); bundle.putParcelableArrayList(SensorbergServiceMessage.MSG_LIST_OF_BEACONS_BEACON_IDS, distinct(beaconIds)); message.setData(bundle); try { messenger.send(message); } catch (RemoteException ex) { ex.printStackTrace(); Logger.log.logError("Could not answer with the list of beacons", ex); } return CONTINUE_SERVICE; } } } return CONTINUE_SERVICE; }

Target:
protected boolean handleIntentEvenIfNoBootstrapperPresent(Intent intent) { if (intent.hasExtra(SensorbergServiceMessage.EXTRA_GENERIC_TYPE)) { int type = intent.getIntExtra(SensorbergServiceMessage.EXTRA_GENERIC_TYPE, -1); switch (type) { case SensorbergServiceMessage.MSG_SHUTDOWN: { Logger.log.serviceHandlesMessage(SensorbergServiceMessage.stringFrom(type)); MinimalBootstrapper minimalBootstrapper = bootstrapper != null ? bootstrapper : new MinimalBootstrapper(serviceScheduler); SensorbergServiceConfiguration.removeConfigurationFromDisk(fileManager); ScannerBroadcastReceiver.setManifestReceiverEnabled(false, this); GenericBroadcastReceiver.setManifestReceiverEnabled(false, this); minimalBootstrapper.unscheduleAllPendingActions(); minimalBootstrapper.stopScanning(); minimalBootstrapper.stopAllScheduledOperations(); bootstrapper = null; return SHUTDOWN_SERVICE; } case SensorbergServiceMessage.MSG_LIST_OF_BEACONS: { final Messenger messenger = intent.getParcelableExtra(SensorbergServiceMessage.MSG_LIST_OF_BEACONS_MESSENGER); final long milliseconds = intent.getLongExtra(SensorbergServiceMessage.MSG_LIST_OF_BEACONS_MILLIS, -1); ArrayList<BeaconId> beaconIds = map(BeaconActionHistoryPublisher.latestEnterEvents(clock.now() - milliseconds), BeaconId.FROM_BEACON_SCAN); if (bootstrapper != null) { beaconIds.addAll(bootstrapper.scanner.getCurrentBeacons()); } Message message = Message.obtain(); message.what = SensorbergServiceMessage.MSG_LIST_OF_BEACONS; Bundle bundle = new Bundle(); message.setData(bundle); try { messenger.send(message); } catch (RemoteException ex) { ex.printStackTrace(); Logger.log.logError("Could not answer with the list of beacons", ex); } return CONTINUE_SERVICE; } } } return CONTINUE_SERVICE; }