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

Commit 2c313368 authored by Brian Stack's avatar Brian Stack
Browse files

Add WakeLockQueueFlagBits to Sensors 2.0

WakeLockQueueFlagBits is used to signal between the framework and the
HAL whenever events are available on the Wake Lock FMQ. The
introduction of this type allows for the HAL to utilize blocking calls
when reading the Wake Lock FMQ, if desired.

Also removes stale reference to WakeLockEvent.

Bug: 122528664
Test: Builds, verified Sensors 2.0 default implementation reads events
      when they become available on the Wake Lock FMQ

Change-Id: Ia83bd1642b8f6aa8ea86da05e83f4040c6e593bb
parent 9cef234b
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -95,11 +95,15 @@ interface ISensors {
     * The Wake Lock FMQ is used by the framework to notify the HAL when it is
     * 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
     * safe to release its wake_lock. When the framework receives WAKE_UP events
     * from the Event FMQ and the framework has acquired a wake_lock, the
     * from the Event FMQ and the framework has acquired a wake_lock, the
     * framework must write a WakeLockEvent to the Wake Lock FMQ with the number
     * framework must write the number of WAKE_UP events processed to the Wake
     * of WAKE_UP events processed. When the HAL reads the WakeLockEvent from
     * Lock FMQ. When the HAL reads the data from the Wake Lock FMQ, the HAL
     * the Wake Lock FMQ, the HAL should decrement its current count of
     * decrements its current count of unprocessed WAKE_UP events and releases
     * unprocessed WAKE_UP events and release its wake_lock if the current
     * its wake_lock if the current count of unprocessed WAKE_UP events is
     * count of unprocessed WAKE_UP events is zero.
     * zero.
     *
     * The framework must use the WakeLockQueueFlagBits::DATA_WRITTEN value to
     * notify the HAL that data has been written to the Wake Lock FMQ and must
     * be read by HAL.
     *
     *
     * The ISensorsCallback is used by the HAL to notify the framework of
     * The ISensorsCallback is used by the HAL to notify the framework of
     * asynchronous events, such as a dynamic sensor connection.
     * asynchronous events, such as a dynamic sensor connection.
+4 −1
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ using ::android::hardware::sensors::V1_0::RateLevel;
using ::android::hardware::sensors::V1_0::Result;
using ::android::hardware::sensors::V1_0::Result;
using ::android::hardware::sensors::V1_0::SharedMemInfo;
using ::android::hardware::sensors::V1_0::SharedMemInfo;
using ::android::hardware::sensors::V2_0::SensorTimeout;
using ::android::hardware::sensors::V2_0::SensorTimeout;
using ::android::hardware::sensors::V2_0::WakeLockQueueFlagBits;


constexpr const char* kWakeLockName = "SensorsHAL_WAKEUP";
constexpr const char* kWakeLockName = "SensorsHAL_WAKEUP";


@@ -215,7 +216,9 @@ void Sensors::readWakeLockFMQ() {


        // Read events from the Wake Lock FMQ. Timeout after a reasonable amount of time to ensure
        // Read events from the Wake Lock FMQ. Timeout after a reasonable amount of time to ensure
        // that any held wake lock is able to be released if it is held for too long.
        // that any held wake lock is able to be released if it is held for too long.
        mWakeLockQueue->readBlocking(&eventsHandled, 1 /* count */, kReadTimeoutNs);
        mWakeLockQueue->readBlocking(&eventsHandled, 1 /* count */, 0 /* readNotification */,
                                     static_cast<uint32_t>(WakeLockQueueFlagBits::DATA_WRITTEN),
                                     kReadTimeoutNs);
        updateWakeLock(0 /* eventsWritten */, eventsHandled);
        updateWakeLock(0 /* eventsWritten */, eventsHandled);
    }
    }
}
}
+8 −0
Original line number Original line Diff line number Diff line
@@ -40,3 +40,11 @@ enum EventQueueFlagBits : uint32_t {
     */
     */
     EVENTS_READ = 1 << 1,
     EVENTS_READ = 1 << 1,
};
};

enum WakeLockQueueFlagBits : uint32_t {
    /**
     * Used to notify the HAL that the framework has written data to the Wake
     * Lock FMQ.
     */
     DATA_WRITTEN = 1 << 0,
};