Removed 'flags' and 'fdIndex' fields from GrantorDescriptor
Removed the unnecessary fields from the
android.hardware.common.GrantorDescriptor type.
Needed change the AidlMQDescriptorShim to hold the android::hardware
version of GrantorDescriptor.
Moved that android::hardware::GrantorDescriptor definition to
MQDescriptorBase.h.
Added some translation between to two types with some bounds checking
for integer conversions. Added satization for intergers to the fmq
tests.
Test: atest fmq_unit_tests &&
system/tools/hidl/tests/run_all_device_tests.sh
Bug: 142326204
Change-Id: Ie802f91b09288b3508df50b556626a592c9c2d95
diff --git a/include/fmq/AidlMessageQueue.h b/include/fmq/AidlMessageQueue.h
index f650442..fe4edc4 100644
--- a/include/fmq/AidlMessageQueue.h
+++ b/include/fmq/AidlMessageQueue.h
@@ -22,12 +22,12 @@
#include <fmq/MessageQueueBase.h>
#include <utils/Log.h>
+namespace android {
+
using aidl::android::hardware::common::MQDescriptor;
using android::details::AidlMQDescriptorShim;
using android::hardware::MQFlavor;
-namespace android {
-
typedef uint64_t RingBufferPosition;
template <typename T, MQFlavor flavor>
@@ -77,10 +77,16 @@
MQDescriptor AidlMessageQueue<T, flavor>::dupeDesc() {
auto* shim = MessageQueueBase<AidlMQDescriptorShim, T, flavor>::getDesc();
if (shim) {
+ std::vector<aidl::android::hardware::common::GrantorDescriptor> grantors;
+ for (const auto& grantor : shim->grantors()) {
+ grantors.push_back(aidl::android::hardware::common::GrantorDescriptor{
+ .offset = static_cast<int32_t>(grantor.offset),
+ .extent = static_cast<int64_t>(grantor.extent)});
+ }
return MQDescriptor{
.quantum = static_cast<int32_t>(shim->getQuantum()),
- .grantors = shim->grantors(),
- .flags = shim->getFlags(),
+ .grantors = grantors,
+ .flags = static_cast<int32_t>(shim->getFlags()),
.fileDescriptor = ndk::ScopedFileDescriptor(dup(shim->handle()->data[0])),
};
} else {