diff options
author | Nick Vaccaro <nvaccaro@google.com> | 2015-11-19 08:44:06 -0800 |
---|---|---|
committer | Nick Vaccaro <nvaccaro@google.com> | 2015-11-19 08:44:06 -0800 |
commit | 7af2cd1c96ced368c1ddeff60231000394b5cd95 (patch) | |
tree | f6a6527d539ee6b738d7fe3ded79b4cb29b7083a | |
parent | 63e566cd0bff765e37f12391cfc7131702b00dd9 (diff) | |
download | android_hardware_invensense-7af2cd1c96ced368c1ddeff60231000394b5cd95.tar.gz android_hardware_invensense-7af2cd1c96ced368c1ddeff60231000394b5cd95.tar.bz2 android_hardware_invensense-7af2cd1c96ced368c1ddeff60231000394b5cd95.zip |
Sensors: Invensense: 6515: don't send duplicate events
Discard any duplicate events found instead of sending to
Sensor Services.
Bug: 25290258
Bug: 25766824
Change-Id: I8af60eee1e5112f3df22a96c74a9d6607ccd5adb
-rw-r--r-- | 6515/libsensors_iio/MPLSensor.cpp | 26 | ||||
-rw-r--r-- | 6515/libsensors_iio/MPLSensor.h | 1 |
2 files changed, 21 insertions, 6 deletions
diff --git a/6515/libsensors_iio/MPLSensor.cpp b/6515/libsensors_iio/MPLSensor.cpp index aef93e1..cfdded8 100644 --- a/6515/libsensors_iio/MPLSensor.cpp +++ b/6515/libsensors_iio/MPLSensor.cpp @@ -178,6 +178,7 @@ MPLSensor::MPLSensor(CompassSensor *compass, int (*m_pt2AccelCalLoadFunc)(long * memset(mInitial6QuatValue, 0, sizeof(mInitial6QuatValue)); mFlushSensorEnabledVector.setCapacity(NumSensors); memset(mEnabledTime, 0, sizeof(mEnabledTime)); + memset(mLastTimestamp, 0, sizeof(mLastTimestamp)); /* setup sysfs paths */ inv_init_sysfs_attributes(); @@ -3896,9 +3897,15 @@ int MPLSensor::readEvents(sensors_event_t* data, int count) update = readDmpPedometerEvents(data, count, ID_P, 1); mPedUpdate = 0; if(update == 1 && count > 0) { - data->timestamp = mStepSensorTimestamp; - count--; - numEventReceived++; + if (mLastTimestamp[i] != mStepSensorTimestamp) { + count--; + numEventReceived++; + data->timestamp = mStepSensorTimestamp; + mLastTimestamp[i] = mStepSensorTimestamp; + } else { + ALOGE("Event from type=%d with duplicate timestamp %lld discarded", + mPendingEvents[i].type, mStepSensorTimestamp); + } continue; } } else { @@ -3914,9 +3921,16 @@ int MPLSensor::readEvents(sensors_event_t* data, int count) mPendingMask |= (1 << i); if (update && (count > 0)) { - *data++ = mPendingEvents[i]; - count--; - numEventReceived++; + // Discard any events with duplicate timestamps + if (mLastTimestamp[i] != mPendingEvents[i].timestamp) { + mLastTimestamp[i] = mPendingEvents[i].timestamp; + *data++ = mPendingEvents[i]; + count--; + numEventReceived++; + } else { + ALOGE("Event from type=%d with duplicate timestamp %lld discarded", + mPendingEvents[i].type, mStepSensorTimestamp); + } } } } diff --git a/6515/libsensors_iio/MPLSensor.h b/6515/libsensors_iio/MPLSensor.h index 63df411..306a07f 100644 --- a/6515/libsensors_iio/MPLSensor.h +++ b/6515/libsensors_iio/MPLSensor.h @@ -370,6 +370,7 @@ protected: int64_t mBatchTimeouts[NumSensors]; hfunc_t mHandlers[NumSensors]; int64_t mEnabledTime[NumSensors]; + int64_t mLastTimestamp[NumSensors]; short mCachedGyroData[3]; long mCachedAccelData[3]; long mCachedCompassData[3]; |