Change bufferhub's bufferId to int
After discussion we decided that our new system should still use int as
type of buffer id. Now the Id generator will generate int ids >= 0
instead of uint32_t ids > 0.
Remove redundant log in destructor of BufferNode, now only log when
freeId failed.
Update BufferHubIdGenerator_test.cpp to fit in current API. Add code to
cleanup generated ids in TestGenerateUniqueIncrementalID.
Test: BufferHubServer_test
Change-Id: I2018bfd009a3c311a99b9114762d0f4fbf1e3fe2
Fix: 118844348
diff --git a/services/bufferhub/BufferHubService.cpp b/services/bufferhub/BufferHubService.cpp
index 6389521..ad49cd6 100644
--- a/services/bufferhub/BufferHubService.cpp
+++ b/services/bufferhub/BufferHubService.cpp
@@ -343,15 +343,15 @@
// Implementation of this function should be consistent with the definition of bufferInfo handle in
// ui/BufferHubDefs.h.
-hidl_handle BufferHubService::buildBufferInfo(uint32_t bufferId, uint32_t clientBitMask,
+hidl_handle BufferHubService::buildBufferInfo(int bufferId, uint32_t clientBitMask,
uint32_t userMetadataSize, const int metadataFd) {
native_handle_t* infoHandle = native_handle_create(BufferHubDefs::kBufferInfoNumFds,
BufferHubDefs::kBufferInfoNumInts);
infoHandle->data[0] = dup(metadataFd);
+ infoHandle->data[1] = bufferId;
// Use memcpy to convert to int without missing digit.
// TOOD(b/121345852): use bit_cast to unpack bufferInfo when C++20 becomes available.
- memcpy(&infoHandle->data[1], &bufferId, sizeof(bufferId));
memcpy(&infoHandle->data[2], &clientBitMask, sizeof(clientBitMask));
memcpy(&infoHandle->data[3], &userMetadataSize, sizeof(userMetadataSize));