From 694e6e829aed152a08f9c14559bb2099690a681e Mon Sep 17 00:00:00 2001 From: Vishal Agarwal Date: Fri, 2 Aug 2019 13:27:31 -0700 Subject: [PATCH] VTS Sensor HAL 2.0: Fix Batch for One Shot sensors One Shot sensors have minDelay set to -1. Force the minDelay to be 0 in the VTS test to avoid errors from invalid parameter Bug: 138758242 Test: Run Batch test manually VtsHalSensorsV2_0TargetTest --gtest_filter=SensorsHidlTest.Batch Change-Id: Ib2287f6f11502c10d346f5e7216c5f31d585edf9 Merged-In: Ib2287f6f11502c10d346f5e7216c5f31d585edf9 (cherry picked from commit 66d8297210a6deb2e0a8608470780d52c5e09620) --- sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp index 62c5334441..9d2596ce8c 100644 --- a/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp +++ b/sensors/2.0/vts/functional/VtsHalSensorsV2_0TargetTest.cpp @@ -761,7 +761,12 @@ TEST_F(SensorsHidlTest, Batch) { activateAllSensors(false /* enable */); for (const SensorInfo& sensor : getSensorsList()) { // Call batch on inactive sensor - ASSERT_EQ(batch(sensor.sensorHandle, sensor.minDelay, 0 /* maxReportLatencyNs */), + // One shot sensors have minDelay set to -1 which is an invalid + // parameter. Use 0 instead to avoid errors. + int64_t samplingPeriodNs = extractReportMode(sensor.flags) == SensorFlagBits::ONE_SHOT_MODE + ? 0 + : sensor.minDelay; + ASSERT_EQ(batch(sensor.sensorHandle, samplingPeriodNs, 0 /* maxReportLatencyNs */), Result::OK); // Activate the sensor