- From: Alexander Shalamov via GitHub <sysbot+gh@w3.org>
- Date: Tue, 02 May 2017 13:13:30 +0000
- To: public-device-apis-log@w3.org
@lknik We are investigating different mitigation strategies for AmbientLightSensor. Could you provide details of the setup you've used, so that everyone can reproduce the results? Would be nice to know: - type of device - lighting conditions - distance to walls / ceiling or nearby objects that reflect / absorb ambient or screen light One of the solutions is to round-up readings. We could use simple JS wrapper, to find 'safe rounding zone' for ALS readings. ``` class RoundedAmbientLightSensor { constructor(frequency, threshold) { this.onchange_ = null; this.illuminance_ = null; this.sensor_ = new AmbientLightSensor({ frequency }); this.sensor_.onchange = () => { let old_illuminance = this.illuminance_; if (this.sensor_.illuminance != null) this.illuminance_ = Math.ceil(this.sensor_.illuminance / threshold) * threshold; if (this.onchange_ != null && this.illuminance_ != null && old_illuminance != this.illuminance_) { this.onchange_(); } }; } set onchange(func) { this.onchange_ = func; } get onchange() { return this.onchange_; } get illuminance() { return this.illuminance_; } get timestamp() { return this.sensor_.timestamp; } start() { this.sensor_.start(); } stop() { this.sensor_.stop(); } } ``` Example of how to use wrapper: ``` let x = new RoundedAmbientLightSensor(20, 20); x.onchange = () => { console.log(x.illuminance); } x.start(); ``` Would you have time to re-run tests that you mentioned in your [blog post](https://blog.lukaszolejnik.com/stealing-sensitive-browser-data-with-the-w3c-ambient-light-sensor-api/)? For example, with different thresholds (5, 10, 20, 50)? -- GitHub Notification of comment by alexshalamov Please view or discuss this issue at https://github.com/w3c/ambient-light/issues/13#issuecomment-298631563 using your GitHub account
Received on Tuesday, 2 May 2017 13:13:36 UTC