diff options
author | Mathias Agopian <mathias@google.com> | 2011-11-01 17:37:49 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2011-11-01 19:09:41 -0700 |
commit | f61acdac57ddac5ebc1b1ca009351fca86926152 (patch) | |
tree | 87622f1e1d396fc689d39d388e679b2654ce0438 /services/sensorservice | |
parent | a9656df58f75946f3eab4dd660df56c9d878a04e (diff) | |
download | frameworks_base-f61acdac57ddac5ebc1b1ca009351fca86926152.zip frameworks_base-f61acdac57ddac5ebc1b1ca009351fca86926152.tar.gz frameworks_base-f61acdac57ddac5ebc1b1ca009351fca86926152.tar.bz2 |
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
Diffstat (limited to 'services/sensorservice')
-rw-r--r-- | services/sensorservice/SensorService.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 5b74fb8..d2d2d8b 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -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); } |