| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2010 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 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 17 | /** | 
 | 18 |  * @addtogroup Sensor | 
 | 19 |  * @{ | 
 | 20 |  */ | 
 | 21 |  | 
 | 22 | /** | 
 | 23 |  * @file sensor.h | 
 | 24 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 25 |  | 
 | 26 | #ifndef ANDROID_SENSOR_H | 
 | 27 | #define ANDROID_SENSOR_H | 
 | 28 |  | 
 | 29 | /****************************************************************** | 
 | 30 |  * | 
 | 31 |  * IMPORTANT NOTICE: | 
 | 32 |  * | 
 | 33 |  *   This file is part of Android's set of stable system headers | 
 | 34 |  *   exposed by the Android NDK (Native Development Kit). | 
 | 35 |  * | 
 | 36 |  *   Third-party source AND binary code relies on the definitions | 
 | 37 |  *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. | 
 | 38 |  * | 
 | 39 |  *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) | 
 | 40 |  *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS | 
 | 41 |  *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY | 
 | 42 |  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES | 
 | 43 |  */ | 
 | 44 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 45 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 46 |  * Structures and functions to receive and process sensor events in | 
 | 47 |  * native code. | 
 | 48 |  * | 
 | 49 |  */ | 
 | 50 |  | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 51 | #include <android/looper.h> | 
 | 52 |  | 
