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

Commit 0bac78b2 authored by Ahmad Khalil's avatar Ahmad Khalil
Browse files

Add new vibrator frequency profile for PWLE v2

This new vibrator frequency profile provides developers with richer information about the vibrators capabilities, including:
1. The minimum and maximum frequencies supported by the vibrator.
2. The maximum output acceleration the vibrator can achieve.
3. Retrieve frequency range for a specified minimum output acceleration

This profile will only be available if the device supports frequency control.

Bug: 347034419
Flag: android.os.vibrator.normalized_pwle_effects
Test: atest FrameworksVibratorCoreTests
Change-Id: I9a16b9b4932d95e8eb8c89bfa43f94920ed9e1ee
parent b0d339f5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -34334,6 +34334,7 @@ package android.os {
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public boolean areEnvelopeEffectsSupported();
    method @NonNull public boolean[] arePrimitivesSupported(@NonNull int...);
    method @RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") @Nullable public android.os.vibrator.VibratorFrequencyProfile getFrequencyProfile();
    method public int getId();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public int getMaxEnvelopeEffectControlPointDurationMillis();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public int getMaxEnvelopeEffectDurationMillis();
@@ -34687,6 +34688,19 @@ package android.os.strictmode {
}
package android.os.vibrator {
  @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public final class VibratorFrequencyProfile {
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") @NonNull public android.util.SparseArray<java.lang.Float> getFrequenciesOutputAcceleration();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") @Nullable public android.util.Range<java.lang.Float> getFrequencyRange(float);
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public float getMaxFrequencyHz();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public float getMaxOutputAccelerationGs();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public float getMinFrequencyHz();
    method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public float getOutputAccelerationGs(float);
  }
}
package android.preference {
  @Deprecated public class CheckBoxPreference extends android.preference.TwoStatePreference {
+23 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.hardware.vibrator.IVibrator;
import android.media.AudioAttributes;
import android.os.vibrator.Flags;
import android.os.vibrator.VibrationConfig;
import android.os.vibrator.VibratorFrequencyProfile;
import android.os.vibrator.VibratorFrequencyProfileLegacy;
import android.util.Log;
import android.view.HapticFeedbackConstants;
@@ -302,6 +303,28 @@ public abstract class Vibrator {
        return new VibratorFrequencyProfileLegacy(frequencyProfile);
    }

    /**
     * Gets the profile that describes the vibrator output across the supported frequency range.
     *
     * <p>The profile describes the output acceleration that the device can reach when it
     * vibrates at different frequencies.
     *
     * @return The frequency profile for this vibrator, or null if the vibrator does not have
     * frequency control. If this vibrator is a composite of multiple physical devices then this
     * will return a profile supported in all devices, or null if the intersection is empty or not
     * available.
     */
    @FlaggedApi(Flags.FLAG_NORMALIZED_PWLE_EFFECTS)
    @Nullable
    public VibratorFrequencyProfile getFrequencyProfile() {
        VibratorInfo.FrequencyProfile frequencyProfile = getInfo().getFrequencyProfile();
        if (frequencyProfile.isEmpty()) {
            return null;
        }

        return new VibratorFrequencyProfile(frequencyProfile);
    }

    /**
     * Return the maximum amplitude the vibrator can play using the audio haptic channels.
     *
+354 −4

File changed.

Preview size limit exceeded, changes collapsed.

+88 −4

File changed.

Preview size limit exceeded, changes collapsed.

+150 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading