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

Commit ae09d65f authored by Mathias Agopian's avatar Mathias Agopian
Browse files

fix an issue where SensorService could request an invalid sensor delay

When the app requests "fastest", the java layer encodes this as a
delay of 0. SensorService was passing this unchanged to the HAL.
However the HAL is required to reject delays lower that the
advertised lower delay.

Change-Id: I92be77acd3af62ffeb49e4b31e24ddcd203510e2
parent b3989276
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -471,14 +471,20 @@ status_t SensorService::setEventRate(const sp<SensorEventConnection>& connection
    if (mInitCheck != NO_ERROR)
        return mInitCheck;

    SensorInterface* sensor = mSensorMap.valueFor(handle);
    if (!sensor)
        return BAD_VALUE;

    if (ns < 0)
        return BAD_VALUE;

    if (ns == 0) {
        ns = sensor->getSensor().getMinDelayNs();
    }

    if (ns < MINIMUM_EVENTS_PERIOD)
        ns = MINIMUM_EVENTS_PERIOD;

    SensorInterface* sensor = mSensorMap.valueFor(handle);
    if (!sensor) return BAD_VALUE;
    return sensor->setDelay(connection.get(), handle, ns);
}