diff options
Diffstat (limited to 'services/sensorservice/SensorService.cpp')
-rw-r--r-- | services/sensorservice/SensorService.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index fd72b23..3d9dcd0 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 @@ -358,6 +359,8 @@ status_t SensorService::dump(int fd, const Vector<String16>& args) result.appendFormat("non-wakeUp | "); } + result.appendFormat("%.4f mA | ", s.getPowerUsage()); + int bufIndex = mLastEventSeen.indexOfKey(s.getHandle()); if (bufIndex >= 0) { const CircularBuffer* buf = mLastEventSeen.valueAt(bufIndex); @@ -918,17 +921,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 +960,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); @@ -1109,7 +1120,7 @@ bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, AppOpsManager appOps; if (appOps.noteOp(opCode, IPCThreadState::self()->getCallingUid(), opPackageName) != AppOpsManager::MODE_ALLOWED) { - ALOGE("%s a sensor (%s) without enabled required app op: %D", + ALOGE("%s a sensor (%s) without enabled required app op: %d", operation, sensor.getName().string(), opCode); return false; } |