Camera: VTS: Fix fence fd double close am: 3ad137edbb am: 053503888b

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

Change-Id: I137949037570e9359c18bd1390d85a4e3f7e5e30
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:47:23 +00:00 committed by Automerger Merge Worker
commit bc79bccb87
3 changed files with 17 additions and 3 deletions

View file

@ -148,7 +148,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

@ -478,6 +478,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);
}