Ignore flush complete events when recording last value for a sensor.
Bug: 11822806 Change-Id: I1402d6684ed71ed413aef6a7be3aad945b331ec2
This commit is contained in:
parent
6790329358
commit
4b84704b97
@ -426,20 +426,21 @@ bool SensorService::threadLoop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SensorService::recordLastValue(
|
void SensorService::recordLastValue(
|
||||||
sensors_event_t const * buffer, size_t count)
|
const sensors_event_t* buffer, size_t count) {
|
||||||
{
|
|
||||||
Mutex::Autolock _l(mLock);
|
Mutex::Autolock _l(mLock);
|
||||||
// record the last event for each sensor
|
const sensors_event_t* last = NULL;
|
||||||
int32_t prev = buffer[0].sensor;
|
for (size_t i = 0; i < count; i++) {
|
||||||
for (size_t i=1 ; i<count ; i++) {
|
const sensors_event_t* event = &buffer[i];
|
||||||
// record the last event of each sensor type in this buffer
|
if (event->type != SENSOR_TYPE_META_DATA) {
|
||||||
int32_t curr = buffer[i].sensor;
|
if (last && event->sensor != last->sensor) {
|
||||||
if (curr != prev) {
|
mLastEventSeen.editValueFor(last->sensor) = *last;
|
||||||
mLastEventSeen.editValueFor(prev) = buffer[i-1];
|
}
|
||||||
prev = curr;
|
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)
|
void SensorService::sortEventBuffer(sensors_event_t* buffer, size_t count)
|
||||||
|
@ -131,7 +131,7 @@ class SensorService :
|
|||||||
|
|
||||||
String8 getSensorName(int handle) const;
|
String8 getSensorName(int handle) const;
|
||||||
bool isVirtualSensor(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);
|
static void sortEventBuffer(sensors_event_t* buffer, size_t count);
|
||||||
Sensor registerSensor(SensorInterface* sensor);
|
Sensor registerSensor(SensorInterface* sensor);
|
||||||
Sensor registerVirtualSensor(SensorInterface* sensor);
|
Sensor registerVirtualSensor(SensorInterface* sensor);
|
||||||
|
Loading…
Reference in New Issue
Block a user