Class ShadowVibrator

java.lang.Object
org.robolectric.shadows.ShadowVibrator
Direct Known Subclasses:
ShadowSystemVibrator

@Implements(android.os.Vibrator.class) public class ShadowVibrator extends Object
  • Field Details

    • pattern

      protected static long[] pattern
    • vibrationEffectSegments

      protected static final List<Object> vibrationEffectSegments
    • primitiveEffects

      protected static final List<ShadowVibrator.PrimitiveEffect> primitiveEffects
    • supportedPrimitives

      protected static final List<Integer> supportedPrimitives
    • vibrationAttributesFromLastVibration

      @Nullable protected static Object vibrationAttributesFromLastVibration
    • audioAttributesFromLastVibration

      @Nullable protected static AudioAttributes audioAttributesFromLastVibration
  • Constructor Details

    • ShadowVibrator

      public ShadowVibrator()
  • Method Details

    • setHasVibrator

      public void setHasVibrator(boolean hasVibrator)
      Controls the return value of Vibrator.hasVibrator() the default is true.
    • setHasAmplitudeControl

      public void setHasAmplitudeControl(boolean hasAmplitudeControl)
      Controls the return value of Vibrator.hasAmplitudeControl() the default is false.
    • isVibrating

      @Implementation(minSdk=30) public boolean isVibrating()
      Returns true if the Vibrator is currently vibrating as controlled by Vibrator.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 a VibrationEffect#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

      public List<ShadowVibrator.PrimitiveEffect> getPrimitiveSegmentsInPrimitiveEffects()
      Returns the last list of PrimitiveSegment vibrations in ShadowVibrator.PrimitiveEffect.
    • getPrimitiveEffects

      @Nullable public List<ShadowVibrator.PrimitiveEffect> getPrimitiveEffects()
      Returns the last list of ShadowVibrator.PrimitiveEffect.
    • areAllPrimitivesSupported

      @Implementation(minSdk=30) protected boolean areAllPrimitivesSupported(int... primitiveIds)
    • setSupportedPrimitives

      public void setSupportedPrimitives(Collection<Integer> primitives)
      Adds supported vibration primitives.
    • getVibrationAttributesFromLastVibration

      @Nullable public Object getVibrationAttributesFromLastVibration()
      Returns the VibrationAttributes from the last vibration.
    • getAudioAttributesFromLastVibration

      @Nullable public AudioAttributes getAudioAttributesFromLastVibration()
      Returns the AudioAttributes from the last vibration.
    • reset

      @Resetter public static void reset()