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
This commit is contained in:
Mathias Agopian 2011-11-01 17:37:49 -07:00
parent b3989276d1
commit ae09d65f5b

View File

@ -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);
}