Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35c1e696 authored by Peng Xu's avatar Peng Xu Committed by Android (Google) Code Review
Browse files

Merge "Sensor: Limit delay to maximum possible value before sending to HAL" into oc-dev

parents fe0cac23 d8a5ce39
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1249,6 +1249,12 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
            handle, connection.get());
    }

    // Check maximum delay for the sensor.
    nsecs_t maxDelayNs = sensor->getSensor().getMaxDelay() * 1000;
    if (maxDelayNs > 0 && (samplingPeriodNs > maxDelayNs)) {
        samplingPeriodNs = maxDelayNs;
    }

    nsecs_t minDelayNs = sensor->getSensor().getMinDelayNs();
    if (samplingPeriodNs < minDelayNs) {
        samplingPeriodNs = minDelayNs;