Merge "vibrator: Deduplicate Supported Primitives Check" am: a399d331fb am: 56438136f7

Change-Id: I23854bf3705189d3c0eb48fd8b722dc55d6327ed
This commit is contained in:
Automerger Merge Worker
2020-01-31 16:15:49 +00:00

View File

@@ -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);
}
}