From 811d138338cdc049749487963e48abe55b0b6093 Mon Sep 17 00:00:00 2001 From: David Lin Date: Tue, 17 Apr 2018 10:29:18 -0700 Subject: [PATCH] haptics: Implement constant effect for heavy click This patch implements support for heavy click effect which has the following UX requirements: - 8 ms in square wave and full amplitude for Walleye - 12 ms in square wave and full amplitude for Taimen Bug: 77863933 Test: manual long press test Change-Id: Ibc30117fecb234a6b400123e5f18a7c100ae36cb Signed-off-by: David Lin --- sepolicy/vendor/property_contexts | 1 + vibrator/Vibrator.cpp | 16 +++++++++++++--- vibrator/Vibrator.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sepolicy/vendor/property_contexts b/sepolicy/vendor/property_contexts index 6c1459e8..451d77db 100644 --- a/sepolicy/vendor/property_contexts +++ b/sepolicy/vendor/property_contexts @@ -164,6 +164,7 @@ ro.vendor.build.svn u:object_r:vendor_default_prop:s0 ro.vendor.extension_library u:object_r:vendor_default_prop:s0 ro.vibrator.hal.click.duration u:object_r:vendor_default_prop:s0 ro.vibrator.hal.tick.duration u:object_r:vendor_default_prop:s0 +ro.vibrator.hal.heavyclick.duration u:object_r:vendor_default_prop:s0 sdm. u:object_r:vendor_default_prop:s0 sys.disable_ext_animation u:object_r:vendor_default_prop:s0 sys.display.low_persistence_mode_brightness u:object_r:vendor_default_prop:s0 diff --git a/vibrator/Vibrator.cpp b/vibrator/Vibrator.cpp index 20ae48b0..96576848 100644 --- a/vibrator/Vibrator.cpp +++ b/vibrator/Vibrator.cpp @@ -42,18 +42,22 @@ static constexpr int8_t MIN_RTP_INPUT = 0; static constexpr char RTP_MODE[] = "rtp"; static constexpr char WAVEFORM_MODE[] = "waveform"; -// Use effect #1 in the waveform library +// Use effect #1 in the waveform library for CLICK effect static constexpr char WAVEFORM_CLICK_EFFECT_SEQ[] = "1 0"; static constexpr int32_t WAVEFORM_CLICK_EFFECT_MS = 6; -// Use effect #2 in the waveform library +// Use effect #2 in the waveform library for TICK effect static constexpr char WAVEFORM_TICK_EFFECT_SEQ[] = "2 0"; static constexpr int32_t WAVEFORM_TICK_EFFECT_MS = 2; -// Use effect #3 in the waveform library +// Use effect #3 in the waveform library for DOUBLE_CLICK effect static constexpr char WAVEFORM_DOUBLE_CLICK_EFFECT_SEQ[] = "3 0"; static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 135; +// Use effect #4 in the waveform library for HEAVY_CLICK effect +static constexpr char WAVEFORM_HEAVY_CLICK_EFFECT_SEQ[] = "4 0"; +static constexpr uint32_t WAVEFORM_HEAVY_CLICK_EFFECT_MS = 8; + // Timeout threshold for selecting open or closed loop mode static constexpr int8_t LOOP_MODE_THRESHOLD_MS = 20; @@ -76,6 +80,8 @@ Vibrator::Vibrator(std::ofstream&& activate, std::ofstream&& duration, mClickDuration = property_get_int32("ro.vibrator.hal.click.duration", WAVEFORM_CLICK_EFFECT_MS); mTickDuration = property_get_int32("ro.vibrator.hal.tick.duration", WAVEFORM_TICK_EFFECT_MS); + mHeavyClickDuration = property_get_int32( + "ro.vibrator.hal.heavyclick.duration", WAVEFORM_HEAVY_CLICK_EFFECT_MS); // This enables effect #1 from the waveform library to be triggered by SLPI // while the AP is in suspend mode @@ -199,6 +205,10 @@ Return Vibrator::performEffect(Effect effect, EffectStrength strength, per mSequencer << WAVEFORM_TICK_EFFECT_SEQ << std::endl; timeMS = mTickDuration; break; + case Effect::HEAVY_CLICK: + mSequencer << WAVEFORM_HEAVY_CLICK_EFFECT_SEQ << std::endl; + timeMS = mHeavyClickDuration; + break; default: _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); return Void(); diff --git a/vibrator/Vibrator.h b/vibrator/Vibrator.h index 2f0ed082..f9daf7cd 100644 --- a/vibrator/Vibrator.h +++ b/vibrator/Vibrator.h @@ -62,6 +62,7 @@ private: std::ofstream mLpTriggerEffect; int32_t mClickDuration; int32_t mTickDuration; + int32_t mHeavyClickDuration; }; } // namespace implementation } // namespace V1_2