Merge "Deactivate sensors after flush events are received" into qt-dev am: 8913d1df2c am: 9ca9db61f8
am: 2ff09083af

Change-Id: I28bea9e6d7ab6083e6ee2f7d112b3eb2a6953027
diff --git a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
index c6d7cad..91b4fa5 100644
--- a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
+++ b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp
@@ -696,11 +696,16 @@
             Result flushResult = flush(sensor.sensorHandle);
             ASSERT_EQ(flushResult, expectedResponse);
         }
-        activate(sensor.sensorHandle, false);
     }
 
     // Wait up to one second for the flush events
     callback.waitForFlushEvents(sensors, flushCalls, 1000 /* timeoutMs */);
+
+    // Deactivate all sensors after waiting for flush events so pending flush events are not
+    // abandoned by the HAL.
+    for (const SensorInfo& sensor : sensors) {
+        activate(sensor.sensorHandle, false);
+    }
     getEnvironment()->unregisterCallback();
 
     // Check that the correct number of flushes are present for each sensor