From 1f0c5ea652d6b4b8f68e88600ca2adb7942f06c5 Mon Sep 17 00:00:00 2001 From: Brian Stack Date: Tue, 18 Sep 2018 16:04:09 -0700 Subject: [PATCH] Define EventQueueFlagBits The EventQueueFlagBits is used to notify the other end of an FMQ when an action should be taken. For instance, the read end of the queue is able to wait on a particular mask bit to be set by the write end of the queue before reading events. This is necessary because the number of events to read must be specified when calling the FMQ's read() or readBlocking() functions. read() will fail if the specified number of events is not available. readBlocking() will not perform a partial read, so if the number of events to read is not known ahead of time, the function may block for an extended period of time until enough events are queued up. By utilizing the EventFlag, the reading of events is able to wait until events are ready to be read, and then the availableToRead() function provides the number of events to read when calling read() or readBlocking(). Bug: 111070257 Test: Compiles Change-Id: I20e9e566efc58196e27e50dae3fc13518ce605fc --- sensors/2.0/Android.bp | 1 + sensors/2.0/ISensors.hal | 4 ++++ sensors/2.0/types.hal | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/sensors/2.0/Android.bp b/sensors/2.0/Android.bp index 20bc4e1d2d..f61483482a 100644 --- a/sensors/2.0/Android.bp +++ b/sensors/2.0/Android.bp @@ -15,6 +15,7 @@ hidl_interface { "android.hidl.base@1.0", ], types: [ + "EventQueueFlagBits", "SensorTimeout", ], gen_java: false, diff --git a/sensors/2.0/ISensors.hal b/sensors/2.0/ISensors.hal index 32092ef224..24454b47c7 100644 --- a/sensors/2.0/ISensors.hal +++ b/sensors/2.0/ISensors.hal @@ -67,6 +67,10 @@ interface ISensors { * Data may only be written to the Event FMQ. Data must not be read from * the Event FMQ since the framework is the only reader. Upon receiving * sensor events, the HAL should write the sensor events to the Event FMQ. + * Once the HAL is finished writing sensor events to the Event FMQ, the HAL + * must call the Event FMQ's EventFlag wake() function with the + * EventQueueFlagBits::READ_AND_PROCESS mask which notifies the framework + * that sensor events are available to be read and processed. * * The Wake Lock FMQ is used by the framework to notify the HAL when it is * safe to release its wake_lock. When the framework receives WAKE_UP events diff --git a/sensors/2.0/types.hal b/sensors/2.0/types.hal index 16e1c03b3b..e1a029a082 100644 --- a/sensors/2.0/types.hal +++ b/sensors/2.0/types.hal @@ -23,3 +23,10 @@ enum SensorTimeout : int32_t { */ WAKE_LOCK_SECONDS = 1, }; + +enum EventQueueFlagBits : uint32_t { + /** + * Used to notify the Event FMQ that events should be read and processed. + */ + READ_AND_PROCESS = 1 << 0, +};