| Dan Albert | 8f860fd | 2017-04-25 12:24:28 -0700 | [diff] [blame] | 53 | #include <stdbool.h> | 
| Peng Xu | da8385c | 2017-02-28 20:19:47 -0800 | [diff] [blame] | 54 | #include <sys/types.h> | 
 | 55 | #include <math.h> | 
 | 56 | #include <stdint.h> | 
 | 57 |  | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 58 | #ifdef __cplusplus | 
 | 59 | extern "C" { | 
 | 60 | #endif | 
 | 61 |  | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 62 | typedef struct AHardwareBuffer AHardwareBuffer; | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 63 |  | 
| Peng Xu | da8385c | 2017-02-28 20:19:47 -0800 | [diff] [blame] | 64 | #define ASENSOR_RESOLUTION_INVALID     (nanf("")) | 
 | 65 | #define ASENSOR_FIFO_COUNT_INVALID     (-1) | 
 | 66 | #define ASENSOR_DELAY_INVALID          INT32_MIN | 
| Brian Stack | 8228fa7 | 2019-01-04 14:15:13 -0800 | [diff] [blame] | 67 | #define ASENSOR_INVALID                (-1) | 
| Peng Xu | da8385c | 2017-02-28 20:19:47 -0800 | [diff] [blame] | 68 |  | 
| Elliott Hughes | f78be36 | 2018-01-23 15:33:56 -0800 | [diff] [blame] | 69 | /* (Keep in sync with hardware/sensors-base.h and Sensor.java.) */ | 
 | 70 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 71 | /** | 
 | 72 |  * Sensor types. | 
| Elliott Hughes | f78be36 | 2018-01-23 15:33:56 -0800 | [diff] [blame] | 73 |  * | 
 | 74 |  * See | 
 | 75 |  * [android.hardware.SensorEvent#values](https://developer.android.com/reference/android/hardware/SensorEvent.html#values) | 
 | 76 |  * for detailed explanations of the data returned for each of these types. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 77 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 78 | enum { | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 79 |     /** | 
| Peng Xu | 37317b6 | 2017-03-07 17:49:31 -0800 | [diff] [blame] | 80 |      * Invalid sensor type. Returned by {@link ASensor_getType} as error value. | 
 | 81 |      */ | 
 | 82 |     ASENSOR_TYPE_INVALID = -1, | 
 | 83 |     /** | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 84 |      * {@link ASENSOR_TYPE_ACCELEROMETER} | 
 | 85 |      * reporting-mode: continuous | 
 | 86 |      * | 
 | 87 |      *  All values are in SI units (m/s^2) and measure the acceleration of the | 
 | 88 |      *  device minus the force of gravity. | 
 | 89 |      */ | 
| Johan Euphrosine | 7d319fc | 2015-08-20 18:13:43 -0700 | [diff] [blame] | 90 |     ASENSOR_TYPE_ACCELEROMETER       = 1, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 91 |     /** | 
 | 92 |      * {@link ASENSOR_TYPE_MAGNETIC_FIELD} | 
 | 93 |      * reporting-mode: continuous | 
 | 94 |      * | 
 | 95 |      *  All values are in micro-Tesla (uT) and measure the geomagnetic | 
 | 96 |      *  field in the X, Y and Z axis. | 
 | 97 |      */ | 
| Johan Euphrosine | 7d319fc | 2015-08-20 18:13:43 -0700 | [diff] [blame] | 98 |     ASENSOR_TYPE_MAGNETIC_FIELD      = 2, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 99 |     /** | 
 | 100 |      * {@link ASENSOR_TYPE_GYROSCOPE} | 
 | 101 |      * reporting-mode: continuous | 
 | 102 |      * | 
 | 103 |      *  All values are in radians/second and measure the rate of rotation | 
 | 104 |      *  around the X, Y and Z axis. | 
 | 105 |      */ | 
| Johan Euphrosine | 7d319fc | 2015-08-20 18:13:43 -0700 | [diff] [blame] | 106 |     ASENSOR_TYPE_GYROSCOPE           = 4, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 107 |     /** | 
 | 108 |      * {@link ASENSOR_TYPE_LIGHT} | 
 | 109 |      * reporting-mode: on-change | 
 | 110 |      * | 
 | 111 |      * The light sensor value is returned in SI lux units. | 
 | 112 |      */ | 
| Johan Euphrosine | 7d319fc | 2015-08-20 18:13:43 -0700 | [diff] [blame] | 113 |     ASENSOR_TYPE_LIGHT               = 5, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 114 |     /** | 
| Elliott Hughes | f78be36 | 2018-01-23 15:33:56 -0800 | [diff] [blame] | 115 |      * {@link ASENSOR_TYPE_PRESSURE} | 
 | 116 |      * | 
 | 117 |      * The pressure sensor value is returned in hPa (millibar). | 
 | 118 |      */ | 
 | 119 |     ASENSOR_TYPE_PRESSURE            = 6, | 
 | 120 |     /** | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 121 |      * {@link ASENSOR_TYPE_PROXIMITY} | 
 | 122 |      * reporting-mode: on-change | 
 | 123 |      * | 
 | 124 |      * The proximity sensor which turns the screen off and back on during calls is the | 
 | 125 |      * wake-up proximity sensor. Implement wake-up proximity sensor before implementing | 
 | 126 |      * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag | 
 | 127 |      * SENSOR_FLAG_WAKE_UP. | 
 | 128 |      * The value corresponds to the distance to the nearest object in centimeters. | 
 | 129 |      */ | 
| Johan Euphrosine | 7d319fc | 2015-08-20 18:13:43 -0700 | [diff] [blame] | 130 |     ASENSOR_TYPE_PROXIMITY           = 8, | 
 | 131 |     /** | 
| Elliott Hughes | f78be36 | 2018-01-23 15:33:56 -0800 | [diff] [blame] | 132 |      * {@link ASENSOR_TYPE_GRAVITY} | 
 | 133 |      * | 
 | 134 |      * All values are in SI units (m/s^2) and measure the direction and | 
 | 135 |      * magnitude of gravity. When the device is at rest, the output of | 
 | 136 |      * the gravity sensor should be identical to that of the accelerometer. | 
 | 137 |      */ | 
 | 138 |     ASENSOR_TYPE_GRAVITY             = 9, | 
 | 139 |     /** | 
| Johan Euphrosine | 7d319fc | 2015-08-20 18:13:43 -0700 | [diff] [blame] | 140 |      * {@link ASENSOR_TYPE_LINEAR_ACCELERATION} | 
 | 141 |      * reporting-mode: continuous | 
 | 142 |      * | 
 | 143 |      *  All values are in SI units (m/s^2) and measure the acceleration of the | 
 | 144 |      *  device not including the force of gravity. | 
 | 145 |      */ | 
| Elliott Hughes | f78be36 | 2018-01-23 15:33:56 -0800 | [diff] [blame] | 146 |     ASENSOR_TYPE_LINEAR_ACCELERATION = 10, | 
 | 147 |     /** | 
 | 148 |      * {@link ASENSOR_TYPE_ROTATION_VECTOR} | 
 | 149 |      */ | 
 | 150 |     ASENSOR_TYPE_ROTATION_VECTOR     = 11, | 
 | 151 |     /** | 
 | 152 |      * {@link ASENSOR_TYPE_RELATIVE_HUMIDITY} | 
 | 153 |      * | 
 | 154 |      * The relative humidity sensor value is returned in percent. | 
 | 155 |      */ | 
 | 156 |     ASENSOR_TYPE_RELATIVE_HUMIDITY   = 12, | 
 | 157 |     /** | 
 | 158 |      * {@link ASENSOR_TYPE_AMBIENT_TEMPERATURE} | 
 | 159 |      * | 
 | 160 |      * The ambient temperature sensor value is returned in Celcius. | 
 | 161 |      */ | 
 | 162 |     ASENSOR_TYPE_AMBIENT_TEMPERATURE = 13, | 
 | 163 |     /** | 
 | 164 |      * {@link ASENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED} | 
 | 165 |      */ | 
 | 166 |     ASENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 14, | 
 | 167 |     /** | 
 | 168 |      * {@link ASENSOR_TYPE_GAME_ROTATION_VECTOR} | 
 | 169 |      */ | 
 | 170 |     ASENSOR_TYPE_GAME_ROTATION_VECTOR = 15, | 
 | 171 |     /** | 
 | 172 |      * {@link ASENSOR_TYPE_GYROSCOPE_UNCALIBRATED} | 
 | 173 |      */ | 
 | 174 |     ASENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 16, | 
 | 175 |     /** | 
 | 176 |      * {@link ASENSOR_TYPE_SIGNIFICANT_MOTION} | 
 | 177 |      */ | 
 | 178 |     ASENSOR_TYPE_SIGNIFICANT_MOTION = 17, | 
 | 179 |     /** | 
 | 180 |      * {@link ASENSOR_TYPE_STEP_DETECTOR} | 
 | 181 |      */ | 
 | 182 |     ASENSOR_TYPE_STEP_DETECTOR = 18, | 
 | 183 |     /** | 
 | 184 |      * {@link ASENSOR_TYPE_STEP_COUNTER} | 
 | 185 |      */ | 
 | 186 |     ASENSOR_TYPE_STEP_COUNTER = 19, | 
 | 187 |     /** | 
 | 188 |      * {@link ASENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR} | 
 | 189 |      */ | 
 | 190 |     ASENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20, | 
 | 191 |     /** | 
 | 192 |      * {@link ASENSOR_TYPE_HEART_RATE} | 
 | 193 |      */ | 
 | 194 |     ASENSOR_TYPE_HEART_RATE = 21, | 
 | 195 |     /** | 
 | 196 |      * {@link ASENSOR_TYPE_POSE_6DOF} | 
 | 197 |      */ | 
 | 198 |     ASENSOR_TYPE_POSE_6DOF = 28, | 
 | 199 |     /** | 
 | 200 |      * {@link ASENSOR_TYPE_STATIONARY_DETECT} | 
 | 201 |      */ | 
 | 202 |     ASENSOR_TYPE_STATIONARY_DETECT = 29, | 
 | 203 |     /** | 
 | 204 |      * {@link ASENSOR_TYPE_MOTION_DETECT} | 
 | 205 |      */ | 
 | 206 |     ASENSOR_TYPE_MOTION_DETECT = 30, | 
 | 207 |     /** | 
 | 208 |      * {@link ASENSOR_TYPE_HEART_BEAT} | 
 | 209 |      */ | 
 | 210 |     ASENSOR_TYPE_HEART_BEAT = 31, | 
 | 211 |     /** | 
| Brian Stack | ccd8843 | 2019-01-08 17:04:18 -0800 | [diff] [blame] | 212 |      * This sensor type is for delivering additional sensor information aside | 
 | 213 |      * from sensor event data. | 
 | 214 |      * | 
 | 215 |      * Additional information may include: | 
 | 216 |      *     - {@link ASENSOR_ADDITIONAL_INFO_INTERNAL_TEMPERATURE} | 
 | 217 |      *     - {@link ASENSOR_ADDITIONAL_INFO_SAMPLING} | 
 | 218 |      *     - {@link ASENSOR_ADDITIONAL_INFO_SENSOR_PLACEMENT} | 
 | 219 |      *     - {@link ASENSOR_ADDITIONAL_INFO_UNTRACKED_DELAY} | 
 | 220 |      *     - {@link ASENSOR_ADDITIONAL_INFO_VEC3_CALIBRATION} | 
 | 221 |      * | 
 | 222 |      * This type will never bind to a sensor. In other words, no sensor in the | 
 | 223 |      * sensor list can have the type {@link ASENSOR_TYPE_ADDITIONAL_INFO}. | 
 | 224 |      * | 
 | 225 |      * If a device supports the sensor additional information feature, it will | 
 | 226 |      * report additional information events via {@link ASensorEvent} and will | 
 | 227 |      * have {@link ASensorEvent#type} set to | 
 | 228 |      * {@link ASENSOR_TYPE_ADDITIONAL_INFO} and {@link ASensorEvent#sensor} set | 
 | 229 |      * to the handle of the reporting sensor. | 
 | 230 |      * | 
 | 231 |      * Additional information reports consist of multiple frames ordered by | 
 | 232 |      * {@link ASensorEvent#timestamp}. The first frame in the report will have | 
 | 233 |      * a {@link AAdditionalInfoEvent#type} of | 
 | 234 |      * {@link ASENSOR_ADDITIONAL_INFO_BEGIN}, and the last frame in the report | 
 | 235 |      * will have a {@link AAdditionalInfoEvent#type} of | 
 | 236 |      * {@link ASENSOR_ADDITIONAL_INFO_END}. | 
 | 237 |      * | 
 | 238 |      */ | 
 | 239 |     ASENSOR_TYPE_ADDITIONAL_INFO = 33, | 
 | 240 |     /** | 
| Elliott Hughes | f78be36 | 2018-01-23 15:33:56 -0800 | [diff] [blame] | 241 |      * {@link ASENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT} | 
 | 242 |      */ | 
 | 243 |     ASENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT = 34, | 
 | 244 |     /** | 
 | 245 |      * {@link ASENSOR_TYPE_ACCELEROMETER_UNCALIBRATED} | 
 | 246 |      */ | 
 | 247 |     ASENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 35, | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 248 | }; | 
 | 249 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 250 | /** | 
 | 251 |  * Sensor accuracy measure. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 252 |  */ | 
 | 253 | enum { | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 254 |     /** no contact */ | 
| Etienne Le Grand | 630e31d | 2014-05-22 17:15:08 -0700 | [diff] [blame] | 255 |     ASENSOR_STATUS_NO_CONTACT       = -1, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 256 |     /** unreliable */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 257 |     ASENSOR_STATUS_UNRELIABLE       = 0, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 258 |     /** low accuracy */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 259 |     ASENSOR_STATUS_ACCURACY_LOW     = 1, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 260 |     /** medium accuracy */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 261 |     ASENSOR_STATUS_ACCURACY_MEDIUM  = 2, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 262 |     /** high accuracy */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 263 |     ASENSOR_STATUS_ACCURACY_HIGH    = 3 | 
 | 264 | }; | 
 | 265 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 266 | /** | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 267 |  * Sensor Reporting Modes. | 
 | 268 |  */ | 
 | 269 | enum { | 
| Peng Xu | 37317b6 | 2017-03-07 17:49:31 -0800 | [diff] [blame] | 270 |     /** invalid reporting mode */ | 
 | 271 |     AREPORTING_MODE_INVALID = -1, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 272 |     /** continuous reporting */ | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 273 |     AREPORTING_MODE_CONTINUOUS = 0, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 274 |     /** reporting on change */ | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 275 |     AREPORTING_MODE_ON_CHANGE = 1, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 276 |     /** on shot reporting */ | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 277 |     AREPORTING_MODE_ONE_SHOT = 2, | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 278 |     /** special trigger reporting */ | 
| Peng Xu | 37317b6 | 2017-03-07 17:49:31 -0800 | [diff] [blame] | 279 |     AREPORTING_MODE_SPECIAL_TRIGGER = 3 | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 280 | }; | 
 | 281 |  | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 282 | /** | 
 | 283 |  * Sensor Direct Report Rates. | 
 | 284 |  */ | 
 | 285 | enum { | 
 | 286 |     /** stopped */ | 
 | 287 |     ASENSOR_DIRECT_RATE_STOP = 0, | 
 | 288 |     /** nominal 50Hz */ | 
 | 289 |     ASENSOR_DIRECT_RATE_NORMAL = 1, | 
 | 290 |     /** nominal 200Hz */ | 
 | 291 |     ASENSOR_DIRECT_RATE_FAST = 2, | 
 | 292 |     /** nominal 800Hz */ | 
 | 293 |     ASENSOR_DIRECT_RATE_VERY_FAST = 3 | 
 | 294 | }; | 
 | 295 |  | 
 | 296 | /** | 
 | 297 |  * Sensor Direct Channel Type. | 
 | 298 |  */ | 
 | 299 | enum { | 
 | 300 |     /** shared memory created by ASharedMemory_create */ | 
 | 301 |     ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY = 1, | 
 | 302 |     /** AHardwareBuffer */ | 
 | 303 |     ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER = 2 | 
 | 304 | }; | 
 | 305 |  | 
