blob: c56da29cf5786f3afa7c7a5807ab2fb55d2c0903 [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 /**
Andreas Huberdb49a412016-10-10 13:23:59 -070055 * Generate a vector of sensor events containing at most "maxCount"
56 * entries.
57 *
58 * Additionally a vector of SensorInfos is returned for any dynamic sensors
59 * connected as notified by returned events of type DYNAMIC_SENSOR_META.
60 *
Peng Xu0873e642017-01-08 13:28:10 -080061 * If there is no sensor event when this function is being called, block
62 * until there are sensor events available.
Andreas Huberdb49a412016-10-10 13:23:59 -070063 *
Peng Xu0873e642017-01-08 13:28:10 -080064 * @param maxCount max number of samples can be returned.
65 * @return result OK on success or BAD_VALUE if maxCount <= 0.
66 * @return data vector of Event contains sensor events.
67 * @return dynamicSensorsAdded vector of SensorInfo contains dynamic sensor
68 * added. Each element corresponds to a dynamic sensor meta events
69 * in data.
Andreas Huberdb49a412016-10-10 13:23:59 -070070 */
71 poll(int32_t maxCount)
72 generates (
73 Result result,
74 vec<Event> data,
75 vec<SensorInfo> dynamicSensorsAdded);
76
77 /*
78 * Sets a sensor’s parameters, including sampling frequency and maximum
79 * report latency. This function can be called while the sensor is
80 * activated, in which case it must not cause any sensor measurements to
81 * be lost: transitioning from one sampling rate to the other cannot cause
82 * lost events, nor can transitioning from a high maximum report latency to
83 * a low maximum report latency.
84 * See the Batching sensor results page for details:
85 * http://source.android.com/devices/sensors/batching.html
86 *
Peng Xu0873e642017-01-08 13:28:10 -080087 * @param sensorHandle handle of sensor to be changed.
88 * @param samplingPeriodNs specifies sensor sample period in nanoseconds.
89 * @param maxReportLatencyNs allowed delay time before an event is sampled
90 * to time of report.
91 * @return result OK on success, BAD_VALUE if any parameters are invalid.
Andreas Huberdb49a412016-10-10 13:23:59 -070092 */
93 batch(int32_t sensorHandle,
Andreas Huberdb49a412016-10-10 13:23:59 -070094 int64_t samplingPeriodNs,
95 int64_t maxReportLatencyNs) generates (Result result);
96
97 /*
Peng Xu0873e642017-01-08 13:28:10 -080098 * Trigger a flush of internal FIFO.
99 *
Andreas Huberdb49a412016-10-10 13:23:59 -0700100 * Flush adds a FLUSH_COMPLETE metadata event to the end of the "batch mode"
Peng Xu0873e642017-01-08 13:28:10 -0800101 * FIFO for the specified sensor and flushes the FIFO. If the FIFO is empty
102 * or if the sensor doesn't support batching (FIFO size zero), return
103 * SUCCESS and add a trivial FLUSH_COMPLETE event added to the event stream.
104 * This applies to all sensors other than one-shot sensors. If the sensor
105 * is a one-shot sensor, flush must return BAD_VALUE and not generate any
106 * flush complete metadata. If the sensor is not active at the time flush()
107 * is called, flush() return BAD_VALUE.
108 *
109 * @param sensorHandle handle of sensor to be flushed.
110 * @return result OK on success and BAD_VALUE if sensorHandle is invalid.
Andreas Huberdb49a412016-10-10 13:23:59 -0700111 */
112 flush(int32_t sensorHandle) generates (Result result);
113
114 /*
Peng Xue82ec562017-01-06 15:27:09 -0800115 * Inject a single sensor event or push operation environment parameters to
116 * device.
117 *
118 * When device is in NORMAL mode, this function is called to push operation
119 * environment data to device. In this operation, Event is always of
120 * SensorType::AdditionalInfo type. See operation evironment parameters
121 * section in AdditionalInfoType.
122 *
123 * When device is in DATA_INJECTION mode, this function is also used for
124 * injecting sensor events.
125 *
126 * Regardless of OperationMode, injected SensorType::ADDITIONAL_INFO
127 * type events should not be routed back to poll() function.
128 *
129 * @see AdditionalInfoType
130 * @see OperationMode
131 * @param event sensor event to be injected
132 * @return result OK on success; PERMISSION_DENIED if operation is not
133 * allowed; INVALID_OPERATION, if this functionality is
134 * unsupported; BAD_VALUE if sensor event cannot be injected.
Andreas Huberdb49a412016-10-10 13:23:59 -0700135 */
136 injectSensorData(Event event) generates (Result result);
Peng Xu0f0df7e2017-01-05 23:39:08 -0800137
138 /*
139 * Register direct report channel.
140 *
141 * Register a direct channel with supplied shared memory information. Upon
142 * return, the sensor hardware is responsible for resetting the memory
143 * content to initial value (depending on memory format settings).
144 *
145 * @param mem shared memory info data structure.
146 * @return result OK on success; BAD_VALUE if shared memory information is
147 * not consistent; NO_MEMORY if shared memory cannot be used by
148 * sensor system; INVALID_OPERATION if functionality is not
149 * supported.
150 * @return channelHandle a positive integer used for referencing registered
151 * direct channel (>0) in configureDirectReport and
152 * unregisterDirectChannel if result is OK, -1 otherwise.
153 */
154 registerDirectChannel(SharedMemInfo mem)
155 generates (Result result, int32_t channelHandle);
156
157 /*
158 * Unregister direct report channel.
159 *
160 * Unregister a direct channel previously registered using
Peng Xu0873e642017-01-08 13:28:10 -0800161 * registerDirectChannel, and remove all active sensor report configured in
162 * still active sensor report configured in the direct channel.
Peng Xu0f0df7e2017-01-05 23:39:08 -0800163 *
164 * @param channelHandle handle of direct channel to be unregistered.
165 * @return result OK if direct report is supported; INVALID_OPERATION
166 * otherwise.
167 */
168 unregisterDirectChannel(int32_t channelHandle) generates (Result result);
169
170 /*
171 * Configure direct sensor event report in direct channel.
172 *
173 * This function start, modify rate or stop direct report of a sensor in a
174 * certain direct channel.
175 *
176 * @param sensorHandle handle of sensor to be configured. When combined
177 * with STOP rate, sensorHandle can be -1 to denote all active
178 * sensors in the direct channel specified by channel Handle.
179 * @param channelHandle handle of direct channel to be configured.
180 * @param rate rate level, see RateLevel enum.
181 *
182 * @return result OK on success; BAD_VALUE if parameter is invalid (such as
183 * rate level is not supported by sensor, channelHandle does not
184 * exist, etc); INVALID_OPERATION if functionality is not
185 * supported.
186 * @return reportToken positive integer to identify multiple sensors of
187 * the same type in a single direct channel. Ignored if rate is
188 * STOP. See SharedMemFormat.
189 */
190 configDirectReport(
191 int32_t sensorHandle, int32_t channelHandle, RateLevel rate)
192 generates (Result result, int32_t reportToken);
Andreas Huberdb49a412016-10-10 13:23:59 -0700193};