Merge "Fix default vibrator HAL to check support on getPrimitiveDuration"

This commit is contained in:
Treehugger Robot
2021-06-28 21:02:48 +00:00
committed by Gerrit Code Review

View File

@@ -125,6 +125,11 @@ ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimiti
ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive primitive,
int32_t* durationMs) {
std::vector<CompositePrimitive> supported;
getSupportedPrimitives(&supported);
if (std::find(supported.begin(), supported.end(), primitive) == supported.end()) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
if (primitive != CompositePrimitive::NOOP) {
*durationMs = 100;
} else {