From cf16a0db57b2f2111eadd304bdab6814f3578c39 Mon Sep 17 00:00:00 2001 From: iusmac Date: Sun, 17 May 2026 11:06:03 +0200 Subject: [PATCH] haptics: Allow to set predefined feedback for texture tick effect Currently, the texture soft ticks will play only if there's a hardware-specific implementation. So, there may be no haptic feedback at all in actions called repeatedly (e.g., when dragging a slider thumb or when performing a back gesture). This is the case for most older devices, see [1]. This CL allows to configure the wave timings via overlay to replicate the texture tick effect implementation. The start & end time values may need to be tuned, so it's not too disruptive to the user. NOTE: when set, this will ignore the hardware-specific implementation, if any (assuming none). [1]: https://github.com/crdroidandroid/issue_tracker/issues/14 Signed-off-by: iusmac --- core/res/res/values/cr_config.xml | 13 +++++++++++++ core/res/res/values/cr_symbols.xml | 3 +++ .../android/server/vibrator/VibrationSettings.java | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/res/res/values/cr_config.xml b/core/res/res/values/cr_config.xml index 19ee1f72a3143..baa4db267c516 100644 --- a/core/res/res/values/cr_config.xml +++ b/core/res/res/values/cr_config.xml @@ -95,4 +95,17 @@ false + + + + + diff --git a/core/res/res/values/cr_symbols.xml b/core/res/res/values/cr_symbols.xml index 9f025f9adc98f..1119ae01b46aa 100644 --- a/core/res/res/values/cr_symbols.xml +++ b/core/res/res/values/cr_symbols.xml @@ -76,4 +76,7 @@ + + + diff --git a/services/core/java/com/android/server/vibrator/VibrationSettings.java b/services/core/java/com/android/server/vibrator/VibrationSettings.java index 46f42feb329af..b7738a3d3f410 100644 --- a/services/core/java/com/android/server/vibrator/VibrationSettings.java +++ b/services/core/java/com/android/server/vibrator/VibrationSettings.java @@ -791,14 +791,16 @@ private static SparseArray createEffectsFromResource(Resources com.android.internal.R.array.config_longPressVibePattern); VibrationEffect tickEffect = createEffectFromResource(resources, com.android.internal.R.array.config_clockTickVibePattern); + VibrationEffect textureTickEffect = createEffectFromResource(resources, + com.android.internal.R.array.config_textureTickVibePattern); SparseArray effects = new SparseArray<>(); effects.put(VibrationEffect.EFFECT_CLICK, clickEffect); effects.put(VibrationEffect.EFFECT_DOUBLE_CLICK, doubleClickEffect); effects.put(VibrationEffect.EFFECT_TICK, tickEffect); effects.put(VibrationEffect.EFFECT_HEAVY_CLICK, heavyClickEffect); - effects.put(VibrationEffect.EFFECT_TEXTURE_TICK, - VibrationEffect.get(VibrationEffect.EFFECT_TICK, false)); + effects.put(VibrationEffect.EFFECT_TEXTURE_TICK, textureTickEffect != null + ? textureTickEffect : VibrationEffect.get(VibrationEffect.EFFECT_TICK, false)); return effects; }