mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
vibrator: Deduplicate Supported Primitives Check
Use the getSupportedPrimitives() as the single source of truth for supported primitive checks. Bug: 147844633 Test: atest VtsHalVibratorTargetTest Change-Id: I8789b0ee9806c5887fca9a0b800fe2e903c76a58 Signed-off-by: Harpreet \"Eli\" Sangha <eliptus@google.com>
This commit is contained in:
committed by
Harpreet "Eli" Sangha
parent
fe5d3986e9
commit
13ef28c6a4
@@ -139,6 +139,9 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& composi
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
|
||||
std::vector<CompositePrimitive> supported;
|
||||
getSupportedPrimitives(&supported);
|
||||
|
||||
for (auto& e : composite) {
|
||||
if (e.delayMs > kComposeDelayMaxMs) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
@@ -146,8 +149,7 @@ ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect>& composi
|
||||
if (e.scale <= 0.0f || e.scale > 1.0f) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
if (e.primitive < CompositePrimitive::NOOP ||
|
||||
e.primitive > CompositePrimitive::LIGHT_TICK) {
|
||||
if (std::find(supported.begin(), supported.end(), e.primitive) == supported.end()) {
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user