summaryrefslogtreecommitdiffstats
path: root/services/sensorservice
diff options
context:
space:
mode:
authorAravind Akella <aakella@google.com>2014-03-06 02:24:29 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-06 02:24:29 +0000
commit8ae7c02e6ffb5533958d04ac0d8f4a8d77fdb734 (patch)
tree594ae1817886ab781acabb91bae7f945f5bd21c1 /services/sensorservice
parent1298c7e527fd242a39f9c0d53aa4f35d1c9decab (diff)
parentffac23b210a96e769fd79ae912b44a185e7d69bd (diff)
downloadframeworks_native-8ae7c02e6ffb5533958d04ac0d8f4a8d77fdb734.zip
frameworks_native-8ae7c02e6ffb5533958d04ac0d8f4a8d77fdb734.tar.gz
frameworks_native-8ae7c02e6ffb5533958d04ac0d8f4a8d77fdb734.tar.bz2
am ffac23b2: am 4b84704b: Ignore flush complete events when recording last value for a sensor.
* commit 'ffac23b210a96e769fd79ae912b44a185e7d69bd': Ignore flush complete events when recording last value for a sensor.
Diffstat (limited to 'services/sensorservice')
-rw-r--r--services/sensorservice/SensorService.cpp23
-rw-r--r--services/sensorservice/SensorService.h2
2 files changed, 13 insertions, 12 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index a2f4332..f6705f6 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 ; i<count ; i++) {
- // record the last event of each sensor type in this buffer
- int32_t curr = buffer[i].sensor;
- if (curr != prev) {
- mLastEventSeen.editValueFor(prev) = buffer[i-1];
- prev = curr;
+ const sensors_event_t* last = NULL;
+ for (size_t i = 0; i < count; i++) {
+ const sensors_event_t* event = &buffer[i];
+ if (event->type != 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 c968319..1dc2dd3 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);