cameraserver: Remove framework only keys before sending capture requests to hal.
Framework only keys ANDROID_SCALER_CROP_REGION_SET,
ANDROID_AF_REGION_SET, ANDROID_AE_REGION_SET, ANDROID_AWB_REGION_SET
must be removed before sending requests to the camera HAL. This is so
that camera HALs built with older versions of VNDK which don't have this
key defined do not fail validate_camera_metadata_structure().
Bug: 198535636
Test: Vendor Testing
Test: Camera CTS
Change-Id: I418831008c39a14b940b909da81b508c2f9b0f0d
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index a195fb1..87c1c75 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -4783,6 +4783,26 @@
return submitRequestSuccess;
}
+status_t Camera3Device::removeFwkOnlyRegionKeys(CameraMetadata *request) {
+ static const std::array<uint32_t, 4> kFwkOnlyRegionKeys = {ANDROID_CONTROL_AF_REGIONS_SET,
+ ANDROID_CONTROL_AE_REGIONS_SET, ANDROID_CONTROL_AWB_REGIONS_SET,
+ ANDROID_SCALER_CROP_REGION_SET};
+ if (request == nullptr) {
+ ALOGE("%s request metadata nullptr", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ status_t res = OK;
+ for (const auto &key : kFwkOnlyRegionKeys) {
+ if (request->exists(key)) {
+ res = request->erase(key);
+ if (res != OK) {
+ return res;
+ }
+ }
+ }
+ return OK;
+}
+
status_t Camera3Device::RequestThread::prepareHalRequests() {
ATRACE_CALL();
@@ -4842,6 +4862,12 @@
it != captureRequest->mSettingsList.end(); it++) {
if (parent->mUHRCropAndMeteringRegionMappers.find(it->cameraId) ==
parent->mUHRCropAndMeteringRegionMappers.end()) {
+ if (removeFwkOnlyRegionKeys(&(it->metadata)) != OK) {
+ SET_ERR("RequestThread: Unable to remove fwk-only keys from request"
+ "%d: %s (%d)", halRequest->frame_number, strerror(-res),
+ res);
+ return INVALID_OPERATION;
+ }
continue;
}
@@ -4856,6 +4882,12 @@
return INVALID_OPERATION;
}
captureRequest->mUHRCropAndMeteringRegionsUpdated = true;
+ if (removeFwkOnlyRegionKeys(&(it->metadata)) != OK) {
+ SET_ERR("RequestThread: Unable to remove fwk-only keys from request"
+ "%d: %s (%d)", halRequest->frame_number, strerror(-res),
+ res);
+ return INVALID_OPERATION;
+ }
}
}