Package org.robolectric.shadows
Class ShadowSensorManager
java.lang.Object
org.robolectric.shadows.ShadowSensorManager
@Implements(value=android.hardware.SensorManager.class,
looseSignatures=true)
public class ShadowSensorManager
extends Object
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.void
Adds aSensor
to theSensorManager
protected Object
Deprecated.Use{@link SensorEventBuilder#newBuilder()}
instead.static SensorEvent
createSensorEvent
(int valueArraySize) Deprecated.Use{@link SensorEventBuilder#newBuilder()}
instead.static SensorEvent
createSensorEvent
(int valueArraySize, int sensorType) Deprecated.Use{@link SensorEventBuilder#newBuilder()}
instead.protected boolean
flush
(SensorEventListener listener) protected Sensor
getDefaultSensor
(int type) Returns the list ofSensorEventListener
s registered on this SensorManager.getSensorList
(int type) boolean
hasListener
(SensorEventListener listener) Tests if the sensor manager has a registration for the given listener.boolean
hasListener
(SensorEventListener listener, Sensor sensor) Tests if the sensor manager has a registration for the given listener for the given sensor.protected boolean
registerListener
(SensorEventListener listener, Sensor sensor, int rate) protected boolean
registerListener
(SensorEventListener listener, Sensor sensor, int rate, int maxLatency) protected boolean
registerListener
(SensorEventListener listener, Sensor sensor, int rate, int maxLatency, Handler handler) protected boolean
registerListener
(SensorEventListener listener, Sensor sensor, int rate, Handler handler) void
removeSensor
(Sensor sensor) void
Propagates theevent
to all registered listeners.void
sendSensorEventToListeners
(SensorEvent event, Sensor sensor) Propagates theevent
to only registered listeners of the given sensor.protected void
unregisterListener
(SensorEventListener listener) protected void
unregisterListener
(SensorEventListener listener, Sensor sensor)
-
Field Details
-
forceListenersToFail
public boolean forceListenersToFail
-
-
Constructor Details
-
ShadowSensorManager
public ShadowSensorManager()
-
-
Method Details
-
addSensor
Deprecated.UseShadowSensor.newInstance(int)
to construct yourSensor
and add to theSensorManager
usingaddSensor(Sensor)
instead. This method will be removed at some point allowing us to use more of the realSensorManager
code.Provide a Sensor for the indicated sensor type.- Parameters:
sensorType
- from Sensor constantssensor
- Sensor instance
-
addSensor
Adds aSensor
to theSensorManager
-
removeSensor
-
getDefaultSensor
-
getSensorList
-
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
-
unregisterListener
-
hasListener
Tests if the sensor manager has a registration for the given listener. -
hasListener
Tests if the sensor manager has a registration for the given listener for the given sensor. -
getListeners
Returns the list ofSensorEventListener
s registered on this SensorManager. Note that the list is unmodifiable, any attempt to modify it will throw an exception. -
sendSensorEventToListeners
Propagates theevent
to all registered listeners. -
sendSensorEventToListeners
Propagates theevent
to only registered listeners of the given sensor. -
flush
-
createSensorEvent
Deprecated.Use{@link SensorEventBuilder#newBuilder()}
instead. -
createSensorEvent
Deprecated.Use{@link SensorEventBuilder#newBuilder()}
instead.Creates aSensorEvent
with the given value array size, which the caller should set based on the type ofSensor
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.Use{@link SensorEventBuilder#newBuilder()}
instead.Creates aSensorEvent
for the givenSensor
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
-
ShadowSensor.newInstance(int)
to construct yourSensor
and add to theSensorManager
usingaddSensor(Sensor)
instead.