| Brian Stack | ccd8843 | 2019-01-08 17:04:18 -0800 | [diff] [blame] | 306 | /** | 
 | 307 |  * Sensor Additional Info Types. | 
 | 308 |  * | 
 | 309 |  * Used to populate {@link AAdditionalInfoEvent#type}. | 
 | 310 |  */ | 
 | 311 | enum { | 
 | 312 |     /** Marks the beginning of additional information frames */ | 
 | 313 |     ASENSOR_ADDITIONAL_INFO_BEGIN = 0, | 
 | 314 |  | 
 | 315 |     /** Marks the end of additional information frames */ | 
 | 316 |     ASENSOR_ADDITIONAL_INFO_END = 1, | 
 | 317 |  | 
 | 318 |     /** | 
 | 319 |      * Estimation of the delay that is not tracked by sensor timestamps. This | 
 | 320 |      * includes delay introduced by sensor front-end filtering, data transport, | 
 | 321 |      * etc. | 
 | 322 |      * float[2]: delay in seconds, standard deviation of estimated value | 
 | 323 |      */ | 
 | 324 |     ASENSOR_ADDITIONAL_INFO_UNTRACKED_DELAY = 0x10000, | 
 | 325 |  | 
 | 326 |     /** float: Celsius temperature */ | 
 | 327 |     ASENSOR_ADDITIONAL_INFO_INTERNAL_TEMPERATURE, | 
 | 328 |  | 
 | 329 |     /** | 
 | 330 |      * First three rows of a homogeneous matrix, which represents calibration to | 
 | 331 |      * a three-element vector raw sensor reading. | 
 | 332 |      * float[12]: 3x4 matrix in row major order | 
 | 333 |      */ | 
 | 334 |     ASENSOR_ADDITIONAL_INFO_VEC3_CALIBRATION, | 
 | 335 |  | 
 | 336 |     /** | 
 | 337 |      * Location and orientation of sensor element in the device frame: origin is | 
 | 338 |      * the geometric center of the mobile device screen surface; the axis | 
 | 339 |      * definition corresponds to Android sensor definitions. | 
 | 340 |      * float[12]: 3x4 matrix in row major order | 
 | 341 |      */ | 
 | 342 |     ASENSOR_ADDITIONAL_INFO_SENSOR_PLACEMENT, | 
 | 343 |  | 
 | 344 |     /** | 
 | 345 |      * float[2]: raw sample period in seconds, | 
 | 346 |      *           standard deviation of sampling period | 
 | 347 |      */ | 
 | 348 |     ASENSOR_ADDITIONAL_INFO_SAMPLING, | 
 | 349 | }; | 
 | 350 |  | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 351 | /* | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 352 |  * A few useful constants | 
 | 353 |  */ | 
 | 354 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 355 | /** Earth's gravity in m/s^2 */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 356 | #define ASENSOR_STANDARD_GRAVITY            (9.80665f) | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 357 | /** Maximum magnetic field on Earth's surface in uT */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 358 | #define ASENSOR_MAGNETIC_FIELD_EARTH_MAX    (60.0f) | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 359 | /** Minimum magnetic field on Earth's surface in uT*/ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 360 | #define ASENSOR_MAGNETIC_FIELD_EARTH_MIN    (30.0f) | 
 | 361 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 362 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 363 |  * A sensor event. | 
 | 364 |  */ | 
 | 365 |  | 
