aidl: vibrator: Only handle actually supported effects

* Let framework handle the other ones
* On devices without hardware effects DOUBLE_CLICK effect is just
  a single click without this
* Let's only keep CLICK and TICK if no hardware effects are supported,
  just like AOSP default vibrator impl

Change-Id: Ib8bf299a417d82fe6196e1b071b5a7b2f9c3e5d8
urubino
Tim Zimmermann 2 years ago
parent 3ed0ddd0fd
commit c48c38dde5
  1. 40
      aidl/vibrator/Vibrator.cpp

@ -138,14 +138,13 @@ ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength, con
} }
ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) { ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect>* _aidl_return) {
*_aidl_return = {Effect::CLICK, Effect::DOUBLE_CLICK, Effect::HEAVY_CLICK, *_aidl_return = { Effect::CLICK, Effect::TICK };
Effect::TICK, Effect::TEXTURE_TICK, Effect::THUD, Effect::POP,
Effect::RINGTONE_1, Effect::RINGTONE_2, Effect::RINGTONE_3, if (mHasTimedOutEffect) {
Effect::RINGTONE_4, Effect::RINGTONE_5, Effect::RINGTONE_6, for (const auto& effect : CP_TRIGGER_EFFECTS) {
Effect::RINGTONE_7, Effect::RINGTONE_7, Effect::RINGTONE_8, _aidl_return->push_back(effect.first);
Effect::RINGTONE_9, Effect::RINGTONE_10, Effect::RINGTONE_11, }
Effect::RINGTONE_12, Effect::RINGTONE_13, Effect::RINGTONE_14, }
Effect::RINGTONE_15};
return ndk::ScopedAStatus::ok(); return ndk::ScopedAStatus::ok();
} }
@ -279,31 +278,10 @@ uint32_t Vibrator::effectToMs(Effect effect, ndk::ScopedAStatus* status) {
switch (effect) { switch (effect) {
case Effect::CLICK: case Effect::CLICK:
return 10; return 10;
case Effect::DOUBLE_CLICK:
return 15;
case Effect::TICK: case Effect::TICK:
case Effect::TEXTURE_TICK:
case Effect::THUD:
case Effect::POP:
return 5; return 5;
case Effect::HEAVY_CLICK: default:
return 10; break;
case Effect::RINGTONE_1:
case Effect::RINGTONE_2:
case Effect::RINGTONE_3:
case Effect::RINGTONE_4:
case Effect::RINGTONE_5:
case Effect::RINGTONE_6:
case Effect::RINGTONE_7:
case Effect::RINGTONE_8:
case Effect::RINGTONE_9:
case Effect::RINGTONE_10:
case Effect::RINGTONE_11:
case Effect::RINGTONE_12:
case Effect::RINGTONE_13:
case Effect::RINGTONE_14:
case Effect::RINGTONE_15:
return 30000;
} }
*status = ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); *status = ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
return 0; return 0;

Loading…
Cancel
Save