From a266b2c8f270ca04179019bb37d2da35dfffeb46 Mon Sep 17 00:00:00 2001 From: chasewu Date: Thu, 31 Mar 2022 23:23:27 +0800 Subject: [PATCH] Correct the PWLE valid duration Getting the maximum duration from HAL to avoid different supported duration under different devices. Fix: 227606057 Test: atest VtsHalVibratorTargetTest Signed-off-by: chasewu Change-Id: I02e96869d9a8e6d5143ae64e3a077bf90dcdb43e --- vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp index abb80a28f6..38417154eb 100644 --- a/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp +++ b/vibrator/aidl/vts/VtsHalVibratorTargetTest.cpp @@ -196,7 +196,7 @@ static ActivePwle composeValidActivePwle(sp vibrator, int32_t capabil active.startFrequency = frequencyHz; active.endAmplitude = (getAmplitudeMin() + getAmplitudeMax()) / 2; active.endFrequency = frequencyHz; - active.duration = 1000; + vibrator->getPwlePrimitiveDurationMax(&(active.duration)); return active; } @@ -759,7 +759,9 @@ TEST_P(VibratorAidl, ComposeValidPwleWithCallback) { std::future completionFuture{completionPromise.get_future()}; sp callback = new CompletionCallback([&completionPromise] { completionPromise.set_value(); }); - uint32_t durationMs = 2100; // Sum of 2 active and 1 braking below + int32_t segmentDurationMaxMs; + vibrator->getPwlePrimitiveDurationMax(&segmentDurationMaxMs); + uint32_t durationMs = segmentDurationMaxMs * 2 + 100; // Sum of 2 active and 1 braking below //TODO(b/187207798): revert back to conservative timeout values once //latencies have been fixed std::chrono::milliseconds timeout{durationMs * 4}; @@ -863,7 +865,7 @@ TEST_P(VibratorAidl, ComposePwleSegmentDurationBoundary) { if (capabilities & IVibrator::CAP_COMPOSE_PWLE_EFFECTS) { ActivePwle active = composeValidActivePwle(vibrator, capabilities); - int segmentDurationMaxMs; + int32_t segmentDurationMaxMs; vibrator->getPwlePrimitiveDurationMax(&segmentDurationMaxMs); active.duration = segmentDurationMaxMs + 10; // Segment duration greater than allowed