| Peng Xu | 70b9838 | 2017-08-07 14:09:11 -0700 | [diff] [blame] | 366 | /* NOTE: changes to these structs have to be backward compatible */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 367 | typedef struct ASensorVector { | 
 | 368 |     union { | 
 | 369 |         float v[3]; | 
 | 370 |         struct { | 
 | 371 |             float x; | 
 | 372 |             float y; | 
 | 373 |             float z; | 
 | 374 |         }; | 
 | 375 |         struct { | 
 | 376 |             float azimuth; | 
 | 377 |             float pitch; | 
 | 378 |             float roll; | 
 | 379 |         }; | 
 | 380 |     }; | 
 | 381 |     int8_t status; | 
 | 382 |     uint8_t reserved[3]; | 
 | 383 | } ASensorVector; | 
 | 384 |  | 
| Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 385 | typedef struct AMetaDataEvent { | 
 | 386 |     int32_t what; | 
 | 387 |     int32_t sensor; | 
 | 388 | } AMetaDataEvent; | 
 | 389 |  | 
 | 390 | typedef struct AUncalibratedEvent { | 
| Peng Xu | 9e72046 | 2016-01-26 18:48:54 -0800 | [diff] [blame] | 391 |     union { | 
 | 392 |         float uncalib[3]; | 
 | 393 |         struct { | 
 | 394 |             float x_uncalib; | 
 | 395 |             float y_uncalib; | 
 | 396 |             float z_uncalib; | 
 | 397 |         }; | 
| Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 398 |     }; | 
| Peng Xu | 9e72046 | 2016-01-26 18:48:54 -0800 | [diff] [blame] | 399 |     union { | 
 | 400 |         float bias[3]; | 
 | 401 |         struct { | 
 | 402 |             float x_bias; | 
 | 403 |             float y_bias; | 
 | 404 |             float z_bias; | 
 | 405 |         }; | 
| Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 406 |     }; | 
| Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 407 | } AUncalibratedEvent; | 
 | 408 |  | 
| Etienne Le Grand | 630e31d | 2014-05-22 17:15:08 -0700 | [diff] [blame] | 409 | typedef struct AHeartRateEvent { | 
| Peng Xu | 9e72046 | 2016-01-26 18:48:54 -0800 | [diff] [blame] | 410 |     float bpm; | 
 | 411 |     int8_t status; | 
| Etienne Le Grand | 630e31d | 2014-05-22 17:15:08 -0700 | [diff] [blame] | 412 | } AHeartRateEvent; | 
 | 413 |  | 
| Peng Xu | 2576cb6 | 2016-01-20 00:22:09 -0800 | [diff] [blame] | 414 | typedef struct ADynamicSensorEvent { | 
| Peng Xu | 9e72046 | 2016-01-26 18:48:54 -0800 | [diff] [blame] | 415 |     int32_t  connected; | 
 | 416 |     int32_t  handle; | 
| Peng Xu | 2576cb6 | 2016-01-20 00:22:09 -0800 | [diff] [blame] | 417 | } ADynamicSensorEvent; | 
 | 418 |  | 
| Brian Stack | ccd8843 | 2019-01-08 17:04:18 -0800 | [diff] [blame] | 419 | typedef struct AAdditionalInfoEvent { | 
| Peng Xu | 9e72046 | 2016-01-26 18:48:54 -0800 | [diff] [blame] | 420 |     int32_t type; | 
 | 421 |     int32_t serial; | 
 | 422 |     union { | 
 | 423 |         int32_t data_int32[14]; | 
 | 424 |         float   data_float[14]; | 
 | 425 |     }; | 
 | 426 | } AAdditionalInfoEvent; | 
 | 427 |  | 
