From 0efab51459437965fdebc152e3393c47064b4a1e Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Sun, 12 Mar 2023 13:07:35 +0100 Subject: [PATCH] aidl: vibrator: Add click and tick duration config properties Change-Id: Ia1015931d19add236bc44fbec06e7ee51993c7b6 --- aidl/vibrator/Vibrator.cpp | 8 ++++++-- aidl/vibrator/Vibrator.h | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/aidl/vibrator/Vibrator.cpp b/aidl/vibrator/Vibrator.cpp index 11d7ff09..2498c545 100644 --- a/aidl/vibrator/Vibrator.cpp +++ b/aidl/vibrator/Vibrator.cpp @@ -7,6 +7,7 @@ #include "Vibrator.h" #include +#include #include #include @@ -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; } diff --git a/aidl/vibrator/Vibrator.h b/aidl/vibrator/Vibrator.h index 06f51665..3a26113f 100644 --- a/aidl/vibrator/Vibrator.h +++ b/aidl/vibrator/Vibrator.h @@ -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