CheckedSurfaceTexture extends DeferrableSurface { @UiThread void resetSurfaceTexture() { if (mResolution == null) { throw new IllegalStateException( "setResolution() must be called before resetSurfaceTexture()"); } release(); mSurfaceTexture = createDetachedSurfaceTexture(mResolution); mOutputChangedListener.onTextureChanged(mSurfaceTexture, mResolution); } CheckedSurfaceTexture(
            OnTextureChangedListener outputChangedListener); @Override ListenableFuture<Surface> getSurface(); @Override void refresh();  }
@Test public void previewOutputUpdatesWhenReset() { mCheckedSurfaceTexture.resetSurfaceTexture(); SurfaceTexture initialOutput = mLatestSurfaceTexture; mCheckedSurfaceTexture.resetSurfaceTexture(); assertThat(initialOutput).isNotNull(); assertThat(mLatestSurfaceTexture).isNotNull(); assertThat(mLatestSurfaceTexture).isNotEqualTo(initialOutput); }