From 4b84704b97300eff3ebfab85652e64d54149d205 Mon Sep 17 00:00:00 2001 From: Aravind Akella Date: Mon, 3 Mar 2014 19:02:46 -0800 Subject: Ignore flush complete events when recording last value for a sensor. Bug: 11822806 Change-Id: I1402d6684ed71ed413aef6a7be3aad945b331ec2 --- services/sensorservice/SensorService.cpp | 23 ++++++++++++----------- services/sensorservice/SensorService.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index a2f433279..f6705f6be 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -426,20 +426,21 @@ bool SensorService::threadLoop() } void SensorService::recordLastValue( - sensors_event_t const * buffer, size_t count) -{ + const sensors_event_t* buffer, size_t count) { Mutex::Autolock _l(mLock); - // record the last event for each sensor - int32_t prev = buffer[0].sensor; - for (size_t i=1 ; itype != SENSOR_TYPE_META_DATA) { + if (last && event->sensor != last->sensor) { + mLastEventSeen.editValueFor(last->sensor) = *last; + } + last = event; } } - mLastEventSeen.editValueFor(prev) = buffer[count-1]; + if (last) { + mLastEventSeen.editValueFor(last->sensor) = *last; + } } void SensorService::sortEventBuffer(sensors_event_t* buffer, size_t count) diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index c9683197f..1dc2dd36a 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -131,7 +131,7 @@ class SensorService : String8 getSensorName(int handle) const; bool isVirtualSensor(int handle) const; - void recordLastValue(sensors_event_t const * buffer, size_t count); + void recordLastValue(const sensors_event_t* buffer, size_t count); static void sortEventBuffer(sensors_event_t* buffer, size_t count); Sensor registerSensor(SensorInterface* sensor); Sensor registerVirtualSensor(SensorInterface* sensor); -- cgit v1.2.3