Do not write into EglSurfaceTexture after creation

... beacuse it prevents other clients from connecting.
Instead, render/compress black image into output buffers
directly if the input surface texture doesn't have any
buffer yet.

Bug: 301023410
Test: OpenCamera
Test: atest virtual_camera_tests
Change-Id: I289ff00b590c9bc18052ae0cc15a9d7320b8f033
diff --git a/services/camera/virtualcamera/tests/EglUtilTest.cc b/services/camera/virtualcamera/tests/EglUtilTest.cc
index d387ebf..d0b7218 100644
--- a/services/camera/virtualcamera/tests/EglUtilTest.cc
+++ b/services/camera/virtualcamera/tests/EglUtilTest.cc
@@ -31,28 +31,12 @@
 namespace virtualcamera {
 namespace {
 
-using ::testing::Eq;
-using ::testing::NotNull;
+using ::testing::IsNull;
 
 constexpr int kWidth = 64;
 constexpr int kHeight = 64;
 constexpr char kGlExtYuvTarget[] = "GL_EXT_YUV_target";
 
-uint8_t getY(const android_ycbcr& ycbcr, const int x, const int y) {
-    uint8_t* yPtr = reinterpret_cast<uint8_t*>(ycbcr.y);
-    return *(yPtr + ycbcr.ystride * y + x);
-}
-
-uint8_t getCb(const android_ycbcr& ycbcr, const int x, const int y) {
-    uint8_t* cbPtr = reinterpret_cast<uint8_t*>(ycbcr.cb);
-    return *(cbPtr + ycbcr.cstride * (y / 2) + (x / 2) * ycbcr.chroma_step);
-}
-
-uint8_t getCr(const android_ycbcr& ycbcr, const int x, const int y) {
-    uint8_t* crPtr = reinterpret_cast<uint8_t*>(ycbcr.cr);
-    return *(crPtr + ycbcr.cstride * (y / 2) + (x / 2) * ycbcr.chroma_step);
-}
-
 TEST(EglDisplayContextTest, SuccessfulInitialization) {
   EglDisplayContext displayContext;
 
@@ -88,7 +72,7 @@
   EXPECT_TRUE(eglTextureProgram.isInitialized());
 }
 
-TEST_F(EglTest, EglSurfaceTextureBlackAfterInit) {
+TEST_F(EglTest, EglSurfaceCurrentBufferNullAfterInit) {
   if (!isGlExtensionSupported(kGlExtYuvTarget)) {
       GTEST_SKIP() << "Skipping test because of missing required GL extension " << kGlExtYuvTarget;
   }
@@ -97,24 +81,7 @@
   surfaceTexture.updateTexture();
   sp<GraphicBuffer> buffer = surfaceTexture.getCurrentBuffer();
 
-  ASSERT_THAT(buffer, NotNull());
-  const int width = buffer->getWidth();
-  const int height = buffer->getHeight();
-  ASSERT_THAT(width, Eq(kWidth));
-  ASSERT_THAT(height, Eq(kHeight));
-
-  android_ycbcr ycbcr;
-  status_t ret = buffer->lockYCbCr(AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN, &ycbcr);
-  ASSERT_THAT(ret, Eq(NO_ERROR));
-  for (int i = 0; i < width; ++i) {
-      for (int j = 0; j < height; ++j) {
-          EXPECT_THAT(getY(ycbcr, i, j), Eq(0x00));
-          EXPECT_THAT(getCb(ycbcr, i, j), Eq(0x7f));
-          EXPECT_THAT(getCr(ycbcr, i, j), Eq(0x7f));
-      }
-  }
-
-  buffer->unlock();
+  EXPECT_THAT(buffer, IsNull());
 }
 
 }  // namespace