Notify Event FMQ when sensor events are read
Notify the Event FMQ whenever sensor events are read by the framework.
This allows for the HAL to utilize the MessageQueue::writeBlocking
function when writing sensor events to the framework.
Bug: 111070257
Test: Verified that the default implementation blocks if the Event FMQ
is full until events are read by the framework.
Change-Id: I62888b38c498a3a0c48c9a6bdb9a1cbe2434df73
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index f2336cb..9b2cd50 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -467,6 +467,10 @@
size_t eventsToRead = std::min({availableEvents, maxNumEventsToRead, mEventBuffer.size()});
if (eventsToRead > 0) {
if (mEventQueue->read(mEventBuffer.data(), eventsToRead)) {
+ // Notify the Sensors HAL that sensor events have been read. This is required to support
+ // the use of writeBlocking by the Sensors HAL.
+ mEventQueueFlag->wake(asBaseType(EventQueueFlagBits::EVENTS_READ));
+
for (size_t i = 0; i < eventsToRead; i++) {
convertToSensorEvent(mEventBuffer[i], &buffer[i]);
}