Fix few issues in virtual camera service:
* Fix incorrect flush implementation (do not try to fetch element from
empty queue).
* Gracefully handle flush call even if render thread is not running.
* Make sure thread is terminated when close is called on session.
* Remove metadata from CaptureResult send when processing flush
request.
* Set streamId to -1 in ErrorRequest NotifyMsg (required, otherwise
it NotifyMsg fails validation in framework).
Bug: 301023410
Test: atest virtual_camera_tests
Test: OpenCamera
Change-Id: I899a9eaed0b69eed93945391c2d0a25120136267
diff --git a/services/camera/virtualcamera/tests/VirtualCameraSessionTest.cc b/services/camera/virtualcamera/tests/VirtualCameraSessionTest.cc
index 0bc5210..74505af 100644
--- a/services/camera/virtualcamera/tests/VirtualCameraSessionTest.cc
+++ b/services/camera/virtualcamera/tests/VirtualCameraSessionTest.cc
@@ -175,6 +175,14 @@
ASSERT_TRUE(mVirtualCameraSession->close().isOk());
}
+TEST_F(VirtualCameraSessionTest, FlushBeforeConfigure) {
+ // Flush request coming before the configure request finished
+ // (so potentially the thread is not yet running) should be
+ // gracefully handled.
+
+ EXPECT_TRUE(mVirtualCameraSession->flush().isOk());
+}
+
TEST_F(VirtualCameraSessionTest, onProcessCaptureRequestTriggersClientCallback) {
StreamConfiguration streamConfiguration;
streamConfiguration.streams = {