AmbientLightSensor: Take |latest_reading_| into account in hasReading().
We were occasionally hitting a DCHECK in AmbientLightSensor's illuminance accessor after commit 2f0fc46c ("[sensors] Round off Ambient Light Sensor readouts to the nearest 50 Lux") when running the Generic Sensors web tests. We assumed that if Sensor::hasReading() returns true, then Sensor::OnSensorReadingChanged() would have been called first and |latest_reading_| would always be set. It turns out there is a small window when this is not true, when one sensor has been fully initialized by the time it received a "reading" event, but other sensors of the same type might not have had OnSensorReadingChanged() be called on them yet. Fix it by overriding Sensor::hasReading() in AmbientLightSensor: an ALS' definition of "having a reading" depends on whether |latest_reading_| has already been set (which means OnSensorReadingChanged() has been called and the value has been properly processed). Bug: 606766, 1078172 Change-Id: I115233e745b402e97e4223fffd4d68a4350451ca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2199287 Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Reviewed-by:Reilly Grant <reillyg@chromium.org> Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Cr-Commit-Position: refs/heads/master@{#772187}
Showing
Please register or sign in to comment