| Peng Xu | 70b9838 | 2017-08-07 14:09:11 -0700 | [diff] [blame] | 428 | /* NOTE: changes to this struct has to be backward compatible */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 429 | typedef struct ASensorEvent { | 
 | 430 |     int32_t version; /* sizeof(struct ASensorEvent) */ | 
 | 431 |     int32_t sensor; | 
 | 432 |     int32_t type; | 
 | 433 |     int32_t reserved0; | 
 | 434 |     int64_t timestamp; | 
 | 435 |     union { | 
| Mathias Agopian | ba02cd2 | 2013-07-03 16:20:57 -0700 | [diff] [blame] | 436 |         union { | 
 | 437 |             float           data[16]; | 
 | 438 |             ASensorVector   vector; | 
 | 439 |             ASensorVector   acceleration; | 
 | 440 |             ASensorVector   magnetic; | 
 | 441 |             float           temperature; | 
 | 442 |             float           distance; | 
 | 443 |             float           light; | 
 | 444 |             float           pressure; | 
| Aravind Akella | 724d91d | 2013-06-27 12:04:23 -0700 | [diff] [blame] | 445 |             float           relative_humidity; | 
 | 446 |             AUncalibratedEvent uncalibrated_gyro; | 
 | 447 |             AUncalibratedEvent uncalibrated_magnetic; | 
 | 448 |             AMetaDataEvent meta_data; | 
| Etienne Le Grand | 630e31d | 2014-05-22 17:15:08 -0700 | [diff] [blame] | 449 |             AHeartRateEvent heart_rate; | 
| Peng Xu | 2576cb6 | 2016-01-20 00:22:09 -0800 | [diff] [blame] | 450 |             ADynamicSensorEvent dynamic_sensor_meta; | 
| Peng Xu | 9e72046 | 2016-01-26 18:48:54 -0800 | [diff] [blame] | 451 |             AAdditionalInfoEvent additional_info; | 
| Mathias Agopian | ba02cd2 | 2013-07-03 16:20:57 -0700 | [diff] [blame] | 452 |         }; | 
 | 453 |         union { | 
 | 454 |             uint64_t        data[8]; | 
 | 455 |             uint64_t        step_counter; | 
 | 456 |         } u64; | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 457 |     }; | 
| Aravind Akella | 9a844cf | 2014-02-11 18:58:52 -0800 | [diff] [blame] | 458 |  | 
 | 459 |     uint32_t flags; | 
 | 460 |     int32_t reserved1[3]; | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 461 | } ASensorEvent; | 
 | 462 |  | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 463 | struct ASensorManager; | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 464 | /** | 
 | 465 |  * {@link ASensorManager} is an opaque type to manage sensors and | 
 | 466 |  * events queues. | 
 | 467 |  * | 
 | 468 |  * {@link ASensorManager} is a singleton that can be obtained using | 
 | 469 |  * ASensorManager_getInstance(). | 
 | 470 |  * | 
 | 471 |  * This file provides a set of functions that uses {@link | 
 | 472 |  * ASensorManager} to access and list hardware sensors, and | 
 | 473 |  * create and destroy event queues: | 
 | 474 |  * - ASensorManager_getSensorList() | 
 | 475 |  * - ASensorManager_getDefaultSensor() | 
 | 476 |  * - ASensorManager_getDefaultSensorEx() | 
 | 477 |  * - ASensorManager_createEventQueue() | 
 | 478 |  * - ASensorManager_destroyEventQueue() | 
 | 479 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 480 | typedef struct ASensorManager ASensorManager; | 
 | 481 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 482 |  | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 483 | struct ASensorEventQueue; | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 484 | /** | 
 | 485 |  * {@link ASensorEventQueue} is an opaque type that provides access to | 
 | 486 |  * {@link ASensorEvent} from hardware sensors. | 
 | 487 |  * | 
 | 488 |  * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue(). | 
 | 489 |  * | 
 | 490 |  * This file provides a set of functions to enable and disable | 
 | 491 |  * sensors, check and get events, and set event rates on a {@link | 
 | 492 |  * ASensorEventQueue}. | 
 | 493 |  * - ASensorEventQueue_enableSensor() | 
 | 494 |  * - ASensorEventQueue_disableSensor() | 
 | 495 |  * - ASensorEventQueue_hasEvents() | 
 | 496 |  * - ASensorEventQueue_getEvents() | 
 | 497 |  * - ASensorEventQueue_setEventRate() | 
| Brian Stack | 65089d5 | 2019-01-11 10:52:07 -0800 | [diff] [blame] | 498 |  * - ASensorEventQueue_requestAdditionalInfoEvents() | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 499 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 500 | typedef struct ASensorEventQueue ASensorEventQueue; | 
 | 501 |  | 
 | 502 | struct ASensor; | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 503 | /** | 
 | 504 |  * {@link ASensor} is an opaque type that provides information about | 
 | 505 |  * an hardware sensors. | 
 | 506 |  * | 
 | 507 |  * A {@link ASensor} pointer can be obtained using | 
 | 508 |  * ASensorManager_getDefaultSensor(), | 
 | 509 |  * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}. | 
 | 510 |  * | 
 | 511 |  * This file provides a set of functions to access properties of a | 
 | 512 |  * {@link ASensor}: | 
 | 513 |  * - ASensor_getName() | 
 | 514 |  * - ASensor_getVendor() | 
 | 515 |  * - ASensor_getType() | 
 | 516 |  * - ASensor_getResolution() | 
 | 517 |  * - ASensor_getMinDelay() | 
 | 518 |  * - ASensor_getFifoMaxEventCount() | 
 | 519 |  * - ASensor_getFifoReservedEventCount() | 
 | 520 |  * - ASensor_getStringType() | 
 | 521 |  * - ASensor_getReportingMode() | 
 | 522 |  * - ASensor_isWakeUpSensor() | 
| Brian Stack | 8228fa7 | 2019-01-04 14:15:13 -0800 | [diff] [blame] | 523 |  * - ASensor_getHandle() | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 524 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 525 | typedef struct ASensor ASensor; | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 526 | /** | 
 | 527 |  * {@link ASensorRef} is a type for constant pointers to {@link ASensor}. | 
 | 528 |  * | 
 | 529 |  * This is used to define entry in {@link ASensorList} arrays. | 
 | 530 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 531 | typedef ASensor const* ASensorRef; | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 532 | /** | 
 | 533 |  * {@link ASensorList} is an array of reference to {@link ASensor}. | 
 | 534 |  * | 
 | 535 |  * A {@link ASensorList} can be initialized using ASensorManager_getSensorList(). | 
 | 536 |  */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 537 | typedef ASensorRef const* ASensorList; | 
 | 538 |  | 
 | 539 | /*****************************************************************************/ | 
 | 540 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 541 | /** | 
| Svet Ganov | 5fa32d4 | 2015-05-07 10:50:59 -0700 | [diff] [blame] | 542 |  * Get a reference to the sensor manager. ASensorManager is a singleton | 
 | 543 |  * per package as different packages may have access to different sensors. | 
 | 544 |  * | 
 | 545 |  * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead. | 
 | 546 |  * | 
 | 547 |  * Example: | 
 | 548 |  * | 
 | 549 |  *     ASensorManager* sensorManager = ASensorManager_getInstance(); | 
 | 550 |  * | 
 | 551 |  */ | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 552 | #if __ANDROID_API__ >= 26 | 
| Svet Ganov | 5fa32d4 | 2015-05-07 10:50:59 -0700 | [diff] [blame] | 553 | __attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance(); | 
| Peng Xu | 477db44 | 2017-07-17 16:40:50 -0700 | [diff] [blame] | 554 | #else | 
 | 555 | ASensorManager* ASensorManager_getInstance(); | 
 | 556 | #endif | 
| Svet Ganov | 5fa32d4 | 2015-05-07 10:50:59 -0700 | [diff] [blame] | 557 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 558 | #if __ANDROID_API__ >= 26 | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 559 | /** | 
| Svet Ganov | 5fa32d4 | 2015-05-07 10:50:59 -0700 | [diff] [blame] | 560 |  * Get a reference to the sensor manager. ASensorManager is a singleton | 
 | 561 |  * per package as different packages may have access to different sensors. | 
 | 562 |  * | 
 | 563 |  * Example: | 
 | 564 |  * | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 565 |  *     ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz"); | 
| Svet Ganov | 5fa32d4 | 2015-05-07 10:50:59 -0700 | [diff] [blame] | 566 |  * | 
 | 567 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 568 | ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName) __INTRODUCED_IN(26); | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 569 | #endif | 
| Svet Ganov | 5fa32d4 | 2015-05-07 10:50:59 -0700 | [diff] [blame] | 570 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 571 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 572 |  * Returns the list of available sensors. | 
 | 573 |  */ | 
 | 574 | int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list); | 
 | 575 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 576 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 577 |  * Returns the default sensor for the given type, or NULL if no sensor | 
| Aravind Akella | b37ba39 | 2014-08-05 14:53:07 -0700 | [diff] [blame] | 578 |  * of that type exists. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 579 |  */ | 
 | 580 | ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type); | 
 | 581 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 582 | #if __ANDROID_API__ >= 21 | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 583 | /** | 
| Aravind Akella | b37ba39 | 2014-08-05 14:53:07 -0700 | [diff] [blame] | 584 |  * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor | 
 | 585 |  * of this type and wakeUp properties exists. | 
 | 586 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 587 | ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp) __INTRODUCED_IN(21); | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 588 | #endif | 
