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/BufferNode.cpp b/services/bufferhub/BufferNode.cpp
index da19a6f..5106390 100644
--- a/services/bufferhub/BufferNode.cpp
+++ b/services/bufferhub/BufferNode.cpp
@@ -30,7 +30,7 @@
// Allocates a new BufferNode.
BufferNode::BufferNode(uint32_t width, uint32_t height, uint32_t layer_count, uint32_t format,
- uint64_t usage, size_t user_metadata_size, uint32_t id)
+ uint64_t usage, size_t user_metadata_size, int id)
: mId(id) {
uint32_t out_stride = 0;
// graphicBufferId is not used in GraphicBufferAllocator::allocate
@@ -73,12 +73,8 @@
}
// Free the id, if valid
- if (id() != BufferHubIdGenerator::kInvalidId) {
- if (BufferHubIdGenerator::getInstance().freeId(id())) {
- ALOGI("%s: id #%u is freed.", __FUNCTION__, id());
- } else {
- ALOGE("%s: Cannot free nonexistent id #%u", __FUNCTION__, id());
- }
+ if (mId >= 0) {
+ BufferHubIdGenerator::getInstance().freeId(mId);
}
}