aidl: vibrator: Add click and tick duration config properties

Change-Id: Ia1015931d19add236bc44fbec06e7ee51993c7b6
urubino
Tim Zimmermann 2 years ago
parent c48c38dde5
commit 0efab51459
  1. 8
      aidl/vibrator/Vibrator.cpp
  2. 5
      aidl/vibrator/Vibrator.h

@ -7,6 +7,7 @@
#include "Vibrator.h"
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <cmath>
#include <fstream>
@ -58,6 +59,9 @@ Vibrator::Vibrator() {
mIsTimedOutVibrator = nodeExists(VIBRATOR_TIMEOUT_PATH);
mHasTimedOutIntensity = nodeExists(VIBRATOR_INTENSITY_PATH);
mHasTimedOutEffect = nodeExists(VIBRATOR_CP_TRIGGER_PATH);
mClickDuration = ::android::base::GetIntProperty("ro.vendor.vibrator_hal.click_duration", mClickDuration);
mTickDuration = ::android::base::GetIntProperty("ro.vendor.vibrator_hal.tick_duration", mTickDuration);
}
ndk::ScopedAStatus Vibrator::getCapabilities(int32_t* _aidl_return) {
@ -277,9 +281,9 @@ uint32_t Vibrator::effectToMs(Effect effect, ndk::ScopedAStatus* status) {
*status = ndk::ScopedAStatus::ok();
switch (effect) {
case Effect::CLICK:
return 10;
return mClickDuration;
case Effect::TICK:
return 5;
return mTickDuration;
default:
break;
}

@ -63,7 +63,7 @@ public:
private:
ndk::ScopedAStatus activate(uint32_t ms);
static uint32_t effectToMs(Effect effect, ndk::ScopedAStatus* status);
uint32_t effectToMs(Effect effect, ndk::ScopedAStatus* status);
static float strengthToAmplitude(EffectStrength strength, ndk::ScopedAStatus* status);
bool mEnabled{false};
@ -73,6 +73,9 @@ private:
bool mIsTimedOutVibrator;
bool mHasTimedOutIntensity;
bool mHasTimedOutEffect;
int mClickDuration = 10;
int mTickDuration = 5;
};
} // namespace vibrator

Loading…
Cancel
Save