SensorService fixes.
1) Flush should only be received by the app calling flush(). Maintain
a queue of all flush() calls and send flush_complete events in that
order.
2) Log warnings for older HALs. Remove batch() calls with DRY_RUN flag.
3) Reallocate event cache when more sensors register and the desired
maxCacheSize increases. Clear NEEDS_ACK flag in the buffer whenever
there is a write() failure.
4) More dump information. Add wake-up flag, maxDelay and timestamps for
sensor events.
Bug: 16874778
Change-Id: I195646191059fd31f75f2f07886c0f98bf9b509a
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp
index 3934509..80845a2 100644
--- a/services/sensorservice/SensorDevice.cpp
+++ b/services/sensorservice/SensorDevice.cpp
@@ -54,6 +54,11 @@
SENSORS_HARDWARE_MODULE_ID, strerror(-err));
if (mSensorDevice) {
+ if (mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_1 ||
+ mSensorDevice->common.version == SENSORS_DEVICE_API_VERSION_1_2) {
+ ALOGE(">>>> WARNING <<< Upgrade sensor HAL to version 1_3");
+ }
+
sensor_t const* list;
ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
mActivationCount.setCapacity(count);
@@ -74,6 +79,7 @@
sensor_t const* list;
ssize_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
+ result.appendFormat("halVersion %d\n", getHalDeviceVersion());
result.appendFormat("%d h/w sensors:\n", int(count));
Mutex::Autolock _l(mLock);
@@ -210,24 +216,8 @@
}
const int halVersion = getHalDeviceVersion();
- if (halVersion >= SENSORS_DEVICE_API_VERSION_1_1) {
- if (flags & SENSORS_BATCH_DRY_RUN) {
- return mSensorDevice->batch(mSensorDevice, handle, flags, samplingPeriodNs,
- maxBatchReportLatencyNs);
- } else {
- // Call h/w with dry run to see if the given parameters are feasible or not. Return if
- // there is an error.
- status_t errDryRun(NO_ERROR);
- errDryRun = mSensorDevice->batch(mSensorDevice, handle, flags | SENSORS_BATCH_DRY_RUN,
- samplingPeriodNs, maxBatchReportLatencyNs);
- if (errDryRun != NO_ERROR) {
- ALOGD_IF(DEBUG_CONNECTIONS, "SensorDevice::batch dry run error %s",
- strerror(-errDryRun));
- return errDryRun;
- }
- }
- } else if (maxBatchReportLatencyNs != 0) {
- // Batch is not supported on older devices.
+ if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 && maxBatchReportLatencyNs != 0) {
+ // Batch is not supported on older devices return invalid operation.
return INVALID_OPERATION;
}