summaryrefslogtreecommitdiff
path: root/camera/device/3.4/default/CameraDeviceSession.cpp
diff options
context:
space:
mode:
authorEmilian Peev <epeev@google.com>2019-02-21 15:06:41 -0800
committerEmilian Peev <epeev@google.com>2019-04-04 13:27:09 -0700
commit5874bba486f05516d8413ff3710bf2595c711d3b (patch)
treeea814e47acf2fd99bde0a04568951f942eb83c5c /camera/device/3.4/default/CameraDeviceSession.cpp
parent70eae1d3f0336a14ee60cd003255b58d9311cdc9 (diff)
Camera: Avoid using an uninitialized physical camera id
'mStreamMap' entries can be inserted by several versions of HIDL API calls. If the fields are initialized by an older version, then make sure that newer additions are always initialized in the respective API method. Bug: 73885805 Test: adb shell /data/nativetest64/VtsHalCameraProviderV2_4TargetTest/VtsHalCameraProviderV2_4TargetTest --hal_service_instance=android.hardware.camera.provider@2.4::ICameraProvider/legacy/0 Change-Id: Ib5bd8f608da05f628c52d288c518cebbe964182b
Diffstat (limited to 'camera/device/3.4/default/CameraDeviceSession.cpp')
-rw-r--r--camera/device/3.4/default/CameraDeviceSession.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/camera/device/3.4/default/CameraDeviceSession.cpp b/camera/device/3.4/default/CameraDeviceSession.cpp
index e00b3f83d0..03b6050397 100644
--- a/camera/device/3.4/default/CameraDeviceSession.cpp
+++ b/camera/device/3.4/default/CameraDeviceSession.cpp
@@ -187,7 +187,6 @@ bool CameraDeviceSession::preProcessConfigurationLocked_3_4(
mPhysicalCameraIdMap[id] = requestedConfiguration.streams[i].physicalCameraId;
mStreamMap[id].data_space = mapToLegacyDataspace(
mStreamMap[id].data_space);
- mStreamMap[id].physical_camera_id = mPhysicalCameraIdMap[id].c_str();
mCirculatingBuffers.emplace(stream.mId, CirculatingBuffers{});
} else {
// width/height/format must not change, but usage/rotation might need to change
@@ -206,6 +205,11 @@ bool CameraDeviceSession::preProcessConfigurationLocked_3_4(
mStreamMap[id].rotation = (int) requestedConfiguration.streams[i].v3_2.rotation;
mStreamMap[id].usage = (uint32_t) requestedConfiguration.streams[i].v3_2.usage;
}
+ // It is possible for the entry in 'mStreamMap' to get initialized by an older
+ // HIDL API. Make sure that the physical id is always initialized when using
+ // a more recent API call.
+ mStreamMap[id].physical_camera_id = mPhysicalCameraIdMap[id].c_str();
+
(*streams)[i] = &mStreamMap[id];
}