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); |
| 124 | }; |