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

Commit bebf04aa authored by Alexey Kuzmin's avatar Alexey Kuzmin
Browse files

Add fallback for TEXTURE_TICK

TEXTURE_TICK vibration effect should fallback to TICK effect if not
supported by HAL (and, if necessary, fallback further to TICK effect
fallback)
Bug: 129275029
Test: atest VibrationEffectTest
Test: adb cmd vibrator prebaked 21 on a phone which does not support
TEXTURE_TICK - you should feel the device vibrates

Change-Id: I788b0835312e2b2ab590c26ef2f9961fe542cf77
parent 78290da5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1895,6 +1895,7 @@ package android.os {
    field public static final int EFFECT_STRENGTH_LIGHT = 0; // 0x0
    field public static final int EFFECT_STRENGTH_MEDIUM = 1; // 0x1
    field public static final int EFFECT_STRENGTH_STRONG = 2; // 0x2
    field public static final int EFFECT_TEXTURE_TICK = 21; // 0x15
    field public static final int EFFECT_THUD = 3; // 0x3
    field public static final int[] RINGTONES;
  }
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public abstract class VibrationEffect implements Parcelable {
     * @see #get(int)
     * @hide
     */
    @TestApi
    public static final int EFFECT_TEXTURE_TICK = Effect.TEXTURE_TICK;

    /** {@hide} */
+4 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ public class VibratorService extends IVibratorService.Stub
                    case VibrationEffect.EFFECT_CLICK:
                    case VibrationEffect.EFFECT_DOUBLE_CLICK:
                    case VibrationEffect.EFFECT_HEAVY_CLICK:
                    case VibrationEffect.EFFECT_TEXTURE_TICK:
                    case VibrationEffect.EFFECT_TICK:
                    case VibrationEffect.EFFECT_POP:
                    case VibrationEffect.EFFECT_THUD:
@@ -379,6 +380,9 @@ public class VibratorService extends IVibratorService.Stub
        mFallbackEffects.put(VibrationEffect.EFFECT_TICK, tickEffect);
        mFallbackEffects.put(VibrationEffect.EFFECT_HEAVY_CLICK, heavyClickEffect);

        mFallbackEffects.put(VibrationEffect.EFFECT_TEXTURE_TICK,
                VibrationEffect.get(VibrationEffect.EFFECT_TICK, false));

        mScaleLevels = new SparseArray<>();
        mScaleLevels.put(SCALE_VERY_LOW,
                new ScaleLevel(SCALE_VERY_LOW_GAMMA, SCALE_VERY_LOW_MAX_AMPLITUDE));