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

Commit 515c6b44 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "fix an issue where SensorService could request an invalid sensor delay" into ics-mr1

parents 45a04db3 f61acdac
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);
}