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

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

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.