| Aravind Akella | b37ba39 | 2014-08-05 14:53:07 -0700 | [diff] [blame] | 589 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 590 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 591 |  * Creates a new sensor event queue and associate it with a looper. | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 592 |  * | 
 | 593 |  * "ident" is a identifier for the events that will be returned when | 
 | 594 |  * calling ALooper_pollOnce(). The identifier must be >= 0, or | 
 | 595 |  * ALOOPER_POLL_CALLBACK if providing a non-NULL callback. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 596 |  */ | 
 | 597 | ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager, | 
 | 598 |         ALooper* looper, int ident, ALooper_callbackFunc callback, void* data); | 
 | 599 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 600 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 601 |  * Destroys the event queue and free all resources associated to it. | 
 | 602 |  */ | 
 | 603 | int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue); | 
 | 604 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 605 | #if __ANDROID_API__ >= 26 | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 606 | /** | 
 | 607 |  * Create direct channel based on shared memory | 
 | 608 |  * | 
 | 609 |  * Create a direct channel of {@link ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY} to be used | 
 | 610 |  * for configuring sensor direct report. | 
 | 611 |  * | 
 | 612 |  * \param manager the {@link ASensorManager} instance obtained from | 
 | 613 |  *                {@link ASensorManager_getInstanceForPackage}. | 
 | 614 |  * \param fd      file descriptor representing a shared memory created by | 
 | 615 |  *                {@link ASharedMemory_create} | 
 | 616 |  * \param size    size to be used, must be less or equal to size of shared memory. | 
 | 617 |  * | 
 | 618 |  * \return a positive integer as a channel id to be used in | 
 | 619 |  *         {@link ASensorManager_destroyDirectChannel} and | 
 | 620 |  *         {@link ASensorManager_configureDirectReport}, or value less or equal to 0 for failures. | 
 | 621 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 622 | int ASensorManager_createSharedMemoryDirectChannel(ASensorManager* manager, int fd, size_t size) __INTRODUCED_IN(26); | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 623 |  | 
 | 624 | /** | 
 | 625 |  * Create direct channel based on AHardwareBuffer | 
 | 626 |  * | 
 | 627 |  * Create a direct channel of {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER} type to be used | 
 | 628 |  * for configuring sensor direct report. | 
 | 629 |  * | 
 | 630 |  * \param manager the {@link ASensorManager} instance obtained from | 
 | 631 |  *                {@link ASensorManager_getInstanceForPackage}. | 
 | 632 |  * \param buffer  {@link AHardwareBuffer} instance created by {@link AHardwareBuffer_allocate}. | 
 | 633 |  * \param size    the intended size to be used, must be less or equal to size of buffer. | 
 | 634 |  * | 
 | 635 |  * \return a positive integer as a channel id to be used in | 
 | 636 |  *         {@link ASensorManager_destroyDirectChannel} and | 
 | 637 |  *         {@link ASensorManager_configureDirectReport}, or value less or equal to 0 for failures. | 
 | 638 |  */ | 
 | 639 | int ASensorManager_createHardwareBufferDirectChannel( | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 640 |         ASensorManager* manager, AHardwareBuffer const * buffer, size_t size) __INTRODUCED_IN(26); | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 641 |  | 
 | 642 | /** | 
 | 643 |  * Destroy a direct channel | 
 | 644 |  * | 
 | 645 |  * Destroy a direct channel previously created using {@link ASensorManager_createDirectChannel}. | 
 | 646 |  * The buffer used for creating direct channel does not get destroyed with | 
 | 647 |  * {@link ASensorManager_destroy} and has to be close or released separately. | 
 | 648 |  * | 
 | 649 |  * \param manager the {@link ASensorManager} instance obtained from | 
 | 650 |  *                {@link ASensorManager_getInstanceForPackage}. | 
 | 651 |  * \param channelId channel id (a positive integer) returned from | 
 | 652 |  *                  {@link ASensorManager_createSharedMemoryDirectChannel} or | 
 | 653 |  *                  {@link ASensorManager_createHardwareBufferDirectChannel}. | 
 | 654 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 655 | void ASensorManager_destroyDirectChannel(ASensorManager* manager, int channelId) __INTRODUCED_IN(26); | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 656 |  | 
 | 657 | /** | 
 | 658 |  * Configure direct report on channel | 
 | 659 |  * | 
 | 660 |  * Configure sensor direct report on a direct channel: set rate to value other than | 
 | 661 |  * {@link ASENSOR_DIRECT_RATE_STOP} so that sensor event can be directly | 
| Peng Xu | ec53d02 | 2017-04-06 18:02:29 -0700 | [diff] [blame] | 662 |  * written into the shared memory region used for creating the buffer. It returns a positive token | 
 | 663 |  * which can be used for identify sensor events from different sensors on success. Calling with rate | 
 | 664 |  * {@link ASENSOR_DIRECT_RATE_STOP} will stop direct report of the sensor specified in the channel. | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 665 |  * | 
 | 666 |  * To stop all active sensor direct report configured to a channel, set sensor to NULL and rate to | 
 | 667 |  * {@link ASENSOR_DIRECT_RATE_STOP}. | 
 | 668 |  * | 
 | 669 |  * In order to successfully configure a direct report, the sensor has to support the specified rate | 
 | 670 |  * and the channel type, which can be checked by {@link ASensor_getHighestDirectReportRateLevel} and | 
 | 671 |  * {@link ASensor_isDirectChannelTypeSupported}, respectively. | 
 | 672 |  * | 
 | 673 |  * Example: | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 674 |  * | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 675 |  *     ASensorManager *manager = ...; | 
 | 676 |  *     ASensor *sensor = ...; | 
 | 677 |  *     int channelId = ...; | 
 | 678 |  * | 
 | 679 |  *     ASensorManager_configureDirectReport(manager, sensor, channel_id, ASENSOR_DIRECT_RATE_FAST); | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 680 |  * | 
 | 681 |  * \param manager   the {@link ASensorManager} instance obtained from | 
 | 682 |  *                  {@link ASensorManager_getInstanceForPackage}. | 
 | 683 |  * \param sensor    a {@link ASensor} to denote which sensor to be operate. It can be NULL if rate | 
 | 684 |  *                  is {@link ASENSOR_DIRECT_RATE_STOP}, denoting stopping of all active sensor | 
 | 685 |  *                  direct report. | 
 | 686 |  * \param channelId channel id (a positive integer) returned from | 
 | 687 |  *                  {@link ASensorManager_createSharedMemoryDirectChannel} or | 
 | 688 |  *                  {@link ASensorManager_createHardwareBufferDirectChannel}. | 
 | 689 |  * | 
| Peng Xu | ec53d02 | 2017-04-06 18:02:29 -0700 | [diff] [blame] | 690 |  * \return positive token for success or negative error code. | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 691 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 692 | int ASensorManager_configureDirectReport(ASensorManager* manager, | 
 | 693 |         ASensor const* sensor, int channelId, int rate) __INTRODUCED_IN(26); | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 694 | #endif /* __ANDROID_API__ >= 26 */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 695 |  | 
 | 696 | /*****************************************************************************/ | 
 | 697 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 698 | /** | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 699 |  * Enable the selected sensor with sampling and report parameters | 
 | 700 |  * | 
 | 701 |  * Enable the selected sensor at a specified sampling period and max batch report latency. | 
 | 702 |  * To disable  sensor, use {@link ASensorEventQueue_disableSensor}. | 
 | 703 |  * | 
 | 704 |  * \param queue {@link ASensorEventQueue} for sensor event to be report to. | 
 | 705 |  * \param sensor {@link ASensor} to be enabled. | 
 | 706 |  * \param samplingPeriodUs sampling period of sensor in microseconds. | 
 | 707 |  * \param maxBatchReportLatencyus maximum time interval between two batch of sensor events are | 
 | 708 |  *                                delievered in microseconds. For sensor streaming, set to 0. | 
 | 709 |  * \return 0 on success or a negative error code on failure. | 
| Aniroop Mathur | da94fd8 | 2015-11-03 01:47:46 +0530 | [diff] [blame] | 710 |  */ | 
 | 711 | int ASensorEventQueue_registerSensor(ASensorEventQueue* queue, ASensor const* sensor, | 
| Peng Xu | da8385c | 2017-02-28 20:19:47 -0800 | [diff] [blame] | 712 |         int32_t samplingPeriodUs, int64_t maxBatchReportLatencyUs); | 
| Aniroop Mathur | da94fd8 | 2015-11-03 01:47:46 +0530 | [diff] [blame] | 713 |  | 
 | 714 | /** | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 715 |  * Enable the selected sensor at default sampling rate. | 
 | 716 |  * | 
 | 717 |  * Start event reports of a sensor to specified sensor event queue at a default rate. | 
 | 718 |  * | 
 | 719 |  * \param queue {@link ASensorEventQueue} for sensor event to be report to. | 
 | 720 |  * \param sensor {@link ASensor} to be enabled. | 
 | 721 |  * | 
 | 722 |  * \return 0 on success or a negative error code on failure. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 723 |  */ | 
 | 724 | int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor); | 
 | 725 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 726 | /** | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 727 |  * Disable the selected sensor. | 
 | 728 |  * | 
 | 729 |  * Stop event reports from the sensor to specified sensor event queue. | 
 | 730 |  * | 
 | 731 |  * \param queue {@link ASensorEventQueue} to be changed | 
 | 732 |  * \param sensor {@link ASensor} to be disabled | 
 | 733 |  * \return 0 on success or a negative error code on failure. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 734 |  */ | 
 | 735 | int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor); | 
 | 736 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 737 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 738 |  * Sets the delivery rate of events in microseconds for the given sensor. | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 739 |  * | 
 | 740 |  * This function has to be called after {@link ASensorEventQueue_enableSensor}. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 741 |  * Note that this is a hint only, generally event will arrive at a higher | 
 | 742 |  * rate. It is an error to set a rate inferior to the value returned by | 
 | 743 |  * ASensor_getMinDelay(). | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 744 |  * | 
 | 745 |  * \param queue {@link ASensorEventQueue} to which sensor event is delivered. | 
 | 746 |  * \param sensor {@link ASensor} of which sampling rate to be updated. | 
 | 747 |  * \param usec sensor sampling period (1/sampling rate) in microseconds | 
 | 748 |  * \return 0 on sucess or a negative error code on failure. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 749 |  */ | 
 | 750 | int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec); | 
 | 751 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 752 | /** | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 753 |  * Determine if a sensor event queue has pending event to be processed. | 
 | 754 |  * | 
 | 755 |  * \param queue {@link ASensorEventQueue} to be queried | 
 | 756 |  * \return 1 if the queue has events; 0 if it does not have events; | 
 | 757 |  *         or a negative value if there is an error. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 758 |  */ | 
 | 759 | int ASensorEventQueue_hasEvents(ASensorEventQueue* queue); | 
 | 760 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 761 | /** | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 762 |  * Retrieve pending events in sensor event queue | 
 | 763 |  * | 
 | 764 |  * Retrieve next available events from the queue to a specified event array. | 
 | 765 |  * | 
 | 766 |  * \param queue {@link ASensorEventQueue} to get events from | 
 | 767 |  * \param events pointer to an array of {@link ASensorEvents}. | 
 | 768 |  * \param count max number of event that can be filled into array event. | 
 | 769 |  * \return number of events returned on success; negative error code when | 
 | 770 |  *         no events are pending or an error has occurred. | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 771 |  * | 
 | 772 |  * Examples: | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 773 |  * | 
| Peng Xu | 80df016 | 2017-08-05 19:00:23 -0700 | [diff] [blame] | 774 |  *     ASensorEvent event; | 
 | 775 |  *     ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1); | 
 | 776 |  * | 
 | 777 |  *     ASensorEvent eventBuffer[8]; | 
 | 778 |  *     ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8); | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 779 |  * | 
 | 780 |  */ | 
