From 7600ff4be021f85b42037be18719ba967d396591 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Tue, 3 Oct 2017 15:32:21 +0300 Subject: [PATCH] Rework the 'Connect to Sensor' abstract operation This patch: - Reworks the 'Connect to Sensor' abstract operation, so that it properly handles multiple device sensors - Drops 'identifying parameters' as those are unnecessary unless the Sensor Discovery functionality is in place. We might put them back when fixing #7. --- index.bs | 47 ++++---- index.html | 343 +++++++++++++++++++++++++---------------------------- 2 files changed, 181 insertions(+), 209 deletions(-) diff --git a/index.bs b/index.bs index 9f1c114..f5dc6a9 100644 --- a/index.bs +++ b/index.bs @@ -599,8 +599,13 @@ for each [=sensor types|type=] simply by instantiating the corresponding {{Sensor}} subclass. Indeed, without specific information identifying a particular [=device sensor|sensor=] -of a given [=sensor type|type=], -the default sensor is chosen. +of a given [=sensor type|type=], the default sensor is chosen by the +user agent. + +If the underlying platform provides an interface to find the [=default sensor=], +the user agent must choose the sensor offered by the platform, otherwise the user agent +itself defines which of the [=device sensor|sensors=] present on the device is +the [=default sensor=].
Listening to the default accelerometer changes: @@ -704,10 +709,6 @@ whose [=inherited interfaces=] contains {{Sensor}}. A [=sensor type=] has a [=ordered set|set=] of associated sensors. -If a [=sensor type=] has more than one [=platform sensor=], -it must have a set of associated identifying parameters -to select the right [=platform sensor=] to associate to each new {{Sensor}} objects. - A [=sensor type=] may have a [=default sensor=]. A [=sensor type=] has an associated {{PermissionName}}. @@ -964,14 +965,6 @@ with the internal slots described in the following table: notified after a new [=sensor reading=] was reported. It is initially false. - - \[[identifyingParameters]] - - A [=sensor type=]-specific group of [=dictionary members=] - used to select the correct [=platform sensor=] - to associate to this {{Sensor}} object. - - @@ -1016,7 +1009,8 @@ and "timestamp" as arguments. or "activated", then return. 1. Set |sensor_instance|.{{[[state]]}} to "activating". 1. Run these sub-steps [=in parallel=]: - 1. let |connected| be the result of invoking [=connect to sensor=]. + 1. let |connected| be the result of invoking [=connect to sensor=] with |sensor_instance| + as argument. 1. If |connected| is false, then 1. Let |e| be the result of [=created|creating=] a "{{NotReadableError!!exception}}" {{DOMException}}. @@ -1143,8 +1137,6 @@ Gets the {{Error}} object passed to {{SensorErrorEventInit}}. Note: there is not guarantee that the requested |options|.{{frequency!!dict-member}} can be respected. The actual [=sampling frequency=] can be calculated using {{Sensor}} {{Sensor/timestamp!!attribute}} attributes. - 1. If [=identifying parameters=] in |options| are set, then: - 1. Set |sensor_instance|.{{[[identifyingParameters]]}} to [=identifying parameters=]. 1. Set |sensor_instance|.{{[[state]]}} to "idle". 1. Return |sensor_instance|.
@@ -1160,16 +1152,18 @@ Gets the {{Error}} object passed to {{SensorErrorEventInit}}. :: True if sensor instance was associated with a [=platform sensor=], false otherwise. - 1. If |sensor_instance|.{{[[identifyingParameters]]}} is set and - |sensor_instance|.{{[[identifyingParameters]]}} allows - a unique [=platform sensor=] to be identified, then: - 1. let |sensor| be that [=platform sensor=], - 1. associate |sensor_instance| with |sensor|. - 1. Return true. - 1. If the [=sensor type=] of |sensor_instance| has an associated [=default sensor=] - and there is a corresponding [=platform sensor=] on the device, then - 1. associate |sensor_instance| with [=default sensor=]. + 1. Let |type| be the [=sensor type=] of |sensor_instance|. + 1. If the device has a single [=device sensor=] which can provide [=sensor readings|readings=] + for |type|, then + 1. Associate |sensor_instance| with a [=platform sensor=] corresponding + to this [=device sensor=]. 1. Return true. + 1. If the device has multiple [=device sensors=] which can provide [=sensor readings|readings=] + for |type|, then + 1. If |type| has an associated [=default sensor=], then + 1. Associate |sensor_instance| with a [=platform sensor=] corresponding + to [=default sensor=]. + 1. Return true. 1. Return false. @@ -1528,7 +1522,6 @@ for each [=sensor types=]: For [=sensor types=] where multiple [=device sensor|sensors=] are common, [=extension specifications=] may choose not to define a [=default sensor=], especially when doing so would not make sense. -- A set of [=identifying parameters=]. TODO: replace that by an abstract operation.

Extending the Permission API

diff --git a/index.html b/index.html index 49a2fb3..c9ab58a 100644 --- a/index.html +++ b/index.html @@ -1183,7 +1183,7 @@ background-attachment: fixed; } - +