mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 10:44:41 +00:00
Use NativeHandle in MQDescriptor instead of ParcelFileDescriptor
android.hardware.common.fmq.MQDescriptor needs to handle multiple file descriptors, so changing from ParcelFileDescriptor to android.hardware.common.NativeHandle. android.hardware.common.fmq.GrantorDescriptor needs to keep track of the fdIndex as well. Bug: 176912570 Test: atest fmq_unit_tests fmq_test Change-Id: I15f2393e6c420ae5394322b28c4523fa80f7dcc7
This commit is contained in:
@@ -41,12 +41,15 @@ interface ITestMsgQ {
|
||||
*
|
||||
* @param configureFmq The server sets up a new unsynchronized FMQ if
|
||||
* this parameter is true.
|
||||
* @param userFd True to initialize the message queue with a user supplied
|
||||
* file descriptor for the ring buffer.
|
||||
* False to let the message queue use a single FD for everything.
|
||||
*
|
||||
* @return ret True if successful.
|
||||
* @return mqDesc This structure describes the unsynchronized FMQ that was
|
||||
* set up by the service. Client can use it to set up the FMQ at its end.
|
||||
*/
|
||||
getFmqUnsyncWrite(bool configureFmq) generates(bool ret, fmq_unsync<int32_t> mqDesc);
|
||||
getFmqUnsyncWrite(bool configureFmq, bool userFd) generates(bool ret, fmq_unsync<int32_t> mqDesc);
|
||||
|
||||
/**
|
||||
* This method request the service to write into the synchronized read/write
|
||||
|
||||
@@ -91,9 +91,10 @@ cc_test {
|
||||
// These are static libs only for testing purposes and portability. Shared
|
||||
// libs should be used on device.
|
||||
static_libs: [
|
||||
"android.hardware.common-unstable-ndk_platform",
|
||||
"android.hardware.common.fmq-unstable-ndk_platform",
|
||||
"android.hardware.tests.msgq@1.0",
|
||||
"android.fmq.test-ndk_platform",
|
||||
"android.hardware.common.fmq-unstable-ndk_platform",
|
||||
],
|
||||
whole_static_libs: [
|
||||
"android.hardware.tests.msgq@1.0-impl",
|
||||
|
||||
@@ -41,10 +41,19 @@ Return<bool> TestMsgQ::configureFmqSyncReadWrite(
|
||||
return true;
|
||||
}
|
||||
|
||||
Return<void> TestMsgQ::getFmqUnsyncWrite(bool configureFmq, getFmqUnsyncWrite_cb _hidl_cb) {
|
||||
Return<void> TestMsgQ::getFmqUnsyncWrite(bool configureFmq, bool userFd,
|
||||
getFmqUnsyncWrite_cb _hidl_cb) {
|
||||
if (configureFmq) {
|
||||
static constexpr size_t kNumElementsInQueue = 1024;
|
||||
mFmqUnsynchronized.reset(new (std::nothrow) MessageQueueUnsync(kNumElementsInQueue));
|
||||
static constexpr size_t kElementSizeBytes = sizeof(int32_t);
|
||||
android::base::unique_fd ringbufferFd;
|
||||
if (userFd) {
|
||||
ringbufferFd.reset(
|
||||
::ashmem_create_region("UnsyncWrite", kNumElementsInQueue * kElementSizeBytes));
|
||||
}
|
||||
mFmqUnsynchronized.reset(new (std::nothrow) MessageQueueUnsync(
|
||||
kNumElementsInQueue, false, std::move(ringbufferFd),
|
||||
kNumElementsInQueue * kElementSizeBytes));
|
||||
}
|
||||
if ((mFmqUnsynchronized == nullptr) ||
|
||||
(mFmqUnsynchronized->isValid() == false)) {
|
||||
|
||||
@@ -56,7 +56,8 @@ struct TestMsgQ : public ITestMsgQ {
|
||||
|
||||
// Methods from ::android::hardware::tests::msgq::V1_0::ITestMsgQ follow.
|
||||
Return<bool> configureFmqSyncReadWrite(const MQDescriptorSync<int32_t>& mqDesc) override;
|
||||
Return<void> getFmqUnsyncWrite(bool configureFmq, getFmqUnsyncWrite_cb _hidl_cb) override;
|
||||
Return<void> getFmqUnsyncWrite(bool configureFmq, bool userFd,
|
||||
getFmqUnsyncWrite_cb _hidl_cb) override;
|
||||
Return<bool> requestWriteFmqSync(int32_t count) override;
|
||||
Return<bool> requestReadFmqSync(int32_t count) override;
|
||||
Return<bool> requestWriteFmqUnsync(int32_t count) override;
|
||||
|
||||
Reference in New Issue
Block a user