Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af1b54cd authored by Brian Stack's avatar Brian Stack
Browse files

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
parent cb10f956
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -467,6 +467,10 @@ ssize_t SensorDevice::pollFmq(sensors_event_t* buffer, size_t maxNumEventsToRead
    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]);
            }