private void updateTrackedResources(ApplicationId appId, boolean track) { if (intentService == null) { log.warn("Intent service is not bound yet"); return; } intentService .getIntents() .forEach( intent -> { if (intent.appId().equals(appId)) { Key key = intent.key(); Collection<NetworkResource> resources = Lists.newArrayList(); intentService .getInstallableIntents(key) .stream() .map(installable -> installable.resources()) .forEach(resources::addAll); if (track) { addTrackedResources(key, resources); } else { removeTrackedResources(key, resources); } } }); }