Class ShadowSensorManager


  • @Implements(value=android.hardware.SensorManager.class,
                looseSignatures=true)
    public class ShadowSensorManager
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addSensor​(int sensorType, android.hardware.Sensor sensor)
      Deprecated.
      Use ShadowSensor.newInstance(int) to construct your Sensor and add to the SensorManager using addSensor(Sensor) instead.
      void addSensor​(android.hardware.Sensor sensor)
      Adds a Sensor to the SensorManager
      protected java.lang.Object createDirectChannel​(android.os.MemoryFile mem)  
      android.hardware.SensorEvent createSensorEvent()  
      static android.hardware.SensorEvent createSensorEvent​(int valueArraySize)
      Creates a SensorEvent with the given value array size, which the caller should set based on the type of Sensor which is being emulated.
      static android.hardware.SensorEvent createSensorEvent​(int valueArraySize, int sensorType)
      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.
      protected android.hardware.Sensor getDefaultSensor​(int type)  
      java.util.List<android.hardware.SensorEventListener> getListeners()
      Returns the list of SensorEventListeners registered on this SensorManager.
      java.util.List<android.hardware.Sensor> getSensorList​(int type)  
      boolean hasListener​(android.hardware.SensorEventListener listener)
      Tests if the sensor manager has a registration for the given listener.
      boolean hasListener​(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor)
      Tests if the sensor manager has a registration for the given listener for the given sensor.
      protected boolean registerListener​(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor, int rate)  
      protected boolean registerListener​(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor, int rate, int maxLatency)  
      protected boolean registerListener​(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor, int rate, int maxLatency, android.os.Handler handler)  
      protected boolean registerListener​(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor, int rate, android.os.Handler handler)  
      void sendSensorEventToListeners​(android.hardware.SensorEvent event)
      Propagates the event to all registered listeners.
      protected void unregisterListener​(android.hardware.SensorEventListener listener)  
      protected void unregisterListener​(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • forceListenersToFail

        public boolean forceListenersToFail
    • Constructor Detail

      • ShadowSensorManager

        public ShadowSensorManager()
    • Method Detail

      • addSensor

        @Deprecated
        public void addSensor​(int sensorType,
                              android.hardware.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​(android.hardware.Sensor sensor)
        Adds a Sensor to the SensorManager
      • getDefaultSensor

        @Implementation
        protected android.hardware.Sensor getDefaultSensor​(int type)
      • getSensorList

        @Implementation
        public java.util.List<android.hardware.Sensor> getSensorList​(int type)
      • registerListener

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

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

        @Implementation(minSdk=19)
        protected boolean registerListener​(android.hardware.SensorEventListener listener,
                                           android.hardware.Sensor sensor,
                                           int rate,
                                           int maxLatency,
                                           android.os.Handler handler)
        Parameters:
        maxLatency - is ignored.
        handler - is ignored
      • registerListener

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

        @Implementation
        protected void unregisterListener​(android.hardware.SensorEventListener listener,
                                          android.hardware.Sensor sensor)
      • unregisterListener

        @Implementation
        protected void unregisterListener​(android.hardware.SensorEventListener listener)
      • hasListener

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

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

        public java.util.List<android.hardware.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​(android.hardware.SensorEvent event)
        Propagates the event to all registered listeners.
      • createSensorEvent

        public android.hardware.SensorEvent createSensorEvent()
      • createSensorEvent

        public static android.hardware.SensorEvent createSensorEvent​(int valueArraySize)
        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

        public static android.hardware.SensorEvent createSensorEvent​(int valueArraySize,
                                                                     int sensorType)
        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 java.lang.Object createDirectChannel​(android.os.MemoryFile mem)