This CL correct the behavior of sensorservice so that the latest
value of on-change sensor is send to client when enabling sensor.
The errornous behavior before is that sensorservice send the oldest
value in local cache.
Bug:
28480791
Change-Id: I7e0b8e52fa0be62ba95910789cff1fe0d4fbb03f
std::lock_guard<std::mutex> lk(mLock);
if (mRecentEvents.size()) {
- *event = mRecentEvents[mRecentEvents.size()-1].mEvent;
+ // Index 0 contains the latest event emplace()'ed
+ *event = mRecentEvents[0].mEvent;
return true;
} else {
return false;