| Peng Xu | da8385c | 2017-02-28 20:19:47 -0800 | [diff] [blame] | 781 | ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, ASensorEvent* events, size_t count); | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 782 |  | 
| Brian Stack | 65089d5 | 2019-01-11 10:52:07 -0800 | [diff] [blame] | 783 | #if __ANDROID_API__ >= __ANDROID_API_Q__ | 
 | 784 | /** | 
 | 785 |  * Request that {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to be delivered on | 
 | 786 |  * the given {@link ASensorEventQueue}. | 
 | 787 |  * | 
 | 788 |  * Sensor data events are always delivered to the {@ASensorEventQueue}. | 
 | 789 |  * | 
 | 790 |  * The {@link ASENSOR_TYPE_ADDITIONAL_INFO} events will be returned through | 
 | 791 |  * {@link ASensorEventQueue_getEvents}. The client is responsible for checking | 
 | 792 |  * {@link ASensorEvent#type} to determine the event type prior to handling of | 
 | 793 |  * the event. | 
 | 794 |  * | 
 | 795 |  * The client must be tolerant of any value for | 
 | 796 |  * {@link AAdditionalInfoEvent#type}, as new values may be defined in the future | 
 | 797 |  * and may delivered to the client. | 
 | 798 |  * | 
 | 799 |  * \param queue {@link ASensorEventQueue} to configure | 
 | 800 |  * \param enable true to request {@link ASENSOR_TYPE_ADDITIONAL_INFO} events, | 
 | 801 |  *        false to stop receiving events | 
 | 802 |  * \return 0 on success or a negative error code on failure | 
 | 803 |  */ | 
 | 804 | int ASensorEventQueue_requestAdditionalInfoEvents(ASensorEventQueue* queue, bool enable); | 
 | 805 | #endif /* __ANDROID_API__ >= __ANDRDOID_API_Q__ */ | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 806 |  | 
 | 807 | /*****************************************************************************/ | 
 | 808 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 809 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 810 |  * Returns this sensor's name (non localized) | 
 | 811 |  */ | 
 | 812 | const char* ASensor_getName(ASensor const* sensor); | 
 | 813 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 814 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 815 |  * Returns this sensor's vendor's name (non localized) | 
 | 816 |  */ | 
 | 817 | const char* ASensor_getVendor(ASensor const* sensor); | 
 | 818 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 819 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 820 |  * Return this sensor's type | 
 | 821 |  */ | 
 | 822 | int ASensor_getType(ASensor const* sensor); | 
 | 823 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 824 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 825 |  * Returns this sensors's resolution | 
 | 826 |  */ | 
 | 827 | float ASensor_getResolution(ASensor const* sensor); | 
 | 828 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 829 | /** | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 830 |  * Returns the minimum delay allowed between events in microseconds. | 
 | 831 |  * A value of zero means that this sensor doesn't report events at a | 
 | 832 |  * constant rate, but rather only when a new data is available. | 
 | 833 |  */ | 
 | 834 | int ASensor_getMinDelay(ASensor const* sensor); | 
 | 835 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 836 | #if __ANDROID_API__ >= 21 | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 837 | /** | 
