readSensor
suspend fun readSensor(context: Context, sensorType: Int, durationMs: Int? = null): List<SensorReading>?
Registers a one-shot listener on the default sensor of sensorType and collects readings.
When durationMs is null, returns after the first sample (single-reading mode); otherwise collects until roughly durationMs (clamped 1-5000) has elapsed. The whole operation is bounded by an overall timeout of durationMs + 500 ms; on timeout, whatever was collected is lost and null is returned (indistinguishable from the no-sensor case at this layer).
Return
the collected SensorReadings, or null if the sensor is absent or it times out.
Parameters
context
used to resolve android.hardware.SensorManager.
sensorType
a Sensor.TYPE_* constant.
durationMs
sampling window in ms, or null for a single reading.