Add duplicate to BufferClient
Calling BufferClient::duplicate() will now return you an uint64_t token
stands for a specific BufferNode. In later CLs users could pass this
IPC-friendly token everywhere and use it to create a IBufferClient
linked to that BufferNode.
The token is derived from the mt19936_64 random algorithm. No same
tokens will be generated at the same time by checking the token_map_.
The map holds a weak_ptr so that if the BufferNode goes away by some
reason the map will not keep it, preventing from memory leak.
Add test case to test on the function.
Test: "atest buffer_hub_binder_service-test" passed.
Bug: 116681016
Change-Id: I54c34d9fabe882326faa141a6f0691419b740694
diff --git a/services/vr/bufferhubd/IBufferHub.cpp b/services/vr/bufferhubd/IBufferHub.cpp
index 2f39e41..a2c0a4a 100644
--- a/services/vr/bufferhubd/IBufferHub.cpp
+++ b/services/vr/bufferhubd/IBufferHub.cpp
@@ -64,7 +64,7 @@
sp<IBufferClient> ret = createBuffer(width, height, layer_count, format,
usage, user_metadata_size);
return reply->writeStrongBinder(IInterface::asBinder(ret));
- } break;
+ }
default:
// Should not reach except binder defined transactions such as dumpsys
return BBinder::onTransact(code, data, reply, flags);