diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 57cb53c8a..11adbe24f 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -471,14 +471,20 @@ status_t SensorService::setEventRate(const sp& 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); }