Correct the camera stream behavior

When VirtualCamera receives a stream stopped event from HalCamera
unexpectedly, this change makes it to call stopVideoStream() and ensures
the resources are clean up properly.

Also, HalCamera is modified not to accept a new frame request when the
video stream is not running.

Fix: 169364969
Test: Run evs_virtualcamera_fuzzer
Change-Id: I3c8b714e38e136d59bf3fd4e7df6efe70438f243
Merged-In: I3c8b714e38e136d59bf3fd4e7df6efe70438f243
(cherry picked from commit ba634b0b87315609131e42e0ca7c82308c836c18)
diff --git a/evs/manager/1.1/HalCamera.cpp b/evs/manager/1.1/HalCamera.cpp
index 38297bb..0f58d51 100644
--- a/evs/manager/1.1/HalCamera.cpp
+++ b/evs/manager/1.1/HalCamera.cpp
@@ -236,6 +236,11 @@
 
     std::lock_guard<std::mutex> lock(mFrameMutex);
 
+    if (mStreamState != RUNNING) {
+        LOG(WARNING) << "This HalCamera is not streaming.";
+        return {};
+    }
+
     mTimelines[id]->BumpFenceEventCounter();
     UniqueFence fence = mTimelines[id]->CreateFence("FrameFence");
 
diff --git a/evs/manager/1.1/VirtualCamera.cpp b/evs/manager/1.1/VirtualCamera.cpp
index 6204a78..fda58d1 100644
--- a/evs/manager/1.1/VirtualCamera.cpp
+++ b/evs/manager/1.1/VirtualCamera.cpp
@@ -180,10 +180,13 @@
                 // Warn if we got an unexpected stream termination
                 LOG(WARNING) << "Stream unexpectedly stopped, current status "
                              << mStreamState;
-            }
 
-            // Mark the stream as stopped.
-            mStreamState = STOPPED;
+                // Clean up the resource and forward an event to the client
+                stopVideoStream();
+
+                // This event is handled properly.
+                return true;
+            }
 
             if (mStream_1_1 == nullptr) {
                 // Send a null frame instead, for v1.0 client