From 5ed80c5144d6b0e9064e7c5a34343de29d6f431e Mon Sep 17 00:00:00 2001 From: Shunkai Yao Date: Thu, 7 Sep 2023 17:42:39 +0000 Subject: [PATCH] Avoid sub_overflow_minimal in AIDL effects VTS Bug: 299385610 Test: atest VtsHalHapticGeneratorTargetTest Change-Id: I1721fb87dd373a40453505733c8aaee647b4cf3b --- audio/aidl/vts/EffectHelper.h | 6 +++--- audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/audio/aidl/vts/EffectHelper.h b/audio/aidl/vts/EffectHelper.h index 685d07d191..2c8edf28fb 100644 --- a/audio/aidl/vts/EffectHelper.h +++ b/audio/aidl/vts/EffectHelper.h @@ -250,11 +250,11 @@ class EffectHelper { maxLimit = std::numeric_limits::max(); if (s.size()) { const auto min = *s.begin(), max = *s.rbegin(); - s.insert(min + (max - min) / 2); - if (min != minLimit) { + s.insert((min & max) + ((min ^ max) >> 1)); + if (min > minLimit + 1) { s.insert(min - 1); } - if (max != maxLimit) { + if (max < maxLimit - 1) { s.insert(max + 1); } } diff --git a/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp b/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp index 54caed920e..b33234b04b 100644 --- a/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp +++ b/audio/aidl/vts/VtsHalHapticGeneratorTargetTest.cpp @@ -208,7 +208,7 @@ INSTANTIATE_TEST_SUITE_P( HapticGeneratorInvalidTest, HapticGeneratorParamTest, ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors( IFactory::descriptor, getEffectTypeUuidHapticGenerator())), - testing::Values(MIN_ID - 1), + testing::Values(MIN_ID), testing::Values(HapticGenerator::VibratorScale::NONE), testing::Values(MIN_FLOAT), testing::Values(MIN_FLOAT), testing::Values(MIN_FLOAT)),