| Aravind Akella | 7001804 | 2014-04-07 22:52:37 +0000 | [diff] [blame] | 838 |  * Returns the maximum size of batches for this sensor. Batches will often be | 
 | 839 |  * smaller, as the hardware fifo might be used for other sensors. | 
 | 840 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 841 | int ASensor_getFifoMaxEventCount(ASensor const* sensor) __INTRODUCED_IN(21); | 
| Aravind Akella | 7001804 | 2014-04-07 22:52:37 +0000 | [diff] [blame] | 842 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 843 | /** | 
| Aravind Akella | 7001804 | 2014-04-07 22:52:37 +0000 | [diff] [blame] | 844 |  * Returns the hardware batch fifo size reserved to this sensor. | 
 | 845 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 846 | int ASensor_getFifoReservedEventCount(ASensor const* sensor) __INTRODUCED_IN(21); | 
| Aravind Akella | 7001804 | 2014-04-07 22:52:37 +0000 | [diff] [blame] | 847 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 848 | /** | 
| Aravind Akella | 7001804 | 2014-04-07 22:52:37 +0000 | [diff] [blame] | 849 |  * Returns this sensor's string type. | 
 | 850 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 851 | const char* ASensor_getStringType(ASensor const* sensor) __INTRODUCED_IN(21); | 
| Aravind Akella | 7001804 | 2014-04-07 22:52:37 +0000 | [diff] [blame] | 852 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 853 | /** | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 854 |  * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants. | 
 | 855 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 856 | int ASensor_getReportingMode(ASensor const* sensor) __INTRODUCED_IN(21); | 
| Aravind Akella | 0e025c5 | 2014-06-03 19:19:57 -0700 | [diff] [blame] | 857 |  | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 858 | /** | 
| Aravind Akella | b37ba39 | 2014-08-05 14:53:07 -0700 | [diff] [blame] | 859 |  * Returns true if this is a wake up sensor, false otherwise. | 
 | 860 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 861 | bool ASensor_isWakeUpSensor(ASensor const* sensor) __INTRODUCED_IN(21); | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 862 | #endif /* __ANDROID_API__ >= 21 */ | 
| Aravind Akella | b37ba39 | 2014-08-05 14:53:07 -0700 | [diff] [blame] | 863 |  | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 864 | #if __ANDROID_API__ >= 26 | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 865 | /** | 
 | 866 |  * Test if sensor supports a certain type of direct channel. | 
 | 867 |  * | 
 | 868 |  * \param sensor  a {@link ASensor} to denote the sensor to be checked. | 
 | 869 |  * \param channelType  Channel type constant, either | 
 | 870 |  *                     {@ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY} | 
 | 871 |  *                     or {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER}. | 
 | 872 |  * \returns true if sensor supports the specified direct channel type. | 
 | 873 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 874 | bool ASensor_isDirectChannelTypeSupported(ASensor const* sensor, int channelType) __INTRODUCED_IN(26); | 
 | 875 |  | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 876 | /** | 
 | 877 |  * Get the highest direct rate level that a sensor support. | 
 | 878 |  * | 
 | 879 |  * \param sensor  a {@link ASensor} to denote the sensor to be checked. | 
 | 880 |  * | 
 | 881 |  * \return a ASENSOR_DIRECT_RATE_... enum denoting the highest rate level supported by the sensor. | 
 | 882 |  *         If return value is {@link ASENSOR_DIRECT_RATE_STOP}, it means the sensor | 
 | 883 |  *         does not support direct report. | 
 | 884 |  */ | 
| Elliott Hughes | 9db409b | 2018-06-18 12:28:46 -0700 | [diff] [blame] | 885 | int ASensor_getHighestDirectReportRateLevel(ASensor const* sensor) __INTRODUCED_IN(26); | 
| Ryan Prichard | 92b1ebe | 2018-07-19 20:32:19 -0700 | [diff] [blame] | 886 | #endif /* __ANDROID_API__ >= 26 */ | 
| Peng Xu | 47cddca | 2017-02-15 23:31:22 -0800 | [diff] [blame] | 887 |  | 
| Brian Stack | 8228fa7 | 2019-01-04 14:15:13 -0800 | [diff] [blame] | 888 | #if __ANDROID_API__ >= __ANDROID_API_Q__ | 
 | 889 | /** | 
 | 890 |  * Returns the sensor's handle. | 
 | 891 |  * | 
 | 892 |  * The handle identifies the sensor within the system and is included in the | 
 | 893 |  * {@link ASensorEvent#sensor} field of sensor events, including those sent with type | 
 | 894 |  * {@link ASENSOR_TYPE_ADDITIONAL_INFO}. | 
 | 895 |  * | 
 | 896 |  * A sensor's handle is able to be used to map {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to the | 
 | 897 |  * sensor that generated the event. | 
 | 898 |  * | 
 | 899 |  * It is important to note that the value returned by {@link ASensor_getHandle} is not the same as | 
 | 900 |  * the value returned by the Java API {@link android.hardware.Sensor#getId} and no mapping exists | 
 | 901 |  * between the values. | 
 | 902 |  */ | 
 | 903 | int ASensor_getHandle(ASensor const* sensor) __INTRODUCED_IN(__ANDROID_API_Q__); | 
 | 904 | #endif /* __ANDROID_API__ >= ANDROID_API_Q__ */ | 
 | 905 |  | 
| Mathias Agopian | e1c61d3 | 2012-03-23 14:19:36 -0700 | [diff] [blame] | 906 | #ifdef __cplusplus | 
 | 907 | }; | 
 | 908 | #endif | 
 | 909 |  | 
 | 910 | #endif // ANDROID_SENSOR_H | 
| Johan Euphrosine | bf6d5e0 | 2015-03-27 17:15:43 -0700 | [diff] [blame] | 911 |  | 
 | 912 | /** @} */ |