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

Commit 33e19b93 authored by Lais Andrade's avatar Lais Andrade
Browse files

Remove Vibrator HIDL dependencies

Android Q is now no longer supported for launching or upgrading
devices in Android V so the vibrator HIDL HAL no longer needs to be
supported by Android.

Bug: 308452413
Test: build
Flag: EXEMPT removing Android.bp dependencies
Change-Id: I2a312e7633f7c4d5fe583368739ab3c0a986fd36
parent 5bd90039
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -251,10 +251,6 @@ java_library {
        "android.hardware.usb.gadget-V1.0-java",
        "android.hardware.usb.gadget-V1.1-java",
        "android.hardware.usb.gadget-V1.2-java",
        "android.hardware.vibrator-V1.0-java",
        "android.hardware.vibrator-V1.1-java",
        "android.hardware.vibrator-V1.2-java",
        "android.hardware.vibrator-V1.3-java",
        "android.hardware.vibrator-V3-java",
        "android.se.omapi-V1-java",
        "android.system.suspend.control.internal-java",
+0 −1
Original line number Diff line number Diff line
@@ -351,7 +351,6 @@ android_non_updatable_stubs_libs = [
    "android.hardware.usb-V1.0-java-constants",
    "android.hardware.usb-V1.1-java-constants",
    "android.hardware.usb.gadget-V1.0-java",
    "android.hardware.vibrator-V1.3-java",
    "framework-protos",
]

+30 −29
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentResolver;
import android.content.Context;
import android.hardware.vibrator.IVibrator;
import android.hardware.vibrator.V1_0.EffectStrength;
import android.hardware.vibrator.V1_3.Effect;
import android.net.Uri;
import android.os.vibrator.BasicPwleSegment;
import android.os.vibrator.Flags;
@@ -60,6 +58,7 @@ import java.util.Objects;
import java.util.StringJoiner;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.IntStream;

/**
 * A VibrationEffect describes a haptic effect to be performed by a {@link Vibrator}.
@@ -91,40 +90,46 @@ public abstract class VibrationEffect implements Parcelable {
    /**
     * A click effect. Use this effect as a baseline, as it's the most common type of click effect.
     */
    public static final int EFFECT_CLICK = Effect.CLICK;
    // Internally this maps to the HAL constant Effect::CLICK
    public static final int EFFECT_CLICK = 0;

    /**
     * A double click effect.
     */
    public static final int EFFECT_DOUBLE_CLICK = Effect.DOUBLE_CLICK;
    // Internally this maps to the HAL constant Effect::DOUBLE_CLICK
    public static final int EFFECT_DOUBLE_CLICK = 1;

    /**
     * A tick effect. This effect is less strong compared to {@link #EFFECT_CLICK}.
     */
    public static final int EFFECT_TICK = Effect.TICK;
    // Internally this maps to the HAL constant Effect::TICK
    public static final int EFFECT_TICK = 2;

    /**
     * A thud effect.
     * @see #get(int)
     * @hide
     */
    // Internally this maps to the HAL constant Effect::THUD
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @TestApi
    public static final int EFFECT_THUD = Effect.THUD;
    public static final int EFFECT_THUD = 3;

    /**
     * A pop effect.
     * @see #get(int)
     * @hide
     */
    // Internally this maps to the HAL constant Effect::POP
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @TestApi
    public static final int EFFECT_POP = Effect.POP;
    public static final int EFFECT_POP = 4;

    /**
     * A heavy click effect. This effect is stronger than {@link #EFFECT_CLICK}.
     */
    public static final int EFFECT_HEAVY_CLICK = Effect.HEAVY_CLICK;
    // Internally this maps to the HAL constant Effect::HEAVY_CLICK
    public static final int EFFECT_HEAVY_CLICK = 5;

    /**
     * A texture effect meant to replicate soft ticks.
@@ -136,20 +141,24 @@ public abstract class VibrationEffect implements Parcelable {
     * @see #get(int)
     * @hide
     */
    // Internally this maps to the HAL constant Effect::TEXTURE_TICK
    @TestApi
    public static final int EFFECT_TEXTURE_TICK = Effect.TEXTURE_TICK;
    public static final int EFFECT_TEXTURE_TICK = 21;

    /** {@hide} */
    // Internally this maps to the HAL constant EffectStrength::LIGHT
    @TestApi
    public static final int EFFECT_STRENGTH_LIGHT = EffectStrength.LIGHT;
    public static final int EFFECT_STRENGTH_LIGHT = 0;

    /** {@hide} */
    // Internally this maps to the HAL constant EffectStrength::MEDIUM
    @TestApi
    public static final int EFFECT_STRENGTH_MEDIUM = EffectStrength.MEDIUM;
    public static final int EFFECT_STRENGTH_MEDIUM = 1;

    /** {@hide} */
    // Internally this maps to the HAL constant EffectStrength::STRONG
    @TestApi
    public static final int EFFECT_STRENGTH_STRONG = EffectStrength.STRONG;
    public static final int EFFECT_STRENGTH_STRONG = 2;

    /**
     * Ringtone patterns. They may correspond with the device's ringtone audio, or may just be a
@@ -158,25 +167,10 @@ public abstract class VibrationEffect implements Parcelable {
     * @see #get(Uri, Context)
     * @hide
     */
    // Internally this maps to the HAL constant Effect::RINGTONE_*
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @TestApi
    public static final int[] RINGTONES = {
        Effect.RINGTONE_1,
        Effect.RINGTONE_2,
        Effect.RINGTONE_3,
        Effect.RINGTONE_4,
        Effect.RINGTONE_5,
        Effect.RINGTONE_6,
        Effect.RINGTONE_7,
        Effect.RINGTONE_8,
        Effect.RINGTONE_9,
        Effect.RINGTONE_10,
        Effect.RINGTONE_11,
        Effect.RINGTONE_12,
        Effect.RINGTONE_13,
        Effect.RINGTONE_14,
        Effect.RINGTONE_15
    };
    public static final int[] RINGTONES = IntStream.rangeClosed(6, 20).toArray();

    /** @hide */
    @IntDef(prefix = { "EFFECT_" }, value = {
@@ -1513,32 +1507,39 @@ public abstract class VibrationEffect implements Parcelable {
         *
         * @hide
         */
        // Internally this maps to the HAL constant CompositePrimitive::NOOP
        public static final int PRIMITIVE_NOOP = 0;
        /**
         * This effect should produce a sharp, crisp click sensation.
         */
        // Internally this maps to the HAL constant CompositePrimitive::CLICK
        public static final int PRIMITIVE_CLICK = 1;
        /**
         * A haptic effect that simulates downwards movement with gravity. Often
         * followed by extra energy of hitting and reverberation to augment
         * physicality.
         */
        // Internally this maps to the HAL constant CompositePrimitive::THUD
        public static final int PRIMITIVE_THUD = 2;
        /**
         * A haptic effect that simulates spinning momentum.
         */
        // Internally this maps to the HAL constant CompositePrimitive::SPIN
        public static final int PRIMITIVE_SPIN = 3;
        /**
         * A haptic effect that simulates quick upward movement against gravity.
         */
        // Internally this maps to the HAL constant CompositePrimitive::QUICK_RISE
        public static final int PRIMITIVE_QUICK_RISE = 4;
        /**
         * A haptic effect that simulates slow upward movement against gravity.
         */
        // Internally this maps to the HAL constant CompositePrimitive::SLOW_RISE
        public static final int PRIMITIVE_SLOW_RISE = 5;
        /**
         * A haptic effect that simulates quick downwards movement with gravity.
         */
        // Internally this maps to the HAL constant CompositePrimitive::QUICK_FALL
        public static final int PRIMITIVE_QUICK_FALL = 6;
        /**
         * This very short effect should produce a light crisp sensation intended
+4 −5
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.vibrator;

import android.annotation.NonNull;
import android.hardware.vibrator.V1_0.EffectStrength;
import android.os.ExternalVibrationScale;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
@@ -236,12 +235,12 @@ final class VibrationScaler {
    /** Mapping of Vibrator.VIBRATION_INTENSITY_* values to {@link EffectStrength}. */
    private static int intensityToEffectStrength(int intensity) {
        return switch (intensity) {
            case Vibrator.VIBRATION_INTENSITY_LOW -> EffectStrength.LIGHT;
            case Vibrator.VIBRATION_INTENSITY_MEDIUM -> EffectStrength.MEDIUM;
            case Vibrator.VIBRATION_INTENSITY_HIGH -> EffectStrength.STRONG;
            case Vibrator.VIBRATION_INTENSITY_LOW -> VibrationEffect.EFFECT_STRENGTH_LIGHT;
            case Vibrator.VIBRATION_INTENSITY_MEDIUM -> VibrationEffect.EFFECT_STRENGTH_MEDIUM;
            case Vibrator.VIBRATION_INTENSITY_HIGH -> VibrationEffect.EFFECT_STRENGTH_STRONG;
            default -> {
                Slog.w(TAG, "Got unexpected vibration intensity: " + intensity);
                yield EffectStrength.STRONG;
                yield VibrationEffect.EFFECT_STRENGTH_STRONG;
            }
        };
    }