summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-12-15 18:12:17 +0000
committerSteve Kondik <shade@chemlab.org>2015-11-07 13:48:42 -0800
commitc77679141d48c6fb593a1b23f5a985f2330f5820 (patch)
tree6fa73a98a00917d81079f1f0a760e245cabbb4dc /services
parent5b6a10373ee6280155f91ef82f51509014530b1e (diff)
downloadframeworks_native-c77679141d48c6fb593a1b23f5a985f2330f5820.zip
frameworks_native-c77679141d48c6fb593a1b23f5a985f2330f5820.tar.gz
frameworks_native-c77679141d48c6fb593a1b23f5a985f2330f5820.tar.bz2
sensorservice: Fix init sequence for pre-1.1 API sensor HALs
The sensors API introduced a new flush() method that older binaries won't have. For those, replace the firstFlush invocation with a setDelay call since a lot of implementations interpreted that as the initialization step. We also don't want any kind of call to flush() to happen when it isn't there, since it'll either hit a random OEM extension or a memory address we really don't want to execute. Change-Id: I26ce923fe385751fed7d1c483a53c074249f0620 sensorservice: Set the rate for pre-1.1 HALs _after_ activation We want to be sure these are applied in the same sequence they used to be... Change-Id: Ied2ba08ed3c4bed3a80bac6ab5471fcea9ba2c09
Diffstat (limited to 'services')
-rw-r--r--services/sensorservice/SensorService.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 40b21a9..313011a 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -915,15 +915,18 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
// Call flush() before calling activate() on the sensor. Wait for a first flush complete
// event before sending events on this connection. Ignore one-shot sensors which don't
// support flush(). Also if this sensor isn't already active, don't call flush().
+ const SensorDevice& device(SensorDevice::getInstance());
if (err == NO_ERROR && sensor->getSensor().getReportingMode() != AREPORTING_MODE_ONE_SHOT &&
rec->getNumConnections() > 1) {
- connection->setFirstFlushPending(handle, true);
- status_t err_flush = sensor->flush(connection.get(), handle);
- // Flush may return error if the underlying h/w sensor uses an older HAL.
- if (err_flush == NO_ERROR) {
- rec->addPendingFlushConnection(connection.get());
- } else {
- connection->setFirstFlushPending(handle, false);
+ if (device.getHalDeviceVersion() >= SENSORS_DEVICE_API_VERSION_1_1) {
+ connection->setFirstFlushPending(handle, true);
+ status_t err_flush = sensor->flush(connection.get(), handle);
+ // Flush may return error if the underlying h/w sensor uses an older HAL.
+ if (err_flush == NO_ERROR) {
+ rec->addPendingFlushConnection(connection.get());
+ } else {
+ connection->setFirstFlushPending(handle, false);
+ }
}
}
@@ -949,6 +952,11 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
mNextSensorRegIndex = (mNextSensorRegIndex + 1) % SENSOR_REGISTRATIONS_BUF_SIZE;
}
+ if (device.getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_1) {
+ // Pre-1.1 sensor HALs had no flush method, and relied on setDelay at init
+ sensor->setDelay(connection.get(), handle, samplingPeriodNs);
+ }
+
if (err != NO_ERROR) {
// batch/activate has failed, reset our state.
cleanupWithoutDisableLocked(connection, handle);