Camera: VTS: Fix fence fd double close am: 3ad137edbb am: 2603479470 am: 7c4bb95a18 am: 36f18e9327

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2539830

Change-Id: Ifa023065ee2380dd87c898275fcd0d1cf261fcf5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shuzhen Wang 2023-04-18 01:43:17 +00:00 committed by Automerger Merge Worker
commit e1dcc40ec3
3 changed files with 17 additions and 3 deletions

View file

@ -150,7 +150,7 @@ void CameraAidlTest::waitForReleaseFence(
const native_handle_t* releaseFenceHandle = bufferAndTimestamp.buffer.releaseFence;
if (releaseFenceHandle != nullptr && releaseFenceHandle->numFds == 1 &&
releaseFenceHandle->data[0] >= 0) {
releaseFence = new android::Fence(releaseFenceHandle->data[0]);
releaseFence = new android::Fence(dup(releaseFenceHandle->data[0]));
}
if (releaseFence && releaseFence->isValid()) {
releaseFence->wait(/*ms*/ 300);

View file

@ -552,6 +552,20 @@ class CameraAidlTest : public ::testing::TestWithParam<std::string> {
hasInputBuffer(hasInput),
collectedResult(1, 10),
expectedPhysicalResults(extraPhysicalResult) {}
~InFlightRequest() {
for (auto& buffer : resultOutputBuffers) {
native_handle_t* acquireFenceHandle = const_cast<native_handle_t*>(
buffer.buffer.acquireFence);
native_handle_close(acquireFenceHandle);
native_handle_delete(acquireFenceHandle);
native_handle_t* releaseFenceHandle = const_cast<native_handle_t*>(
buffer.buffer.releaseFence);
native_handle_close(releaseFenceHandle);
native_handle_delete(releaseFenceHandle);
}
}
};
static bool matchDeviceName(const std::string& deviceName, const std::string& providerType,

View file

@ -428,8 +428,8 @@ bool DeviceCb::processCaptureResultLocked(
bufferId,
outputBuffer,
buffer.status,
::android::makeFromAidl(buffer.acquireFence),
::android::makeFromAidl(buffer.releaseFence)};
::android::dupFromAidl(buffer.acquireFence),
::android::dupFromAidl(buffer.releaseFence)};
streamBufferAndTimestamp.timeStamp = systemTime();
request->resultOutputBuffers.push_back(streamBufferAndTimestamp);
}