From 9920e212f8252f2d49e60a4c8199e5826ff18ef6 Mon Sep 17 00:00:00 2001 From: Brian Stack Date: Tue, 30 Oct 2018 11:54:25 -0700 Subject: [PATCH] Only save newly received events during testing All events in the temporary event buffer were being saved during testing. This caused some events to be saved multiple times. This patch ensures that only new events are saved. Bug: 115969174 Test: Verified duplicate events are not received Change-Id: Ia2c7df7273456700e0da2ddd927f7daf42e69334 --- sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp b/sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp index 54442876f4..2fb67a69cf 100644 --- a/sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp +++ b/sensors/2.0/vts/functional/SensorsHidlEnvironmentV2_0.cpp @@ -123,8 +123,8 @@ void SensorsHidlEnvironmentV2_0::readEvents() { size_t eventsToRead = std::min(availableEvents, mEventBuffer.size()); if (eventsToRead > 0) { if (mEventQueue->read(mEventBuffer.data(), eventsToRead)) { - for (const auto& e : mEventBuffer) { - addEvent(e); + for (size_t i = 0; i < eventsToRead; i++) { + addEvent(mEventBuffer[i]); } } }