From: Tim Zimmermann Date: Fri, 15 Apr 2022 08:04:25 +0000 (+0200) Subject: aidl: vibrator: Don't allow intensity 0 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=36977e29925839092c17737f7dff379b42f79a6b;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung.git aidl: vibrator: Don't allow intensity 0 * Even if amplitude is > 0 resulting intensity might be 0 sometimes * New devices just return EINVAL in kernel and ignore it, but on older ones this may result in very weak vibration Change-Id: I5d290d60d8414ca747dce4af847f190e3caedbe0 --- diff --git a/aidl/vibrator/Vibrator.cpp b/aidl/vibrator/Vibrator.cpp index 95d5aec..0f64702 100644 --- a/aidl/vibrator/Vibrator.cpp +++ b/aidl/vibrator/Vibrator.cpp @@ -162,6 +162,11 @@ ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) { if (intensity > INTENSITY_MAX) { intensity = INTENSITY_MAX; } + + if (intensity == 0) { + return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); + } + LOG(DEBUG) << "Setting intensity: " << intensity; if (mHasTimedOutIntensity) {