mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 06:22:53 +00:00
Merge "Camera: Validate physical camera related metadata field from legacy HAL" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3cef9bf5b0
@@ -51,6 +51,32 @@ CameraDeviceSession::CameraDeviceSession(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
camera_metadata_entry_t capabilities =
|
||||
mDeviceInfo.find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
|
||||
bool isLogicalMultiCamera = false;
|
||||
for (size_t i = 0; i < capabilities.count; i++) {
|
||||
if (capabilities.data.u8[i] ==
|
||||
ANDROID_REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA) {
|
||||
isLogicalMultiCamera = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isLogicalMultiCamera) {
|
||||
camera_metadata_entry entry =
|
||||
mDeviceInfo.find(ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS);
|
||||
const uint8_t* ids = entry.data.u8;
|
||||
size_t start = 0;
|
||||
for (size_t i = 0; i < entry.count; ++i) {
|
||||
if (ids[i] == '\0') {
|
||||
if (start != i) {
|
||||
const char* physicalId = reinterpret_cast<const char*>(ids+start);
|
||||
mPhysicalCameraIds.emplace(physicalId);
|
||||
}
|
||||
start = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CameraDeviceSession::~CameraDeviceSession() {
|
||||
@@ -456,9 +482,19 @@ void CameraDeviceSession::sProcessCaptureResult_3_4(
|
||||
return;
|
||||
}
|
||||
|
||||
if (hal_result->num_physcam_metadata > d->mPhysicalCameraIds.size()) {
|
||||
ALOGE("%s: Fatal: Invalid num_physcam_metadata %u", __FUNCTION__,
|
||||
hal_result->num_physcam_metadata);
|
||||
return;
|
||||
}
|
||||
result.physicalCameraMetadata.resize(hal_result->num_physcam_metadata);
|
||||
for (uint32_t i = 0; i < hal_result->num_physcam_metadata; i++) {
|
||||
std::string physicalId = hal_result->physcam_ids[i];
|
||||
if (d->mPhysicalCameraIds.find(physicalId) == d->mPhysicalCameraIds.end()) {
|
||||
ALOGE("%s: Fatal: Invalid physcam_ids[%u]: %s", __FUNCTION__,
|
||||
i, hal_result->physcam_ids[i]);
|
||||
return;
|
||||
}
|
||||
V3_2::CameraMetadata physicalMetadata;
|
||||
V3_2::implementation::convertToHidl(hal_result->physcam_metadata[i], &physicalMetadata);
|
||||
PhysicalCameraMetadata physicalCameraMetadata = {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <hidl/Status.h>
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include "CameraMetadata.h"
|
||||
#include "HandleImporter.h"
|
||||
@@ -110,6 +111,10 @@ protected:
|
||||
|
||||
// Whether this camera device session is created with version 3.4 callback.
|
||||
bool mHasCallback_3_4;
|
||||
|
||||
// Physical camera ids for the logical multi-camera. Empty if this
|
||||
// is not a logical multi-camera.
|
||||
std::unordered_set<std::string> mPhysicalCameraIds;
|
||||
private:
|
||||
|
||||
struct TrampolineSessionInterface_3_4 : public ICameraDeviceSession {
|
||||
|
||||
Reference in New Issue
Block a user