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
urubino
Tim Zimmermann 2 years ago
parent 79fae21736
commit 36977e2992
No known key found for this signature in database
GPG Key ID: 6DC21A63F819C5EF
  1. 5
      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) {

Loading…
Cancel
Save