Package org.robolectric.shadows
Class ShadowVibrator
java.lang.Object
org.robolectric.shadows.ShadowVibrator
- Direct Known Subclasses:
ShadowSystemVibrator
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A data class for exposingVibrationEffect.Composition$PrimitiveEffect
, which is a hidden non TestApi class introduced in Android R. -
Field Summary
Modifier and TypeFieldDescriptionprotected static AudioAttributes
protected static long[]
protected static final List<ShadowVibrator.PrimitiveEffect>
protected static final SparseArray<Integer>
protected static Object
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
areAllPrimitivesSupported
(int... primitiveIds) Returns theAudioAttributes
from the last vibration.int
Returns the last vibration effect ID of aVibrationEffect#Prebaked
(e.g.long
Returns the last vibration duration in MS.long[]
Returns the last vibration pattern.protected int[]
getPrimitiveDurations
(int... primitiveIds) Returns the last list ofShadowVibrator.PrimitiveEffect
.Returns the last list ofPrimitiveSegment
vibrations inShadowVibrator.PrimitiveEffect
.int
Returns the last vibration repeat times.Returns theVibrationAttributes
from the last vibration.boolean
Returns true if the Vibrator has been cancelled.boolean
Returns true if the Vibrator is currently vibrating as controlled byVibrator.vibrate(long)
static void
reset()
void
setHasAmplitudeControl
(boolean hasAmplitudeControl) Controls the return value ofVibrator.hasAmplitudeControl()
the default is false.void
setHasVibrator
(boolean hasVibrator) Controls the return value ofVibrator.hasVibrator()
the default is true.void
setPrimitiveDurations
(int primitiveId, int durationMillis) Set a custom duration in milliseconds for the given vibration primitive.void
setSupportedPrimitives
(Collection<Integer> primitives) Adds supported vibration primitives.
-
Field Details
-
pattern
protected static long[] pattern -
vibrationEffectSegments
-
primitiveEffects
-
supportedPrimitives
-
primitiveidsToDurationMillis
-
vibrationAttributesFromLastVibration
-
audioAttributesFromLastVibration
-
-
Constructor Details
-
ShadowVibrator
public ShadowVibrator()
-
-
Method Details
-
setHasVibrator
public void setHasVibrator(boolean hasVibrator) Controls the return value ofVibrator.hasVibrator()
the default is true. -
setHasAmplitudeControl
public void setHasAmplitudeControl(boolean hasAmplitudeControl) Controls the return value ofVibrator.hasAmplitudeControl()
the default is false. -
isVibrating
Returns true if the Vibrator is currently vibrating as controlled byVibrator.vibrate(long)
-
isCancelled
public boolean isCancelled()Returns true if the Vibrator has been cancelled. -
getMilliseconds
public long getMilliseconds()Returns the last vibration duration in MS. -
getPattern
public long[] getPattern()Returns the last vibration pattern. -
getEffectId
public int getEffectId()Returns the last vibration effect ID of aVibrationEffect#Prebaked
(e.g.VibrationEffect#EFFECT_CLICK
).This field is non-zero only if a
VibrationEffect#Prebaked
was ever requested. -
getRepeat
public int getRepeat()Returns the last vibration repeat times. -
getPrimitiveSegmentsInPrimitiveEffects
Returns the last list ofPrimitiveSegment
vibrations inShadowVibrator.PrimitiveEffect
. -
getPrimitiveEffects
Returns the last list ofShadowVibrator.PrimitiveEffect
. -
areAllPrimitivesSupported
-
setSupportedPrimitives
Adds supported vibration primitives. -
getPrimitiveDurations
-
setPrimitiveDurations
public void setPrimitiveDurations(int primitiveId, int durationMillis) Set a custom duration in milliseconds for the given vibration primitive. -
getVibrationAttributesFromLastVibration
Returns theVibrationAttributes
from the last vibration. -
getAudioAttributesFromLastVibration
Returns theAudioAttributes
from the last vibration. -
reset
-