Implement flushing and improve request tracking.

BUG: https://b/29937783, https://b/32941326
TEST: unit tests pass, fixes 8 failing cts tests
Change-Id: Idc390bdc1e51ba2bdbda91d90acc459a09a5f174
diff --git a/modules/camera/3_4/camera.h b/modules/camera/3_4/camera.h
index f21d33f..e1f7639 100644
--- a/modules/camera/3_4/camera.h
+++ b/modules/camera/3_4/camera.h
@@ -55,7 +55,7 @@
         const camera_metadata_t *constructDefaultRequestSettings(int type);
         int processCaptureRequest(camera3_capture_request_t *temp_request);
         void dump(int fd);
-
+        int flush();
 
     protected:
         // Connect to the device: open dev nodes, etc.
@@ -82,6 +82,9 @@
         // Enqueue a request to receive data from the camera
         virtual int enqueueRequest(
             std::shared_ptr<CaptureRequest> request) = 0;
+        // Flush in flight buffers.
+        virtual int flushBuffers() = 0;
+
 
         // Callback for when the device has filled in the requested data.
         // Fills in the result struct, validates the data, sends appropriate
@@ -133,6 +136,7 @@
         // Lock protecting only static camera characteristics, which may
         // be accessed without the camera device open
         android::Mutex mStaticInfoLock;
+        android::Mutex mFlushLock;
         // Array of handles to streams currently in use by the device
         Stream **mStreams;
         // Number of streams in mStreams