Package: android.hardware.sensors@1.0

ISensors

interface ISensors

Methods

getSensorsList

getSensorsList ()
generates (vec<SensorInfo> list)

Enumerate all available(static)sensors.

Details
Generates
list

setOperationMode

setOperationMode (OperationMode mode)
generates (Result result)

Place the module in a specific mode.The following modes are defined

SENSOR_HAL_NORMAL_MODE - Normal operation.Default state of the module.

SENSOR_HAL_DATA_INJECTION_MODE - Loopback mode.Data is injected for the supported sensors by the sensor service in this mode.

Details
Parameters
mode
Generates
result

activate

activate (int32_t sensorHandle, bool enabled)
generates (Result result)

Activate/de-activate one sensor.

After sensor de-activation, existing sensor events that have not been picked up by poll() must be abandoned immediately so that subsequent activation will not get stale sensor events(events that are generated prior to the latter activation).

Details
Parameters
sensorHandle
is the handle of the sensor to change.
enabled
set to true to enable, or false to disable the sensor.
Generates
result
OK on success, BAD_VALUE if sensorHandle is invalid.

poll

poll (int32_t maxCount)
generates (Result result, vec<Event> data, vec<SensorInfo> dynamicSensorsAdded)

Generate a vector of sensor events containing at most "maxCount" entries.

Additionally a vector of SensorInfos is returned for any dynamic sensors connected as notified by returned events of type DYNAMIC_SENSOR_META.

If there is no sensor event when this function is being called, block until there are sensor events available.

Details
Parameters
maxCount
max number of samples can be returned, must be>0.Actual number of events returned in data must be <= maxCount and>0.
Generates
result
OK on success or BAD_VALUE if maxCount <= 0.
data
vector of Event contains sensor events.
dynamicSensorsAdded
vector of SensorInfo contains dynamic sensor added.Each element corresponds to a dynamic sensor meta events in data.

batch

batch (int32_t sensorHandle, int64_t samplingPeriodNs, int64_t maxReportLatencyNs)
generates (Result result)

Sets a sensor’s parameters, including sampling frequency and maximum report latency.This function can be called while the sensor is activated, in which case it must not cause any sensor measurements to be lost:transitioning from one sampling rate to the other cannot cause lost events, nor can transitioning from a high maximum report latency to a low maximum report latency.See the Batching sensor results page for details:http ://source.android.com/devices/sensors/batching.html

Details
Parameters
sensorHandle
handle of sensor to be changed.
samplingPeriodNs
specifies sensor sample period in nanoseconds.
maxReportLatencyNs
allowed delay time before an event is sampled to time of report.
Generates
result
OK on success, BAD_VALUE if any parameters are invalid.

flush

flush (int32_t sensorHandle)
generates (Result result)

Trigger a flush of internal FIFO.

Flush adds a FLUSH_COMPLETE metadata event to the end of the "batch mode" FIFO for the specified sensor and flushes the FIFO.If the FIFO is empty or if the sensor doesn't support batching(FIFO size zero), return SUCCESS and add a trivial FLUSH_COMPLETE event added to the event stream.This applies to all sensors other than one-shot sensors.If the sensor is a one-shot sensor, flush must return BAD_VALUE and not generate any flush complete metadata.If the sensor is not active at the time flush() is called, flush() return BAD_VALUE.

Details
Parameters
sensorHandle
handle of sensor to be flushed.
Generates
result
OK on success and BAD_VALUE if sensorHandle is invalid.

injectSensorData

injectSensorData (Event event)
generates (Result result)

Inject a single sensor event or push operation environment parameters to device.

When device is in NORMAL mode, this function is called to push operation environment data to device.In this operation, Event is always of SensorType::AdditionalInfo type.See operation evironment parameters section in AdditionalInfoType.

When device is in DATA_INJECTION mode, this function is also used for injecting sensor events.

Regardless of OperationMode, injected SensorType::ADDITIONAL_INFO type events should not be routed back to poll() function.

Details
Parameters
event
sensor event to be injected
Generates
result
OK on success;PERMISSION_DENIED if operation is not allowed;INVALID_OPERATION, if this functionality is unsupported;BAD_VALUE if sensor event cannot be injected.

registerDirectChannel

registerDirectChannel (SharedMemInfo mem)
generates (Result result, int32_t channelHandle)

Register direct report channel.

Register a direct channel with supplied shared memory information.Upon return, the sensor hardware is responsible for resetting the memory content to initial value(depending on memory format settings).

Details
Parameters
mem
shared memory info data structure.
Generates
result
OK on success;BAD_VALUE if shared memory information is not consistent;NO_MEMORY if shared memory cannot be used by sensor system;INVALID_OPERATION if functionality is not supported.
channelHandle
a positive integer used for referencing registered direct channel(> 0)in configureDirectReport and unregisterDirectChannel if result is OK, -1 otherwise.

unregisterDirectChannel

unregisterDirectChannel (int32_t channelHandle)
generates (Result result)

Unregister direct report channel.

Unregister a direct channel previously registered using registerDirectChannel, and remove all active sensor report configured in still active sensor report configured in the direct channel.

Details
Parameters
channelHandle
handle of direct channel to be unregistered.
Generates
result
OK if direct report is supported;INVALID_OPERATION otherwise.

configDirectReport

configDirectReport (int32_t sensorHandle, int32_t channelHandle, RateLevel rate)
generates (Result result, int32_t reportToken)

Configure direct sensor event report in direct channel.

This function start, modify rate or stop direct report of a sensor in a certain direct channel.

Details
Parameters
sensorHandle
handle of sensor to be configured.When combined with STOP rate, sensorHandle can be -1 to denote all active sensors in the direct channel specified by channel Handle.
channelHandle
handle of direct channel to be configured.
rate
rate level, see RateLevel enum.
Generates
result
OK on success;BAD_VALUE if parameter is invalid(such as rate level is not supported by sensor, channelHandle does not exist, etc); INVALID_OPERATION if functionality is not supported.
reportToken
positive integer to identify multiple sensors of the same type in a single direct channel.Ignored if rate is STOP.See SharedMemFormat.