AmbientLightSensor: Ignore readings received before sensor activation.
This follows what Sensor::OnSensorReadingChanged() already does, but which we were missing in the AmbientLightSensor override. Platform sensor initialization happens before the sensor infrastructure on the Blink side transitions reaches Sensor::NotifyActivated() and transitions to the SensorState::kActivated state. In practice, this means we can start receiving readings too early, and in the Ambient Light Sensor case it meant setting |latest_reading_| to an actual value but never emitting a "reading" event, so users would never get notified of the first reading after starting the sensor (which also contradicts the spec). To make it worse, we have privacy measures in place that require illuminance readings to differ by a certain threshold before we emit a reading event, so if the user's surroundings did not change no reading event would ever be emitted at all, even though accessing the "illuminance" attribute in JS would actually return a rounded version of the first reading the platform sensor sent during initialization. Bug: 606766, 1046902 Change-Id: Id9e8844b5e4a199686024795befaa3539530cf0d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2030889 Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Commit-Queue: Reilly Grant <reillyg@chromium.org> Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Reviewed-by:Reilly Grant <reillyg@chromium.org> Cr-Commit-Position: refs/heads/master@{#736902}
Showing
Please register or sign in to comment