blob: a60cc10484bc5b8a4d9fe6681a9db732f57c96b6 [file] [log] [blame]
Andreas Huberdb49a412016-10-10 13:23:59 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.sensors@1.0;
18
19interface ISensors {
20 /**
21 * Enumerate all available (static) sensors.
22 */
23 getSensorsList() generates (vec<SensorInfo> list);
24
25 /**
Peng Xu0873e642017-01-08 13:28:10 -080026 * Place the module in a specific mode. The following modes are defined
Andreas Huberdb49a412016-10-10 13:23:59 -070027 *
28 * SENSOR_HAL_NORMAL_MODE - Normal operation. Default state of the module.
29 *
30 * SENSOR_HAL_DATA_INJECTION_MODE - Loopback mode.
31 * Data is injected for the supported sensors by the sensor service in
32 * this mode.
33 *
34 * @return OK on success
35 * BAD_VALUE if requested mode is not supported
36 * PERMISSION_DENIED if operation is not allowed
37 */
38 setOperationMode(OperationMode mode) generates (Result result);
39
40 /* Activate/de-activate one sensor.
41 *
Andreas Huberdb49a412016-10-10 13:23:59 -070042 * After sensor de-activation, existing sensor events that have not
Peng Xu0873e642017-01-08 13:28:10 -080043 * been picked up by poll() must be abandoned immediately so that
Andreas Huberdb49a412016-10-10 13:23:59 -070044 * subsequent activation will not get stale sensor events (events
45 * that are generated prior to the latter activation).
46 *
Peng Xu0873e642017-01-08 13:28:10 -080047 * @param sensorHandle is the handle of the sensor to change.
48 * @param enabled set to true to enable, or false to disable the sensor.
49 *
50 * @return result OK on success, BAD_VALUE if sensorHandle is invalid.
Andreas Huberdb49a412016-10-10 13:23:59 -070051 */
52 activate(int32_t sensorHandle, bool enabled) generates (Result result);
53
54 /**
55 * Set the sampling period in nanoseconds for a given sensor.
Peng Xu0873e642017-01-08 13:28:10 -080056 *
Andreas Huberdb49a412016-10-10 13:23:59 -070057 * If samplingPeriodNs > maxDelay it will be truncated to
58 * maxDelay and if samplingPeriodNs < minDelay it will be
59 * replaced by minDelay.
60 *
Peng Xu0873e642017-01-08 13:28:10 -080061 * @param sensorHandle handle of sensor to be changed.
62 * @param samplngPeriodNs specified sampling period in nanoseconds.
63 * @return result OK on success, BAD_VALUE if sensorHandle is invalid.
Andreas Huberdb49a412016-10-10 13:23:59 -070064 */
65 setDelay(int32_t sensorHandle, int64_t samplingPeriodNs)
66 generates (Result result);
67
68 /**
69 * Generate a vector of sensor events containing at most "maxCount"
70 * entries.
71 *
72 * Additionally a vector of SensorInfos is returned for any dynamic sensors
73 * connected as notified by returned events of type DYNAMIC_SENSOR_META.
74 *
Peng Xu0873e642017-01-08 13:28:10 -080075 * If there is no sensor event when this function is being called, block
76 * until there are sensor events available.
Andreas Huberdb49a412016-10-10 13:23:59 -070077 *
Peng Xu0873e642017-01-08 13:28:10 -080078 * @param maxCount max number of samples can be returned.
79 * @return result OK on success or BAD_VALUE if maxCount <= 0.
80 * @return data vector of Event contains sensor events.
81 * @return dynamicSensorsAdded vector of SensorInfo contains dynamic sensor
82 * added. Each element corresponds to a dynamic sensor meta events
83 * in data.
Andreas Huberdb49a412016-10-10 13:23:59 -070084 */
85 poll(int32_t maxCount)
86 generates (
87 Result result,
88 vec<Event> data,
89 vec<SensorInfo> dynamicSensorsAdded);
90
91 /*
92 * Sets a sensor’s parameters, including sampling frequency and maximum
93 * report latency. This function can be called while the sensor is
94 * activated, in which case it must not cause any sensor measurements to
95 * be lost: transitioning from one sampling rate to the other cannot cause
96 * lost events, nor can transitioning from a high maximum report latency to
97 * a low maximum report latency.
98 * See the Batching sensor results page for details:
99 * http://source.android.com/devices/sensors/batching.html
100 *
Peng Xu0873e642017-01-08 13:28:10 -0800101 * @param sensorHandle handle of sensor to be changed.
102 * @param samplingPeriodNs specifies sensor sample period in nanoseconds.
103 * @param maxReportLatencyNs allowed delay time before an event is sampled
104 * to time of report.
105 * @return result OK on success, BAD_VALUE if any parameters are invalid.
Andreas Huberdb49a412016-10-10 13:23:59 -0700106 */
107 batch(int32_t sensorHandle,
108 int32_t flags,
109 int64_t samplingPeriodNs,
110 int64_t maxReportLatencyNs) generates (Result result);
111
112 /*
Peng Xu0873e642017-01-08 13:28:10 -0800113 * Trigger a flush of internal FIFO.
114 *
Andreas Huberdb49a412016-10-10 13:23:59 -0700115 * Flush adds a FLUSH_COMPLETE metadata event to the end of the "batch mode"
Peng Xu0873e642017-01-08 13:28:10 -0800116 * FIFO for the specified sensor and flushes the FIFO. If the FIFO is empty
117 * or if the sensor doesn't support batching (FIFO size zero), return
118 * SUCCESS and add a trivial FLUSH_COMPLETE event added to the event stream.
119 * This applies to all sensors other than one-shot sensors. If the sensor
120 * is a one-shot sensor, flush must return BAD_VALUE and not generate any
121 * flush complete metadata. If the sensor is not active at the time flush()
122 * is called, flush() return BAD_VALUE.
123 *
124 * @param sensorHandle handle of sensor to be flushed.
125 * @return result OK on success and BAD_VALUE if sensorHandle is invalid.
Andreas Huberdb49a412016-10-10 13:23:59 -0700126 */
127 flush(int32_t sensorHandle) generates (Result result);
128
129 /*
130 * Inject a single sensor sample to this device.
131 * data points to the sensor event to be injected
132 * Returns OK on success
133 * PERMISSION_DENIED if operation is not allowed
134 * INVALID_OPERATION, if this functionality is unsupported
135 * BAD_VALUE if sensor event cannot be injected
136 */
137 injectSensorData(Event event) generates (Result result);
Peng Xu0f0df7e2017-01-05 23:39:08 -0800138
139 /*
140 * Register direct report channel.
141 *
142 * Register a direct channel with supplied shared memory information. Upon
143 * return, the sensor hardware is responsible for resetting the memory
144 * content to initial value (depending on memory format settings).
145 *
146 * @param mem shared memory info data structure.
147 * @return result OK on success; BAD_VALUE if shared memory information is
148 * not consistent; NO_MEMORY if shared memory cannot be used by
149 * sensor system; INVALID_OPERATION if functionality is not
150 * supported.
151 * @return channelHandle a positive integer used for referencing registered
152 * direct channel (>0) in configureDirectReport and
153 * unregisterDirectChannel if result is OK, -1 otherwise.
154 */
155 registerDirectChannel(SharedMemInfo mem)
156 generates (Result result, int32_t channelHandle);
157
158 /*
159 * Unregister direct report channel.
160 *
161 * Unregister a direct channel previously registered using
Peng Xu0873e642017-01-08 13:28:10 -0800162 * registerDirectChannel, and remove all active sensor report configured in
163 * still active sensor report configured in the direct channel.
Peng Xu0f0df7e2017-01-05 23:39:08 -0800164 *
165 * @param channelHandle handle of direct channel to be unregistered.
166 * @return result OK if direct report is supported; INVALID_OPERATION
167 * otherwise.
168 */
169 unregisterDirectChannel(int32_t channelHandle) generates (Result result);
170
171 /*
172 * Configure direct sensor event report in direct channel.
173 *
174 * This function start, modify rate or stop direct report of a sensor in a
175 * certain direct channel.
176 *
177 * @param sensorHandle handle of sensor to be configured. When combined
178 * with STOP rate, sensorHandle can be -1 to denote all active
179 * sensors in the direct channel specified by channel Handle.
180 * @param channelHandle handle of direct channel to be configured.
181 * @param rate rate level, see RateLevel enum.
182 *
183 * @return result OK on success; BAD_VALUE if parameter is invalid (such as
184 * rate level is not supported by sensor, channelHandle does not
185 * exist, etc); INVALID_OPERATION if functionality is not
186 * supported.
187 * @return reportToken positive integer to identify multiple sensors of
188 * the same type in a single direct channel. Ignored if rate is
189 * STOP. See SharedMemFormat.
190 */
191 configDirectReport(
192 int32_t sensorHandle, int32_t channelHandle, RateLevel rate)
193 generates (Result result, int32_t reportToken);
Andreas Huberdb49a412016-10-10 13:23:59 -0700194};