Add Vts tests for FMQ
Ensure FMQ is supported through VTS, actually running, and can process
a variety of inputs.
Bug: 327047057
Test: atest VtsHalPowerTargetTest
Change-Id: I70edaf41fca544bfd48e1ce2a99f48e4a6a835b8
diff --git a/power/aidl/default/Android.bp b/power/aidl/default/Android.bp
index b4ccc7d..4926b91 100644
--- a/power/aidl/default/Android.bp
+++ b/power/aidl/default/Android.bp
@@ -35,6 +35,7 @@
"libbinder_ndk",
"libcutils",
"libfmq",
+ "libutils",
],
srcs: [
"main.cpp",
diff --git a/power/aidl/default/Power.cpp b/power/aidl/default/Power.cpp
index 8f15663..64294e5 100644
--- a/power/aidl/default/Power.cpp
+++ b/power/aidl/default/Power.cpp
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
#include <fmq/AidlMessageQueue.h>
#include <fmq/EventFlag.h>
+#include <thread>
namespace aidl {
namespace android {
@@ -85,10 +86,17 @@
}
ndk::ScopedAStatus Power::getSessionChannel(int32_t, int32_t, ChannelConfig* _aidl_return) {
- static AidlMessageQueue<ChannelMessage, SynchronizedReadWrite> stubQueue{1, true};
+ static AidlMessageQueue<ChannelMessage, SynchronizedReadWrite> stubQueue{20, true};
+ static std::thread stubThread([&] {
+ ChannelMessage data;
+ // This loop will only run while there is data waiting
+ // to be processed, and blocks on a futex all other times
+ while (stubQueue.readBlocking(&data, 1, 0)) {
+ }
+ });
_aidl_return->channelDescriptor = stubQueue.dupeDesc();
- _aidl_return->readFlagBitmask = 0;
- _aidl_return->writeFlagBitmask = 0;
+ _aidl_return->readFlagBitmask = 0x01;
+ _aidl_return->writeFlagBitmask = 0x02;
_aidl_return->eventFlagDescriptor = std::nullopt;
return ndk::ScopedAStatus::ok();
}