QCamera2: HAL3: Report ERROR_RESULT when metadata is dropped

When metadata is dropped due to lower performance scenarios,
report ERROR_RESULT to framework instead of ENODEV
as the metadata error can be recoverable.

Bug: 31008299
Change-Id: I14b6e45171692b966e30cd17730e2c0c56c2babd
diff --git a/camera/QCamera2/HAL3/QCamera3HWI.cpp b/camera/QCamera2/HAL3/QCamera3HWI.cpp
index 1c29db1..b5342c2 100644
--- a/camera/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/camera/QCamera2/HAL3/QCamera3HWI.cpp
@@ -2580,17 +2580,22 @@
                 i++;
                 continue;
             } else {
-                ALOGE("%s: Fatal: Missing metadata buffer for frame number %d", __func__, i->frame_number);
-                if (free_and_bufdone_meta_buf) {
-                    mMetadataChannel->bufDone(metadata_buf);
-                    free(metadata_buf);
-                }
+                ALOGE("%s: Missing metadata buffer for frame number %d, reporting CAMERA3_MSG_ERROR_RESULT",
+                     __func__, i->frame_number);
+
+                mPendingLiveRequest--;
+
+                CameraMetadata dummyMetadata;
+                dummyMetadata.update(ANDROID_REQUEST_ID, &(i->request_id), 1);
+                result.result = dummyMetadata.release();
+
                 camera3_notify_msg_t notify_msg;
                 memset(&notify_msg, 0, sizeof(notify_msg));
                 notify_msg.type = CAMERA3_MSG_ERROR;
-                notify_msg.message.error.error_code = CAMERA3_MSG_ERROR_DEVICE;
+                notify_msg.message.error.error_code = CAMERA3_MSG_ERROR_RESULT;
+                notify_msg.message.error.error_stream = NULL;
+                notify_msg.message.error.frame_number = i->frame_number;
                 mCallbackOps->notify(mCallbackOps, &notify_msg);
-                goto done_metadata;
             }
         } else {
             i->partial_result_cnt++;