Filter when to send interval/latency status events
Only post interval/latency status updates to nanoapps if the sensor
became enabled. This prevents posting the event to nanoapps in the case
when the sensor was stayed disabled, but received a onSamplingStatusUpdate
callback.
Bug: 111444100
Test: Compile and run sensor world with passive request to gyro,
verify events are not sent when the sensor was already disabled
Change-Id: Id97d0f59549eedf6caaf30d7a182737581a62e83
diff --git a/platform/slpi/see/platform_sensor.cc b/platform/slpi/see/platform_sensor.cc
index 857b6ed..5cf6a51 100644
--- a/platform/slpi/see/platform_sensor.cc
+++ b/platform/slpi/see/platform_sensor.cc
@@ -190,9 +190,9 @@
newStatus.latency = update.status.latency;
}
- if (newStatus.enabled != prevStatus.enabled
- || newStatus.interval != prevStatus.interval
- || newStatus.latency != prevStatus.latency) {
+ if (newStatus.enabled != prevStatus.enabled ||
+ (newStatus.enabled && (newStatus.interval != prevStatus.interval
+ || newStatus.latency != prevStatus.latency))) {
sensor->setSamplingStatus(newStatus);
// Only post to Nanoapps with an open request.