summaryrefslogtreecommitdiffstats
path: root/services/sensorservice/SensorService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/sensorservice/SensorService.cpp')
-rw-r--r--services/sensorservice/SensorService.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index fd72b23..28af943 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -146,9 +146,10 @@ void SensorService::onFirstRef()
aSensor = registerVirtualSensor( new OrientationSensor() );
if (virtualSensorsNeeds & (1<<SENSOR_TYPE_ROTATION_VECTOR)) {
- // if we are doing our own rotation-vector, also add
- // the orientation sensor and remove the HAL provided one.
- mUserSensorList.replaceAt(aSensor, orientationIndex);
+ if (orientationIndex == -1) {
+ // some sensor HALs don't provide an orientation sensor.
+ mUserSensorList.add(aSensor);
+ }
}
// virtual debugging sensors are not added to mUserSensorList
@@ -918,17 +919,20 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection,
// to maintain the on-change logic (any on-change events except the initial
// one should be trigger by a change in value). 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 &&
sensor->getSensor().getReportingMode() != AREPORTING_MODE_ON_CHANGE &&
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);
+ }
}
}
@@ -954,6 +958,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);