[device-posture] Fetching the posture type needs to be async (#78)

darktears has just created a new issue for https://github.com/w3c/device-posture:

== Fetching the posture type needs to be async ==
As I'm working on the implementation of the spec inside Chromium (see WIP that I uploaded in https://chromium-review.googlesource.com/c/chromium/src/+/2985142/) it seems clear to me that `navigator.devicePosture.type` won't work.

On Android and Windows at the moment the posture is derived from the fold angle. In the future we may or not have a dedicated API to query the posture directly but that's what we have for now. On Android it means that we need to fetch the [hinge angle](https://developer.android.com/reference/android/hardware/Sensor#TYPE_HINGE_ANGLE) from the OS and that's an async operation. On Windows there isn't any API to fetch the hinge angle but so far the foldable devices shipping expose a custom sensor that is basically exposing the hinge angle as well. Similar to Android this is a async operation that may not return immediately. We need to first ask the OS access to the sensor and then wait the readings. This is extremely similar to the generic sensors btw.

So I suggest we change navigator.devicePosture.type to something else with a Promise that we can resolve when the browser have the first information to be able to compute the posture.

@kenchris

Please view or discuss this issue at https://github.com/w3c/device-posture/issues/78 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 24 June 2021 17:36:49 UTC