Avoid sub_overflow_minimal in AIDL effects VTS

Bug: 299385610
Test: atest VtsHalHapticGeneratorTargetTest
Change-Id: I1721fb87dd373a40453505733c8aaee647b4cf3b
This commit is contained in:
Shunkai Yao 2023-09-07 17:42:39 +00:00
parent 8f28f8b8ea
commit 5ed80c5144
2 changed files with 4 additions and 4 deletions

View file

@ -250,11 +250,11 @@ class EffectHelper {
maxLimit = std::numeric_limits<S>::max(); maxLimit = std::numeric_limits<S>::max();
if (s.size()) { if (s.size()) {
const auto min = *s.begin(), max = *s.rbegin(); const auto min = *s.begin(), max = *s.rbegin();
s.insert(min + (max - min) / 2); s.insert((min & max) + ((min ^ max) >> 1));
if (min != minLimit) { if (min > minLimit + 1) {
s.insert(min - 1); s.insert(min - 1);
} }
if (max != maxLimit) { if (max < maxLimit - 1) {
s.insert(max + 1); s.insert(max + 1);
} }
} }

View file

@ -208,7 +208,7 @@ INSTANTIATE_TEST_SUITE_P(
HapticGeneratorInvalidTest, HapticGeneratorParamTest, HapticGeneratorInvalidTest, HapticGeneratorParamTest,
::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors( ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
IFactory::descriptor, getEffectTypeUuidHapticGenerator())), IFactory::descriptor, getEffectTypeUuidHapticGenerator())),
testing::Values(MIN_ID - 1), testing::Values(MIN_ID),
testing::Values(HapticGenerator::VibratorScale::NONE), testing::Values(HapticGenerator::VibratorScale::NONE),
testing::Values(MIN_FLOAT), testing::Values(MIN_FLOAT), testing::Values(MIN_FLOAT), testing::Values(MIN_FLOAT),
testing::Values(MIN_FLOAT)), testing::Values(MIN_FLOAT)),