Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d39cbecb authored by Michael Wright's avatar Michael Wright
Browse files

Use config_longPressVibePattern as heavy click fallback.

Rather than using the regular click effect as the fallback, use the long
press pattern since heavy click is the new effect for long press. This
also lets us distinguish the two effects in the configuration.

Bug: 77863933
Test: long-press on something, feel the effect
Change-Id: Ie22d064cbdd2d33702180cb528d743e75ff8ae63
parent 84745ebe
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -286,23 +286,28 @@ public class VibratorService extends IVibratorService.Stub
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        context.registerReceiver(mIntentReceiver, filter);

        long[] clickEffectTimings = getLongIntArray(context.getResources(),
        VibrationEffect clickEffect = createEffectFromResource(
                com.android.internal.R.array.config_virtualKeyVibePattern);
        VibrationEffect clickEffect = createEffect(clickEffectTimings);
        VibrationEffect doubleClickEffect = VibrationEffect.createWaveform(
                DOUBLE_CLICK_EFFECT_FALLBACK_TIMINGS, -1 /*repeatIndex*/);
        long[] tickEffectTimings = getLongIntArray(context.getResources(),
        VibrationEffect heavyClickEffect = createEffectFromResource(
                com.android.internal.R.array.config_longPressVibePattern);
        VibrationEffect tickEffect = createEffectFromResource(
                com.android.internal.R.array.config_clockTickVibePattern);
        VibrationEffect tickEffect = createEffect(tickEffectTimings);

        mFallbackEffects = new SparseArray<VibrationEffect>();
        mFallbackEffects.put(VibrationEffect.EFFECT_CLICK, clickEffect);
        mFallbackEffects.put(VibrationEffect.EFFECT_DOUBLE_CLICK, doubleClickEffect);
        mFallbackEffects.put(VibrationEffect.EFFECT_TICK, tickEffect);
        mFallbackEffects.put(VibrationEffect.EFFECT_HEAVY_CLICK, clickEffect);
        mFallbackEffects.put(VibrationEffect.EFFECT_HEAVY_CLICK, heavyClickEffect);
    }

    private static VibrationEffect createEffect(long[] timings) {
    private VibrationEffect createEffectFromResource(int resId) {
        long[] timings = getLongIntArray(mContext.getResources(), resId);
        return createEffectFromTimings(timings);
    }

    private static VibrationEffect createEffectFromTimings(long[] timings) {
        if (timings == null || timings.length == 0) {
            return null;
        } else if (timings.length == 1) {