Skip to content

Commit f61acda

Browse files
committed
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
1 parent a9656df commit f61acda

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

services/sensorservice/SensorService.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,20 @@ status_t SensorService::setEventRate(const sp<SensorEventConnection>& connection
471471
if (mInitCheck != NO_ERROR)
472472
return mInitCheck;
473473

474+
SensorInterface* sensor = mSensorMap.valueFor(handle);
475+
if (!sensor)
476+
return BAD_VALUE;
477+
474478
if (ns < 0)
475479
return BAD_VALUE;
476480

481+
if (ns == 0) {
482+
ns = sensor->getSensor().getMinDelayNs();
483+
}
484+
477485
if (ns < MINIMUM_EVENTS_PERIOD)
478486
ns = MINIMUM_EVENTS_PERIOD;
479487

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

0 commit comments

Comments
 (0)