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 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.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
setSupportedPrimitives
(Collection<Integer> primitives) Adds supported vibration primitives.
-
Field Details
-
pattern
protected static long[] pattern -
vibrationEffectSegments
-
primitiveEffects
-
supportedPrimitives
-
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. -
getVibrationAttributesFromLastVibration
Returns theVibrationAttributes
from the last vibration. -
getAudioAttributesFromLastVibration
Returns theAudioAttributes
from the last vibration. -
reset
-