Write to Wake Lock FMQ
Write the number of WAKE_UP sensor events handled by the Sensor
Service to the Wake Lock FMQ. This allows the Sensors HAL to release
its wake lock for events once the Sensor Service holds a wake lock for
the events.
Bug: 111070257
Test: Compile, configured system to use sensors@2.0 and ensured that
a_sns_test received events
Test: Ensured device with sensors@1.0 receives events as expected
Change-Id: Ide091012bdaeb2e6a9fc4f5a43ddbb298dbf3416
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 3822ee1..7c56e5c 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -651,16 +651,18 @@
// sending events to clients (incrementing SensorEventConnection::mWakeLockRefCount) should
// not be interleaved with decrementing SensorEventConnection::mWakeLockRefCount and
// releasing the wakelock.
- bool bufferHasWakeUpEvent = false;
+ uint32_t wakeEvents = 0;
for (int i = 0; i < count; i++) {
if (isWakeUpSensorEvent(mSensorEventBuffer[i])) {
- bufferHasWakeUpEvent = true;
- break;
+ wakeEvents++;
}
}
- if (bufferHasWakeUpEvent && !mWakeLockAcquired) {
- setWakeLockAcquiredLocked(true);
+ if (wakeEvents > 0) {
+ if (!mWakeLockAcquired) {
+ setWakeLockAcquiredLocked(true);
+ }
+ device.writeWakeLockHandled(wakeEvents);
}
recordLastValueLocked(mSensorEventBuffer, count);