Skip to content

Commit 515c6b4

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "fix an issue where SensorService could request an invalid sensor delay" into ics-mr1
2 parents 45a04db + f61acda commit 515c6b4

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)