VibratorFrequencyProfile


public final class VibratorFrequencyProfile
extends Object

java.lang.Object
   ↳ android.os.vibrator.VibratorFrequencyProfile


Describes the output of a Vibrator for different vibration frequencies.

The profile contains the vibrator's frequency range (minimum/maximum) and maximum acceleration, enabling retrieval of supported acceleration levels for specific frequencies, if the device supports independent frequency control.

It also describes the max output acceleration (Gs), of a vibration at different supported frequencies (Hz).

Vibrators without independent frequency control do not have a frequency profile.

Summary

Public methods

SparseArray<Float> getFrequenciesOutputAcceleration()

Returns a SparseArray representing the vibrator's output acceleration capabilities across different frequencies.

Range<Float> getFrequencyRange(float minOutputAccelerationGs)

Returns the frequency range (in Hz) where the vibrator can sustain at least the given minimum output acceleration (Gs).

float getMaxFrequencyHz()

Gets the maximum frequency supported by the vibrator.

float getMaxOutputAccelerationGs()

Returns the maximum output acceleration (in Gs) supported by the vibrator.

float getMinFrequencyHz()

Gets the minimum frequency supported by the vibrator.

float getOutputAccelerationGs(float frequencyHz)

Returns the output acceleration (in Gs) for the given frequency (Hz).

Inherited methods

Public methods

getFrequenciesOutputAcceleration

public SparseArray<Float> getFrequenciesOutputAcceleration ()

Returns a SparseArray representing the vibrator's output acceleration capabilities across different frequencies. This map defines the maximum acceleration the vibrator can achieve at each supported frequency.

The map's keys are frequencies in Hz, and the corresponding values are the maximum achievable output accelerations in Gs.

Returns
SparseArray<Float> A map of frequencies (Hz) to maximum accelerations (Gs). This value cannot be null.

getFrequencyRange

public Range<Float> getFrequencyRange (float minOutputAccelerationGs)

Returns the frequency range (in Hz) where the vibrator can sustain at least the given minimum output acceleration (Gs).

Parameters
minOutputAccelerationGs float: The minimum desired output acceleration in Gs.

Returns
Range<Float> A Range object representing the frequency range where the vibrator can sustain at least the given minimum acceleration, or null if the minimum output acceleration cannot be achieved.

getMaxFrequencyHz

public float getMaxFrequencyHz ()

Gets the maximum frequency supported by the vibrator.

Returns
float the maximum frequency supported by the vibrator, in hertz.

getMaxOutputAccelerationGs

public float getMaxOutputAccelerationGs ()

Returns the maximum output acceleration (in Gs) supported by the vibrator. This value represents the highest acceleration the vibrator can achieve across its entire frequency range.

Returns
float The maximum output acceleration in Gs.

getMinFrequencyHz

public float getMinFrequencyHz ()

Gets the minimum frequency supported by the vibrator.

Returns
float the minimum frequency supported by the vibrator, in hertz.

getOutputAccelerationGs

public float getOutputAccelerationGs (float frequencyHz)

Returns the output acceleration (in Gs) for the given frequency (Hz). This method provides the actual acceleration the vibrator will produce when operating at the specified frequency, using linear interpolation over the getFrequenciesOutputAcceleration().

Parameters
frequencyHz float: The frequency in Hz.

Returns
float The output acceleration in Gs for the given frequency.