@Test public void unpackerExtractsCaptureCallbacks() { ImageCaptureConfig.Builder imageCaptureConfigBuilder = new ImageCaptureConfig.Builder(); CaptureCallback captureCallback = mock(CaptureCallback.class); new Camera2Config.Extender(imageCaptureConfigBuilder) .setSessionCaptureCallback(captureCallback); CaptureConfig.Builder captureBuilder = new CaptureConfig.Builder(); mUnpacker.unpack(imageCaptureConfigBuilder.build(), captureBuilder); CaptureConfig captureConfig = captureBuilder.build(); CameraCaptureCallback cameraCaptureCallback = captureConfig.getCameraCaptureCallbacks().get(0); assertThat(((CaptureCallbackContainer) cameraCaptureCallback).getCaptureCallback()) .isEqualTo(captureCallback); }
@Override public void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder) { CaptureConfig defaultCaptureConfig = config.getDefaultCaptureConfig( null); Config implOptions = OptionsBundle.emptyBundle(); int templateType = CaptureConfig.defaultEmptyCaptureConfig().getTemplateType(); if (defaultCaptureConfig != null) { templateType = defaultCaptureConfig.getTemplateType(); builder.addAllCameraCaptureCallbacks(defaultCaptureConfig.getCameraCaptureCallbacks()); implOptions = defaultCaptureConfig.getImplementationOptions(); } builder.setImplementationOptions(implOptions); final Camera2Config camera2Config = new Camera2Config(config); builder.setTemplateType(camera2Config.getCaptureRequestTemplate(templateType)); builder.addCameraCaptureCallback( CaptureCallbackContainer.create( camera2Config.getSessionCaptureCallback( Camera2CaptureCallbacks.createNoOpCallback()))); Camera2Config.Builder configBuilder = new Camera2Config.Builder(); for (Option<?> option : camera2Config.getCaptureRequestOptions()) { @SuppressWarnings("unchecked") Option<Object> typeErasedOption = (Option<Object>) option; @SuppressWarnings("unchecked") CaptureRequest.Key<Object> key = (CaptureRequest.Key<Object>) option.getToken(); configBuilder.setCaptureRequestOption(key, camera2Config.retrieveOption(typeErasedOption)); } builder.addImplementationOptions(configBuilder.build()); }
Camera2CaptureOptionUnpacker implements CaptureConfig.OptionUnpacker { @Override public void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder) { CaptureConfig defaultCaptureConfig = config.getDefaultCaptureConfig( null); Config implOptions = OptionsBundle.emptyBundle(); int templateType = CaptureConfig.defaultEmptyCaptureConfig().getTemplateType(); if (defaultCaptureConfig != null) { templateType = defaultCaptureConfig.getTemplateType(); builder.addAllCameraCaptureCallbacks(defaultCaptureConfig.getCameraCaptureCallbacks()); implOptions = defaultCaptureConfig.getImplementationOptions(); } builder.setImplementationOptions(implOptions); final Camera2Config camera2Config = new Camera2Config(config); builder.setTemplateType(camera2Config.getCaptureRequestTemplate(templateType)); builder.addCameraCaptureCallback( CaptureCallbackContainer.create( camera2Config.getSessionCaptureCallback( Camera2CaptureCallbacks.createNoOpCallback()))); Camera2Config.Builder configBuilder = new Camera2Config.Builder(); for (Option<?> option : camera2Config.getCaptureRequestOptions()) { @SuppressWarnings("unchecked") Option<Object> typeErasedOption = (Option<Object>) option; @SuppressWarnings("unchecked") CaptureRequest.Key<Object> key = (CaptureRequest.Key<Object>) option.getToken(); configBuilder.setCaptureRequestOption(key, camera2Config.retrieveOption(typeErasedOption)); } builder.addImplementationOptions(configBuilder.build()); } }
Camera2CaptureOptionUnpacker implements CaptureConfig.OptionUnpacker { @Override public void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder) { CaptureConfig defaultCaptureConfig = config.getDefaultCaptureConfig( null); Config implOptions = OptionsBundle.emptyBundle(); int templateType = CaptureConfig.defaultEmptyCaptureConfig().getTemplateType(); if (defaultCaptureConfig != null) { templateType = defaultCaptureConfig.getTemplateType(); builder.addAllCameraCaptureCallbacks(defaultCaptureConfig.getCameraCaptureCallbacks()); implOptions = defaultCaptureConfig.getImplementationOptions(); } builder.setImplementationOptions(implOptions); final Camera2Config camera2Config = new Camera2Config(config); builder.setTemplateType(camera2Config.getCaptureRequestTemplate(templateType)); builder.addCameraCaptureCallback( CaptureCallbackContainer.create( camera2Config.getSessionCaptureCallback( Camera2CaptureCallbacks.createNoOpCallback()))); Camera2Config.Builder configBuilder = new Camera2Config.Builder(); for (Option<?> option : camera2Config.getCaptureRequestOptions()) { @SuppressWarnings("unchecked") Option<Object> typeErasedOption = (Option<Object>) option; @SuppressWarnings("unchecked") CaptureRequest.Key<Object> key = (CaptureRequest.Key<Object>) option.getToken(); configBuilder.setCaptureRequestOption(key, camera2Config.retrieveOption(typeErasedOption)); } builder.addImplementationOptions(configBuilder.build()); }  }
Camera2CaptureOptionUnpacker implements CaptureConfig.OptionUnpacker { @Override public void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder) { CaptureConfig defaultCaptureConfig = config.getDefaultCaptureConfig( null); Config implOptions = OptionsBundle.emptyBundle(); int templateType = CaptureConfig.defaultEmptyCaptureConfig().getTemplateType(); if (defaultCaptureConfig != null) { templateType = defaultCaptureConfig.getTemplateType(); builder.addAllCameraCaptureCallbacks(defaultCaptureConfig.getCameraCaptureCallbacks()); implOptions = defaultCaptureConfig.getImplementationOptions(); } builder.setImplementationOptions(implOptions); final Camera2Config camera2Config = new Camera2Config(config); builder.setTemplateType(camera2Config.getCaptureRequestTemplate(templateType)); builder.addCameraCaptureCallback( CaptureCallbackContainer.create( camera2Config.getSessionCaptureCallback( Camera2CaptureCallbacks.createNoOpCallback()))); Camera2Config.Builder configBuilder = new Camera2Config.Builder(); for (Option<?> option : camera2Config.getCaptureRequestOptions()) { @SuppressWarnings("unchecked") Option<Object> typeErasedOption = (Option<Object>) option; @SuppressWarnings("unchecked") CaptureRequest.Key<Object> key = (CaptureRequest.Key<Object>) option.getToken(); configBuilder.setCaptureRequestOption(key, camera2Config.retrieveOption(typeErasedOption)); } builder.addImplementationOptions(configBuilder.build()); }  @Override void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder); }
Camera2CaptureOptionUnpacker implements CaptureConfig.OptionUnpacker { @Override public void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder) { CaptureConfig defaultCaptureConfig = config.getDefaultCaptureConfig( null); Config implOptions = OptionsBundle.emptyBundle(); int templateType = CaptureConfig.defaultEmptyCaptureConfig().getTemplateType(); if (defaultCaptureConfig != null) { templateType = defaultCaptureConfig.getTemplateType(); builder.addAllCameraCaptureCallbacks(defaultCaptureConfig.getCameraCaptureCallbacks()); implOptions = defaultCaptureConfig.getImplementationOptions(); } builder.setImplementationOptions(implOptions); final Camera2Config camera2Config = new Camera2Config(config); builder.setTemplateType(camera2Config.getCaptureRequestTemplate(templateType)); builder.addCameraCaptureCallback( CaptureCallbackContainer.create( camera2Config.getSessionCaptureCallback( Camera2CaptureCallbacks.createNoOpCallback()))); Camera2Config.Builder configBuilder = new Camera2Config.Builder(); for (Option<?> option : camera2Config.getCaptureRequestOptions()) { @SuppressWarnings("unchecked") Option<Object> typeErasedOption = (Option<Object>) option; @SuppressWarnings("unchecked") CaptureRequest.Key<Object> key = (CaptureRequest.Key<Object>) option.getToken(); configBuilder.setCaptureRequestOption(key, camera2Config.retrieveOption(typeErasedOption)); } builder.addImplementationOptions(configBuilder.build()); }  @Override void unpack(UseCaseConfig<?> config, final CaptureConfig.Builder builder);  }