@Implements(value=android.hardware.SensorManager.class, looseSignatures=true) public class ShadowSensorManager extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
boolean |
forceListenersToFail |
Constructor and Description |
---|
ShadowSensorManager() |
Modifier and Type | Method and 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. This method will be removed at some point allowing us to use more of the real SensorManager code. |
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. |
protected android.hardware.Sensor |
getDefaultSensor(int type) |
java.util.List<android.hardware.SensorEventListener> |
getListeners()
Returns the list of
SensorEventListener s registered on this SensorManager. |
boolean |
hasListener(android.hardware.SensorEventListener listener) |
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,
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) |
@Deprecated public void addSensor(int sensorType, android.hardware.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.Provide a Sensor for the indicated sensor type.
sensorType
- from Sensor constantssensor
- Sensor instancepublic void addSensor(android.hardware.Sensor sensor)
Adds a Sensor
to the SensorManager
@Implementation protected android.hardware.Sensor getDefaultSensor(int type)
@Implementation protected boolean registerListener(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor, int rate, android.os.Handler handler)
handler
- is ignored.@Implementation protected boolean registerListener(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor, int rate)
@Implementation protected void unregisterListener(android.hardware.SensorEventListener listener, android.hardware.Sensor sensor)
@Implementation protected void unregisterListener(android.hardware.SensorEventListener listener)
public boolean hasListener(android.hardware.SensorEventListener listener)
public java.util.List<android.hardware.SensorEventListener> getListeners()
Returns the list of SensorEventListener
s registered on this SensorManager. Note that the list is unmodifiable, any attempt to modify it will throw an exception.
public void sendSensorEventToListeners(android.hardware.SensorEvent event)
Propagates the event
to all registered listeners.
public android.hardware.SensorEvent 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.
@Implementation(minSdk=26) protected java.lang.Object createDirectChannel(android.os.MemoryFile mem)