@Implements(value=android.hardware.SensorManager.class, looseSignatures=true) public class ShadowSensorManager extends Object
Modifier and Type | Field | Description |
---|---|---|
boolean |
forceListenersToFail |
Constructor | Description |
---|---|
ShadowSensorManager() |
Modifier and Type | Method | Description |
---|---|---|
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. |
void |
addSensor(Sensor sensor) |
Adds a
Sensor to the SensorManager |
protected Object |
createDirectChannel(MemoryFile mem) |
|
SensorEvent |
createSensorEvent() |
|
static 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 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 Sensor |
getDefaultSensor(int type) |
|
List<SensorEventListener> |
getListeners() |
Returns the list of
SensorEventListener s registered on this SensorManager. |
List<Sensor> |
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 |
sendSensorEventToListeners(SensorEvent event) |
Propagates the
event to all registered listeners. |
protected void |
unregisterListener(SensorEventListener listener) |
|
protected void |
unregisterListener(SensorEventListener listener,
Sensor sensor) |
@Deprecated public void addSensor(int sensorType, Sensor sensor)
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.sensorType
- from Sensor constantssensor
- Sensor instancepublic void addSensor(Sensor sensor)
Sensor
to the SensorManager
@Implementation protected Sensor getDefaultSensor(int type)
@Implementation public List<Sensor> getSensorList(int type)
@Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, Handler handler)
handler
- is ignored.@Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency)
maxLatency
- is ignored.@Implementation(minSdk=19) protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate, int maxLatency, Handler handler)
maxLatency
- is ignored.handler
- is ignored@Implementation protected boolean registerListener(SensorEventListener listener, Sensor sensor, int rate)
@Implementation protected void unregisterListener(SensorEventListener listener, Sensor sensor)
@Implementation protected void unregisterListener(SensorEventListener listener)
public boolean hasListener(SensorEventListener listener)
public boolean hasListener(SensorEventListener listener, Sensor sensor)
public List<SensorEventListener> getListeners()
SensorEventListener
s registered on this SensorManager. Note that
the list is unmodifiable, any attempt to modify it will throw an exception.public void sendSensorEventToListeners(SensorEvent event)
event
to all registered listeners.public SensorEvent createSensorEvent()
public static SensorEvent createSensorEvent(int valueArraySize)
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.
public static SensorEvent createSensorEvent(int valueArraySize, int sensorType)
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.
@Implementation(minSdk=26) protected Object createDirectChannel(MemoryFile mem)