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

Commit 57d94d9f authored by Michael Wright's avatar Michael Wright
Browse files

Add support for vibrator 1.1 HAL and TICK effect.

New HAL support is a bit hacky but gets us unblocked.

Bug: 38417655
Bug: 38417570
Test: Manual (hacked up 1.1 HAL implementation that just logs)
Change-Id: I207cce97c81734bac1ca00a5de18e160d13e2bbe
parent 426a6148
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -598,6 +598,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
    android.hardware.usb-V1.0-java-constants             \
    android.hardware.usb-V1.1-java-constants             \
    android.hardware.vibrator-V1.0-java-constants        \
    android.hardware.vibrator-V1.1-java-constants        \

# Loaded with System.loadLibrary by android.view.textclassifier
LOCAL_REQUIRED_MODULES += libtextclassifier
+18 −6
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.os;

import android.hardware.vibrator.V1_0.Constants.Effect;
import android.hardware.vibrator.V1_1.Constants.Effect_1_1;

import java.util.Arrays;

@@ -41,7 +41,7 @@ public abstract class VibrationEffect implements Parcelable {
     * @see #get(int)
     * @hide
     */
    public static final int EFFECT_CLICK = Effect.CLICK;
    public static final int EFFECT_CLICK = Effect_1_1.CLICK;

    /**
     * A double click effect.
@@ -49,7 +49,14 @@ public abstract class VibrationEffect implements Parcelable {
     * @see #get(int)
     * @hide
     */
    public static final int EFFECT_DOUBLE_CLICK = Effect.DOUBLE_CLICK;
    public static final int EFFECT_DOUBLE_CLICK = Effect_1_1.DOUBLE_CLICK;

    /**
     * A tick effect.
     * @see #get(int)
     * @hide
     */
    public static final int EFFECT_TICK = Effect_1_1.TICK;

    /** @hide to prevent subclassing from outside of the framework */
    public VibrationEffect() { }
@@ -382,7 +389,12 @@ public abstract class VibrationEffect implements Parcelable {

        @Override
        public void validate() {
            if (mEffectId != EFFECT_CLICK) {
            switch (mEffectId) {
                case EFFECT_CLICK:
                case EFFECT_DOUBLE_CLICK:
                case EFFECT_TICK:
                    break;
                default:
                    throw new IllegalArgumentException(
                            "Unknown prebaked effect type (value=" + mEffectId + ")");
            }
+0 −8
Original line number Diff line number Diff line
@@ -965,14 +965,6 @@
        <item>10</item>
    </integer-array>

    <!-- Vibrator pattern for feedback about a context click -->
    <integer-array name="config_contextClickVibePattern">
        <item>0</item>
        <item>1</item>
        <item>20</item>
        <item>21</item>
    </integer-array>

    <bool name="config_use_strict_phone_number_comparation">false</bool>

    <!-- Display low battery warning when battery level dips to this value.
+0 −1
Original line number Diff line number Diff line
@@ -1558,7 +1558,6 @@
  <java-symbol type="array" name="config_longPressVibePattern" />
  <java-symbol type="array" name="config_safeModeDisabledVibePattern" />
  <java-symbol type="array" name="config_safeModeEnabledVibePattern" />
  <java-symbol type="array" name="config_contextClickVibePattern" />
  <java-symbol type="array" name="config_virtualKeyVibePattern" />
  <java-symbol type="attr" name="actionModePopupWindowStyle" />
  <java-symbol type="attr" name="dialogCustomTitleDecorLayout" />
+15 −10
Original line number Diff line number Diff line
@@ -221,19 +221,24 @@ public class VibratorService extends IVibratorService.Stub

        long[] clickEffectTimings = getLongIntArray(context.getResources(),
                com.android.internal.R.array.config_virtualKeyVibePattern);
        VibrationEffect clickEffect;
        if (clickEffectTimings.length == 0) {
            clickEffect = null;
        } else if (clickEffectTimings.length == 1) {
            clickEffect = VibrationEffect.createOneShot(
                    clickEffectTimings[0], VibrationEffect.DEFAULT_AMPLITUDE);
        } else {
            clickEffect = VibrationEffect.createWaveform(clickEffectTimings, -1);
        }
        VibrationEffect clickEffect = createEffect(clickEffectTimings);
        VibrationEffect doubleClickEffect = VibrationEffect.createWaveform(
                new long[] {0, 30, 100, 30} /*timings*/, -1);
        long[] tickEffectTimings = getLongIntArray(context.getResources(),
                com.android.internal.R.array.config_clockTickVibePattern);
        VibrationEffect tickEffect = createEffect(tickEffectTimings);

        mFallbackEffects = new VibrationEffect[] { clickEffect, doubleClickEffect, tickEffect };
    }

        mFallbackEffects = new VibrationEffect[] { clickEffect, doubleClickEffect };
    private static VibrationEffect createEffect(long[] timings) {
        if (timings == null || timings.length == 0) {
            return null;
        } else if (timings.length == 1) {
            return VibrationEffect.createOneShot(timings[0], VibrationEffect.DEFAULT_AMPLITUDE);
        } else {
            return VibrationEffect.createWaveform(timings, -1);
        }
    }

    public void systemReady() {
Loading