Andreas Huber | db49a41 | 2016-10-10 13:23:59 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.hardware.sensors@1.0; |
| 18 | |
| 19 | interface ISensors { |
| 20 | /** |
| 21 | * Enumerate all available (static) sensors. |
| 22 | */ |
| 23 | getSensorsList() generates (vec<SensorInfo> list); |
| 24 | |
| 25 | /** |
| 26 | * Place the module in a specific mode. The following modes are defined |
| 27 | * |
| 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 | * |
| 42 | * sensorHandle is the handle of the sensor to change. |
| 43 | * enabled set to true to enable, or false to disable the sensor. |
| 44 | * |
| 45 | * After sensor de-activation, existing sensor events that have not |
| 46 | * been picked up by poll() should be abandoned immediately so that |
| 47 | * subsequent activation will not get stale sensor events (events |
| 48 | * that are generated prior to the latter activation). |
| 49 | * |
| 50 | * Returns OK on success, BAD_VALUE if sensorHandle is invalid. |
| 51 | */ |
| 52 | activate(int32_t sensorHandle, bool enabled) generates (Result result); |
| 53 | |
| 54 | /** |
| 55 | * Set the sampling period in nanoseconds for a given sensor. |
| 56 | * If samplingPeriodNs > maxDelay it will be truncated to |
| 57 | * maxDelay and if samplingPeriodNs < minDelay it will be |
| 58 | * replaced by minDelay. |
| 59 | * |
| 60 | * Returns OK on success, BAD_VALUE if sensorHandle is invalid. |
| 61 | */ |
| 62 | setDelay(int32_t sensorHandle, int64_t samplingPeriodNs) |
| 63 | generates (Result result); |
| 64 | |
| 65 | /** |
| 66 | * Generate a vector of sensor events containing at most "maxCount" |
| 67 | * entries. |
| 68 | * |
| 69 | * Additionally a vector of SensorInfos is returned for any dynamic sensors |
| 70 | * connected as notified by returned events of type DYNAMIC_SENSOR_META. |
| 71 | * |
| 72 | * This function should block if there is no sensor event |
| 73 | * available when being called. |
| 74 | * |
| 75 | * Returns OK on success or BAD_VALUE if maxCount <= 0. |
| 76 | */ |
| 77 | poll(int32_t maxCount) |
| 78 | generates ( |
| 79 | Result result, |
| 80 | vec<Event> data, |
| 81 | vec<SensorInfo> dynamicSensorsAdded); |
| 82 | |
| 83 | /* |
| 84 | * Sets a sensor’s parameters, including sampling frequency and maximum |
| 85 | * report latency. This function can be called while the sensor is |
| 86 | * activated, in which case it must not cause any sensor measurements to |
| 87 | * be lost: transitioning from one sampling rate to the other cannot cause |
| 88 | * lost events, nor can transitioning from a high maximum report latency to |
| 89 | * a low maximum report latency. |
| 90 | * See the Batching sensor results page for details: |
| 91 | * http://source.android.com/devices/sensors/batching.html |
| 92 | * |
| 93 | * Returns OK on success, BAD_VALUE if any parameters are invalid. |
| 94 | */ |
| 95 | batch(int32_t sensorHandle, |
| 96 | int32_t flags, |
| 97 | int64_t samplingPeriodNs, |
| 98 | int64_t maxReportLatencyNs) generates (Result result); |
| 99 | |
| 100 | /* |
| 101 | * Flush adds a FLUSH_COMPLETE metadata event to the end of the "batch mode" |
| 102 | * FIFO for the specified sensor and flushes the FIFO. |
| 103 | * If the FIFO is empty or if the sensor doesn't support batching |
| 104 | * (FIFO size zero), it should return SUCCESS along with a trivial |
| 105 | * FLUSH_COMPLETE event added to the event stream. |
| 106 | * This applies to all sensors other than one-shot sensors. |
| 107 | * If the sensor is a one-shot sensor, flush must return BAD_VALUE and not |
| 108 | * generate any flush complete metadata. |
| 109 | * If the sensor is not active at the time flush() is called, flush() should |
| 110 | * return BAD_VALUE. |
| 111 | * Returns OK on success and BAD_VALUE if sensorHandle is invalid. |
| 112 | */ |
| 113 | flush(int32_t sensorHandle) generates (Result result); |
| 114 | |
| 115 | /* |
| 116 | * Inject a single sensor sample to this device. |
| 117 | * data points to the sensor event to be injected |
| 118 | * Returns OK on success |
| 119 | * PERMISSION_DENIED if operation is not allowed |
| 120 | * INVALID_OPERATION, if this functionality is unsupported |
| 121 | * BAD_VALUE if sensor event cannot be injected |
| 122 | */ |
| 123 | injectSensorData(Event event) generates (Result result); |
Peng Xu | 0f0df7e | 2017-01-05 23:39:08 -0800 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * Register direct report channel. |
| 127 | * |
| 128 | * Register a direct channel with supplied shared memory information. Upon |
| 129 | * return, the sensor hardware is responsible for resetting the memory |
| 130 | * content to initial value (depending on memory format settings). |
| 131 | * |
| 132 | * @param mem shared memory info data structure. |
| 133 | * @return result OK on success; BAD_VALUE if shared memory information is |
| 134 | * not consistent; NO_MEMORY if shared memory cannot be used by |
| 135 | * sensor system; INVALID_OPERATION if functionality is not |
| 136 | * supported. |
| 137 | * @return channelHandle a positive integer used for referencing registered |
| 138 | * direct channel (>0) in configureDirectReport and |
| 139 | * unregisterDirectChannel if result is OK, -1 otherwise. |
| 140 | */ |
| 141 | registerDirectChannel(SharedMemInfo mem) |
| 142 | generates (Result result, int32_t channelHandle); |
| 143 | |
| 144 | /* |
| 145 | * Unregister direct report channel. |
| 146 | * |
| 147 | * Unregister a direct channel previously registered using |
| 148 | * registerDirectChannel. If there is still active sensor report configured |
| 149 | * in the direct channel, HAL should remove them. |
| 150 | * |
| 151 | * @param channelHandle handle of direct channel to be unregistered. |
| 152 | * @return result OK if direct report is supported; INVALID_OPERATION |
| 153 | * otherwise. |
| 154 | */ |
| 155 | unregisterDirectChannel(int32_t channelHandle) generates (Result result); |
| 156 | |
| 157 | /* |
| 158 | * Configure direct sensor event report in direct channel. |
| 159 | * |
| 160 | * This function start, modify rate or stop direct report of a sensor in a |
| 161 | * certain direct channel. |
| 162 | * |
| 163 | * @param sensorHandle handle of sensor to be configured. When combined |
| 164 | * with STOP rate, sensorHandle can be -1 to denote all active |
| 165 | * sensors in the direct channel specified by channel Handle. |
| 166 | * @param channelHandle handle of direct channel to be configured. |
| 167 | * @param rate rate level, see RateLevel enum. |
| 168 | * |
| 169 | * @return result OK on success; BAD_VALUE if parameter is invalid (such as |
| 170 | * rate level is not supported by sensor, channelHandle does not |
| 171 | * exist, etc); INVALID_OPERATION if functionality is not |
| 172 | * supported. |
| 173 | * @return reportToken positive integer to identify multiple sensors of |
| 174 | * the same type in a single direct channel. Ignored if rate is |
| 175 | * STOP. See SharedMemFormat. |
| 176 | */ |
| 177 | configDirectReport( |
| 178 | int32_t sensorHandle, int32_t channelHandle, RateLevel rate) |
| 179 | generates (Result result, int32_t reportToken); |
Andreas Huber | db49a41 | 2016-10-10 13:23:59 -0700 | [diff] [blame] | 180 | }; |