ProcessingImageReader implements ImageReaderProxy { public void setCaptureBundle(@NonNull CaptureBundle captureBundle) { synchronized (mLock) { if (captureBundle.getCaptureStages() != null) { if (mInputImageReader.getMaxImages() < captureBundle.getCaptureStages().size()) { throw new IllegalArgumentException( "CaptureBundle is lager than InputImageReader."); } mCaptureIdList.clear(); for (CaptureStage captureStage : captureBundle.getCaptureStages()) { if (captureStage != null) { mCaptureIdList.add(captureStage.getId()); } } } mSettableImageProxyBundle = new SettableImageProxyBundle(mCaptureIdList); setupSettableImageProxyBundleCallbacks(); } } ProcessingImageReader(int width, int height, int format, int maxImages,
            @Nullable Handler handler,
            @NonNull CaptureBundle captureBundle, @NonNull CaptureProcessor captureProcessor);   ProcessingImageReader(ImageReaderProxy imageReader, @Nullable Handler handler,
            @NonNull CaptureBundle captureBundle,
            @NonNull CaptureProcessor captureProcessor); @Override @Nullable ImageProxy acquireLatestImage(); @Override @Nullable ImageProxy acquireNextImage(); @Override void close(); @Override int getHeight(); @Override int getWidth(); @Override int getImageFormat(); @Override int getMaxImages(); @Override Surface getSurface(); @Override void setOnImageAvailableListener(
            @Nullable final ImageReaderProxy.OnImageAvailableListener listener,
            @Nullable Handler handler); void setCaptureBundle(@NonNull CaptureBundle captureBundle);  }
@Test public void canSetFuturesInSettableImageProxyBundle() throws InterruptedException, TimeoutException, ExecutionException { final AtomicReference<ImageProxyBundle> bundleRef = new AtomicReference<>(); CaptureProcessor captureProcessor = new CaptureProcessor() { @Override public void onOutputSurface(Surface surface, int imageFormat) { } @Override public void process(ImageProxyBundle bundle) { bundleRef.set(bundle); } @Override public void onResolutionUpdate(Size size) { } }; ProcessingImageReader processingImageReader = new ProcessingImageReader( mImageReaderProxy, mMainHandler, mCaptureBundle, captureProcessor); Map<Integer, Long> resultMap = new HashMap<>(); resultMap.put(CAPTURE_ID_0, TIMESTAMP_0); resultMap.put(CAPTURE_ID_1, TIMESTAMP_1); triggerAndVerify(bundleRef, resultMap); processingImageReader.setCaptureBundle(CaptureBundles.createCaptureBundle(mCaptureStage2, mCaptureStage3)); Map<Integer, Long> resultMap1 = new HashMap<>(); resultMap1.put(CAPTURE_ID_2, TIMESTAMP_2); resultMap1.put(CAPTURE_ID_3, TIMESTAMP_3); triggerAndVerify(bundleRef, resultMap1); }
@Test(expected = IllegalArgumentException.class) public void captureStageExceedMaxCaptureStage_setCaptureBundleThrowsException() { ProcessingImageReader processingImageReader = new ProcessingImageReader(100, 100, ImageFormat.YUV_420_888, 2, mMainHandler, mCaptureBundle, mock(CaptureProcessor.class)); processingImageReader.setCaptureBundle( CaptureBundles.createCaptureBundle(mCaptureStage1, mCaptureStage2, mCaptureStage3)); }