Class ShadowSensorManager

java.lang.Object
org.robolectric.shadows.ShadowSensorManager

@Implements(value=android.hardware.SensorManager.class, looseSignatures=true) public class ShadowSensorManager extends Object
  • Field Details

    • forceListenersToFail

      public boolean forceListenersToFail
  • Constructor Details

    • ShadowSensorManager

      public ShadowSensorManager()
  • Method Details

    • addSensor

      @Deprecated public void addSensor(int sensorType, Sensor sensor)
      Deprecated.
      Use ShadowSensor.newInstance(int) to construct your Sensor and add to the SensorManager using addSensor(Sensor) instead. This method will be removed at some point allowing us to use more of the real SensorManager code.
      Provide a Sensor for the indicated sensor type.
      Parameters:
      sensorType - from Sensor constants
      sensor - Sensor instance
    • addSensor

      public void addSensor(Sensor sensor)
      Adds a Sensor to the SensorManager
    • removeSensor

      public void removeSensor(Sensor sensor)
    • getDefaultSensor

      @Implementation protected Sensor getDefaultSensor(int type)
    • getSensorList

      @Implementation public List<Sensor> getSensorList(int type)
    • registerListener

      @Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, Handler handler)
      Parameters:
      handler - is ignored.
    • registerListener

      @Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency)
      Parameters:
      maxLatency - is ignored.
    • registerListener

      @Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency, Handler handler)
      Parameters:
      maxLatency - is ignored.
      handler - is ignored
    • registerListener

      @Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate)
    • unregisterListener

      @Implementation protected void unregisterListener(SensorEventListener listener, Sensor sensor)
    • unregisterListener

      @Implementation protected void unregisterListener(SensorEventListener listener)
    • hasListener

      public boolean hasListener(SensorEventListener listener)
      Tests if the sensor manager has a registration for the given listener.
    • hasListener

      public boolean hasListener(SensorEventListener listener, Sensor sensor)
      Tests if the sensor manager has a registration for the given listener for the given sensor.
    • getListeners

      public List<SensorEventListener> getListeners()
      Returns the list of SensorEventListeners registered on this SensorManager. Note that the list is unmodifiable, any attempt to modify it will throw an exception.
    • sendSensorEventToListeners

      public void sendSensorEventToListeners(SensorEvent event)
      Propagates the event to all registered listeners.
    • sendSensorEventToListeners

      public void sendSensorEventToListeners(SensorEvent event, Sensor sensor)
      Propagates the event to only registered listeners of the given sensor.
    • flush

      @Implementation protected boolean flush(SensorEventListener listener)
    • createSensorEvent

      @Deprecated public SensorEvent createSensorEvent()
      Deprecated.
      Use {@link SensorEventBuilder#newBuilder()} instead.
    • createSensorEvent

      @Deprecated public static SensorEvent createSensorEvent(int valueArraySize)
      Deprecated.
      Use {@link SensorEventBuilder#newBuilder()} instead.
      Creates a SensorEvent with the given value array size, which the caller should set based on the type of Sensor which is being emulated.

      Callers can then specify individual values for the event. For example, for a proximity event a caller may wish to specify the distance value:

      
       event.values[0] = distance;
       

      See SensorEvent.values for more information about values.

    • createSensorEvent

      @Deprecated public static SensorEvent createSensorEvent(int valueArraySize, int sensorType)
      Deprecated.
      Use {@link SensorEventBuilder#newBuilder()} instead.
      Creates a SensorEvent for the given Sensor type with the given value array size, which the caller should set based on the type of sensor which is being emulated.

      Callers can then specify individual values for the event. For example, for a proximity event a caller may wish to specify the distance value:

      
       event.values[0] = distance;
       

      See SensorEvent.values for more information about values.

    • createDirectChannel

      @Implementation(minSdk=26) protected Object createDirectChannel(MemoryFile mem)