The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 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 | #ifndef ANDROID_SENSORS_INTERFACE_H |
| 18 | #define ANDROID_SENSORS_INTERFACE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/cdefs.h> |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <hardware/hardware.h> |
Mike Lockwood | 21b652f | 2009-05-22 10:05:48 -0400 | [diff] [blame] | 25 | #include <cutils/native_handle.h> |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 26 | |
| 27 | __BEGIN_DECLS |
| 28 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 29 | /*****************************************************************************/ |
| 30 | |
| 31 | #define SENSORS_HEADER_VERSION 1 |
| 32 | #define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) |
| 33 | #define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 34 | #define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 35 | #define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 36 | #define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 37 | #define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 38 | #define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 39 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 40 | /** |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 41 | * Please see the Sensors section of source.android.com for an |
| 42 | * introduction to and detailed descriptions of Android sensor types: |
| 43 | * http://source.android.com/devices/sensors/index.html |
| 44 | */ |
| 45 | |
| 46 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 47 | * The id of this module |
| 48 | */ |
| 49 | #define SENSORS_HARDWARE_MODULE_ID "sensors" |
| 50 | |
| 51 | /** |
| 52 | * Name of the sensors device to open |
| 53 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 54 | #define SENSORS_HARDWARE_POLL "poll" |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 55 | |
| 56 | /** |
| 57 | * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. |
| 58 | * A Handle identifies a given sensors. The handle is used to activate |
| 59 | * and/or deactivate sensors. |
| 60 | * In this version of the API there can only be 256 handles. |
| 61 | */ |
| 62 | #define SENSORS_HANDLE_BASE 0 |
| 63 | #define SENSORS_HANDLE_BITS 8 |
| 64 | #define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS) |
| 65 | |
| 66 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 67 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 68 | * **** Deprecated ***** |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 69 | * flags for (*batch)() |
| 70 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 71 | * see (*batch)() documentation for details. |
| 72 | * Deprecated as of SENSORS_DEVICE_API_VERSION_1_3. |
| 73 | * WAKE_UP_* sensors replace WAKE_UPON_FIFO_FULL concept. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 74 | */ |
| 75 | enum { |
| 76 | SENSORS_BATCH_DRY_RUN = 0x00000001, |
| 77 | SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 |
| 78 | }; |
| 79 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 80 | /* |
| 81 | * what field for meta_data_event_t |
| 82 | */ |
| 83 | enum { |
| 84 | /* a previous flush operation has completed */ |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 85 | META_DATA_FLUSH_COMPLETE = 1, |
| 86 | META_DATA_VERSION /* always last, leave auto-assigned */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 89 | /* |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 90 | * The permission to use for body sensors (like heart rate monitors). |
| 91 | * See sensor types for more details on what sensors should require this |
| 92 | * permission. |
| 93 | */ |
| 94 | #define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS" |
| 95 | |
| 96 | /* |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 97 | * Availability: SENSORS_DEVICE_API_VERSION_1_4 |
Ashutosh Joshi | 050f2e4 | 2015-04-15 13:56:53 -0700 | [diff] [blame] | 98 | * Sensor HAL modes used in set_operation_mode method |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 99 | */ |
| 100 | enum { |
| 101 | /* |
| 102 | * Operating modes for the HAL. |
| 103 | */ |
| 104 | |
| 105 | /* |
| 106 | * Normal mode operation. This is the default state of operation. |
| 107 | * The HAL shall initialize into this mode on device startup. |
| 108 | */ |
| 109 | SENSOR_HAL_NORMAL_MODE = 0, |
| 110 | |
Aravind Akella | c7f5413 | 2015-06-22 18:26:54 -0700 | [diff] [blame] | 111 | /* |
| 112 | * Data Injection mode. In this mode, the device shall not source data from the |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 113 | * physical sensors as it would in normal mode. Instead sensor data is |
| 114 | * injected by the sensor service. |
| 115 | */ |
Aravind Akella | c7f5413 | 2015-06-22 18:26:54 -0700 | [diff] [blame] | 116 | SENSOR_HAL_DATA_INJECTION_MODE = 0x1 |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 117 | }; |
| 118 | |
Peng Xu | d156299 | 2016-03-29 18:14:05 -0700 | [diff] [blame] | 119 | #define SENSOR_FLAG_MASK(nbit, shift) (((1<<(nbit))-1)<<(shift)) |
| 120 | #define SENSOR_FLAG_MASK_1(shift) SENSOR_FLAG_MASK(1, shift) |
| 121 | |
| 122 | /* |
| 123 | * Mask and shift for reporting mode sensor flags defined above. |
| 124 | */ |
| 125 | #define REPORTING_MODE_SHIFT (1) |
| 126 | #define REPORTING_MODE_NBIT (3) |
| 127 | #define REPORTING_MODE_MASK SENSOR_FLAG_MASK(REPORTING_MODE_NBIT, REPORTING_MODE_SHIFT) |
| 128 | // 0xE |
| 129 | |
| 130 | /* |
| 131 | * Mask and shift for data_injection mode sensor flags defined above. |
| 132 | */ |
| 133 | #define DATA_INJECTION_SHIFT (4) |
| 134 | #define DATA_INJECTION_MASK SENSOR_FLAG_MASK_1(DATA_INJECTION_SHIFT) //0x10 |
| 135 | |
| 136 | /* |
| 137 | * Mask and shift for dynamic sensor flag. |
| 138 | */ |
| 139 | #define DYNAMIC_SENSOR_SHIFT (5) |
| 140 | #define DYNAMIC_SENSOR_MASK SENSOR_FLAG_MASK_1(DYNAMIC_SENSOR_SHIFT) //0x20 |
| 141 | |
| 142 | /* |
| 143 | * Mask and shift for sensor additional information support. |
| 144 | */ |
| 145 | #define ADDITIONAL_INFO_SHIFT (6) |
| 146 | #define ADDITIONAL_INFO_MASK SENSOR_FLAG_MASK_1(ADDITIONAL_INFO_SHIFT) //0x40 |
| 147 | |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 148 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 149 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 150 | * Sensor flags used in sensor_t.flags. |
| 151 | */ |
| 152 | enum { |
| 153 | /* |
Aravind Akella | 110d2f2 | 2014-09-04 15:36:31 -0700 | [diff] [blame] | 154 | * Whether this sensor wakes up the AP from suspend mode when data is available. Whenever |
| 155 | * sensor events are delivered from a wake_up sensor, the driver needs to hold a wake_lock till |
| 156 | * the events are read by the SensorService i.e till sensors_poll_device_t.poll() is called the |
| 157 | * next time. Once poll is called again it means events have been read by the SensorService, the |
| 158 | * driver can safely release the wake_lock. SensorService will continue to hold a wake_lock till |
| 159 | * the app actually reads the events. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 160 | */ |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 161 | SENSOR_FLAG_WAKE_UP = 1U << 0, |
| 162 | /* |
| 163 | * Reporting modes for various sensors. Each sensor will have exactly one of these modes set. |
| 164 | * The least significant 2nd, 3rd and 4th bits are used to represent four possible reporting |
| 165 | * modes. |
| 166 | */ |
| 167 | SENSOR_FLAG_CONTINUOUS_MODE = 0, // 0000 |
| 168 | SENSOR_FLAG_ON_CHANGE_MODE = 0x2, // 0010 |
| 169 | SENSOR_FLAG_ONE_SHOT_MODE = 0x4, // 0100 |
Aravind Akella | c7f5413 | 2015-06-22 18:26:54 -0700 | [diff] [blame] | 170 | SENSOR_FLAG_SPECIAL_REPORTING_MODE = 0x6, // 0110 |
| 171 | |
| 172 | /* |
| 173 | * Set this flag if the sensor supports data_injection mode and allows data to be injected |
| 174 | * from the SensorService. When in data_injection ONLY sensors with this flag set are injected |
| 175 | * sensor data and only sensors with this flag set are activated. Eg: Accelerometer and Step |
| 176 | * Counter sensors can be set with this flag and SensorService will inject accelerometer data |
| 177 | * and read the corresponding step counts. |
| 178 | */ |
Peng Xu | d156299 | 2016-03-29 18:14:05 -0700 | [diff] [blame] | 179 | SENSOR_FLAG_SUPPORTS_DATA_INJECTION = DATA_INJECTION_MASK, // 1 0000 |
| 180 | |
| 181 | /* |
| 182 | * Set this flag if the sensor is a dynamically connected sensor. See |
| 183 | * dynamic_sensor_meta_event_t and SENSOR_TYPE_DYNAMIC_SENSOR_META for details. |
| 184 | */ |
| 185 | SENSOR_FLAG_DYNAMIC_SENSOR = DYNAMIC_SENSOR_MASK, |
| 186 | |
| 187 | /* |
| 188 | * Set this flag if sensor additional information is supported. See SENSOR_TYPE_ADDITIONAL_INFO |
| 189 | * and additional_info_event_t for details. |
| 190 | */ |
| 191 | SENSOR_FLAG_ADDITIONAL_INFO = ADDITIONAL_INFO_MASK |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 192 | }; |
| 193 | |
Aravind Akella | c7f5413 | 2015-06-22 18:26:54 -0700 | [diff] [blame] | 194 | |
| 195 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 196 | * Sensor type |
| 197 | * |
| 198 | * Each sensor has a type which defines what this sensor measures and how |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 199 | * measures are reported. See the Base sensors and Composite sensors lists |
| 200 | * for complete descriptions: |
| 201 | * http://source.android.com/devices/sensors/base_triggers.html |
| 202 | * http://source.android.com/devices/sensors/composite_sensors.html |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 203 | * |
| 204 | * Device manufacturers (OEMs) can define their own sensor types, for |
| 205 | * their private use by applications or services provided by them. Such |
| 206 | * sensor types are specific to an OEM and can't be exposed in the SDK. |
| 207 | * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 208 | * |
| 209 | * All sensors defined outside of the device private range must correspond to |
| 210 | * a type defined in this file, and must satisfy the characteristics listed in |
| 211 | * the description of the sensor type. |
| 212 | * |
| 213 | * Starting with version SENSORS_DEVICE_API_VERSION_1_2, each sensor also |
| 214 | * has a stringType. |
| 215 | * - StringType of sensors inside of the device private range MUST be prefixed |
| 216 | * by the sensor provider's or OEM reverse domain name. In particular, they |
| 217 | * cannot use the "android.sensor" prefix. |
| 218 | * - StringType of sensors outside of the device private range MUST correspond |
| 219 | * to the one defined in this file (starting with "android.sensor"). |
| 220 | * For example, accelerometers must have |
| 221 | * type=SENSOR_TYPE_ACCELEROMETER and |
| 222 | * stringType=SENSOR_STRING_TYPE_ACCELEROMETER |
| 223 | * |
| 224 | * When android introduces a new sensor type that can replace an OEM-defined |
| 225 | * sensor type, the OEM must use the official sensor type and stringType on |
| 226 | * versions of the HAL that support this new official sensor type. |
| 227 | * |
| 228 | * Example (made up): Suppose Google's Glass team wants to surface a sensor |
| 229 | * detecting that Glass is on a head. |
| 230 | * - Such a sensor is not officially supported in android KitKat |
| 231 | * - Glass devices launching on KitKat can implement a sensor with |
| 232 | * type = 0x10001 and stringType = "com.google.glass.onheaddetector" |
| 233 | * - In L android release, if android decides to define |
| 234 | * SENSOR_TYPE_ON_HEAD_DETECTOR and STRING_SENSOR_TYPE_ON_HEAD_DETECTOR, |
| 235 | * those types should replace the Glass-team-specific types in all future |
| 236 | * launches. |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 237 | * - When launching Glass on the L release, Google should now use the official |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 238 | * type (SENSOR_TYPE_ON_HEAD_DETECTOR) and stringType. |
| 239 | * - This way, all applications can now use this sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 240 | */ |
| 241 | |
| 242 | /* |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 243 | * Base for device manufacturers private sensor types. |
| 244 | * These sensor types can't be exposed in the SDK. |
| 245 | */ |
| 246 | #define SENSOR_TYPE_DEVICE_PRIVATE_BASE 0x10000 |
| 247 | |
| 248 | /* |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 249 | * SENSOR_TYPE_META_DATA |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 250 | * reporting-mode: n/a |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 251 | * wake-up sensor: n/a |
| 252 | * |
| 253 | * NO SENSOR OF THAT TYPE MUST BE RETURNED (*get_sensors_list)() |
| 254 | * |
| 255 | * SENSOR_TYPE_META_DATA is a special token used to populate the |
| 256 | * sensors_meta_data_event structure. It doesn't correspond to a physical |
| 257 | * sensor. sensors_meta_data_event are special, they exist only inside |
| 258 | * the HAL and are generated spontaneously, as opposed to be related to |
| 259 | * a physical sensor. |
| 260 | * |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 261 | * sensors_meta_data_event_t.version must be META_DATA_VERSION |
| 262 | * sensors_meta_data_event_t.sensor must be 0 |
| 263 | * sensors_meta_data_event_t.type must be SENSOR_TYPE_META_DATA |
| 264 | * sensors_meta_data_event_t.reserved must be 0 |
| 265 | * sensors_meta_data_event_t.timestamp must be 0 |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 266 | * |
| 267 | * The payload is a meta_data_event_t, where: |
| 268 | * meta_data_event_t.what can take the following values: |
| 269 | * |
| 270 | * META_DATA_FLUSH_COMPLETE |
| 271 | * This event indicates that a previous (*flush)() call has completed for the sensor |
| 272 | * handle specified in meta_data_event_t.sensor. |
| 273 | * see (*flush)() for more details |
| 274 | * |
| 275 | * All other values for meta_data_event_t.what are reserved and |
| 276 | * must not be used. |
| 277 | * |
| 278 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 279 | #define SENSOR_TYPE_META_DATA (0) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 280 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 281 | /* |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 282 | * Wake up sensors. |
| 283 | * Each sensor may have either or both a wake-up and a non-wake variant. |
| 284 | * When registered in batch mode, wake-up sensors will wake up the AP when |
| 285 | * their FIFOs are full or when the batch timeout expires. A separate FIFO has |
| 286 | * to be maintained for wake up sensors and non wake up sensors. The non wake-up |
| 287 | * sensors need to overwrite their FIFOs when they are full till the AP wakes up |
| 288 | * and the wake-up sensors will wake-up the AP when their FIFOs are full or when |
| 289 | * the batch timeout expires without losing events. Wake-up and non wake-up variants |
| 290 | * of each sensor can be activated at different rates independently of each other. |
| 291 | * |
| 292 | * Note: Proximity sensor and significant motion sensor which were defined in previous |
| 293 | * releases are also wake-up sensors and should be treated as such. Wake-up one-shot |
| 294 | * sensors like SIGNIFICANT_MOTION cannot be batched, hence the text about batch above |
| 295 | * doesn't apply to them. See the definitions of SENSOR_TYPE_PROXIMITY and |
| 296 | * SENSOR_TYPE_SIGNIFICANT_MOTION for more info. |
| 297 | * |
| 298 | * Set SENSOR_FLAG_WAKE_UP flag for all wake-up sensors. |
| 299 | * |
| 300 | * For example, A device can have two sensors both of SENSOR_TYPE_ACCELEROMETER and |
| 301 | * one of them can be a wake_up sensor (with SENSOR_FLAG_WAKE_UP flag set) and the other |
| 302 | * can be a regular non wake_up sensor. Both of these sensors must be activated/deactivated |
| 303 | * independently of the other. |
| 304 | */ |
| 305 | |
| 306 | /* |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 307 | * SENSOR_TYPE_ACCELEROMETER |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 308 | * reporting-mode: continuous |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 309 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 310 | * All values are in SI units (m/s^2) and measure the acceleration of the |
| 311 | * device minus the force of gravity. |
| 312 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 313 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 314 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 315 | */ |
| 316 | #define SENSOR_TYPE_ACCELEROMETER (1) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 317 | #define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 318 | |
| 319 | /* |
| 320 | * SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 321 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 322 | * |
| 323 | * All values are in micro-Tesla (uT) and measure the geomagnetic |
| 324 | * field in the X, Y and Z axis. |
| 325 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 326 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 327 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 328 | */ |
| 329 | #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) |
| 330 | #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 331 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 332 | |
| 333 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 334 | * SENSOR_TYPE_ORIENTATION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 335 | * reporting-mode: continuous |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 336 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 337 | * All values are angles in degrees. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 338 | * |
Mathias Agopian | 66a4095 | 2010-07-22 17:11:50 -0700 | [diff] [blame] | 339 | * Orientation sensors return sensor events for all 3 axes at a constant |
| 340 | * rate defined by setDelay(). |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 341 | * |
| 342 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 343 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 344 | */ |
| 345 | #define SENSOR_TYPE_ORIENTATION (3) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 346 | #define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 347 | |
| 348 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 349 | * SENSOR_TYPE_GYROSCOPE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 350 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 351 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 352 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 353 | * around the X, Y and Z axis. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 354 | * |
| 355 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 356 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 357 | */ |
| 358 | #define SENSOR_TYPE_GYROSCOPE (4) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 359 | #define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 360 | |
| 361 | /* |
| 362 | * SENSOR_TYPE_LIGHT |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 363 | * reporting-mode: on-change |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 364 | * |
| 365 | * The light sensor value is returned in SI lux units. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 366 | * |
| 367 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 368 | */ |
| 369 | #define SENSOR_TYPE_LIGHT (5) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 370 | #define SENSOR_STRING_TYPE_LIGHT "android.sensor.light" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 371 | |
| 372 | /* |
| 373 | * SENSOR_TYPE_PRESSURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 374 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 375 | * |
| 376 | * The pressure sensor return the athmospheric pressure in hectopascal (hPa) |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 377 | * |
| 378 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 379 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 380 | */ |
| 381 | #define SENSOR_TYPE_PRESSURE (6) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 382 | #define SENSOR_STRING_TYPE_PRESSURE "android.sensor.pressure" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 383 | |
| 384 | /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ |
| 385 | #define SENSOR_TYPE_TEMPERATURE (7) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 386 | #define SENSOR_STRING_TYPE_TEMPERATURE "android.sensor.temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 387 | |
| 388 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 389 | * SENSOR_TYPE_PROXIMITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 390 | * reporting-mode: on-change |
Mike Lockwood | a241431 | 2009-11-03 10:29:50 -0500 | [diff] [blame] | 391 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 392 | * The proximity sensor which turns the screen off and back on during calls is the |
| 393 | * wake-up proximity sensor. Implement wake-up proximity sensor before implementing |
| 394 | * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag |
| 395 | * SENSOR_FLAG_WAKE_UP. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 396 | * The value corresponds to the distance to the nearest object in centimeters. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 397 | */ |
| 398 | #define SENSOR_TYPE_PROXIMITY (8) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 399 | #define SENSOR_STRING_TYPE_PROXIMITY "android.sensor.proximity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 400 | |
| 401 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 402 | * SENSOR_TYPE_GRAVITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 403 | * reporting-mode: continuous |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 404 | * |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 405 | * A gravity output indicates the direction of and magnitude of gravity in |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 406 | * the devices's coordinates. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 407 | * |
| 408 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 409 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 410 | */ |
| 411 | #define SENSOR_TYPE_GRAVITY (9) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 412 | #define SENSOR_STRING_TYPE_GRAVITY "android.sensor.gravity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 413 | |
| 414 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 415 | * SENSOR_TYPE_LINEAR_ACCELERATION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 416 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 417 | * |
| 418 | * Indicates the linear acceleration of the device in device coordinates, |
| 419 | * not including gravity. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 420 | * |
| 421 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 422 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 423 | */ |
| 424 | #define SENSOR_TYPE_LINEAR_ACCELERATION (10) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 425 | #define SENSOR_STRING_TYPE_LINEAR_ACCELERATION "android.sensor.linear_acceleration" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 426 | |
| 427 | |
| 428 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 429 | * SENSOR_TYPE_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 430 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 431 | * |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 432 | * The rotation vector symbolizes the orientation of the device relative to the |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 433 | * East-North-Up coordinates frame. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 434 | * |
| 435 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 436 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 437 | */ |
| 438 | #define SENSOR_TYPE_ROTATION_VECTOR (11) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 439 | #define SENSOR_STRING_TYPE_ROTATION_VECTOR "android.sensor.rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 440 | |
| 441 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 442 | * SENSOR_TYPE_RELATIVE_HUMIDITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 443 | * reporting-mode: on-change |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 444 | * |
| 445 | * A relative humidity sensor measures relative ambient air humidity and |
| 446 | * returns a value in percent. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 447 | * |
| 448 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 449 | */ |
| 450 | #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 451 | #define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY "android.sensor.relative_humidity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 452 | |
| 453 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 454 | * SENSOR_TYPE_AMBIENT_TEMPERATURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 455 | * reporting-mode: on-change |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 456 | * |
| 457 | * The ambient (room) temperature in degree Celsius. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 458 | * |
| 459 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 460 | */ |
| 461 | #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 462 | #define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE "android.sensor.ambient_temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 463 | |
| 464 | /* |
| 465 | * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 466 | * reporting-mode: continuous |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 467 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 468 | * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is |
| 469 | * reported separately instead of being included in the measurement. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 470 | * |
| 471 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 472 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 473 | */ |
| 474 | #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 475 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.magnetic_field_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 476 | |
| 477 | /* |
| 478 | * SENSOR_TYPE_GAME_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 479 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 480 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 481 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 482 | * field. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 483 | * |
| 484 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 485 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 486 | */ |
| 487 | #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 488 | #define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR "android.sensor.game_rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 489 | |
| 490 | /* |
| 491 | * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 492 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 493 | * |
| 494 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 495 | * around the X, Y and Z axis. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 496 | * |
| 497 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 498 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 499 | */ |
| 500 | #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 501 | #define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED "android.sensor.gyroscope_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 502 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 503 | /* |
| 504 | * SENSOR_TYPE_SIGNIFICANT_MOTION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 505 | * reporting-mode: one-shot |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 506 | * |
| 507 | * A sensor of this type triggers an event each time significant motion |
| 508 | * is detected and automatically disables itself. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 509 | * For Significant Motion sensor to be useful, it must be defined as a |
| 510 | * wake-up sensor. (set SENSOR_FLAG_WAKE_UP). Implement the wake-up significant motion |
| 511 | * sensor. A non wake-up version is not useful. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 512 | * The only allowed value to return is 1.0. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 513 | */ |
| 514 | |
| 515 | #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 516 | #define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION "android.sensor.significant_motion" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 517 | |
| 518 | /* |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 519 | * SENSOR_TYPE_STEP_DETECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 520 | * reporting-mode: special |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 521 | * |
| 522 | * A sensor of this type triggers an event each time a step is taken |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 523 | * by the user. The only allowed value to return is 1.0 and an event |
| 524 | * is generated for each step. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 525 | * |
| 526 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 527 | */ |
| 528 | |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 529 | #define SENSOR_TYPE_STEP_DETECTOR (18) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 530 | #define SENSOR_STRING_TYPE_STEP_DETECTOR "android.sensor.step_detector" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 531 | |
| 532 | |
| 533 | /* |
| 534 | * SENSOR_TYPE_STEP_COUNTER |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 535 | * reporting-mode: on-change |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 536 | * |
| 537 | * A sensor of this type returns the number of steps taken by the user since |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 538 | * the last reboot while activated. The value is returned as a uint64_t and is |
Etienne Le Grand | f770b7a | 2013-07-10 14:08:40 -0700 | [diff] [blame] | 539 | * reset to zero only on a system / android reboot. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 540 | * |
| 541 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 542 | * version if the system possesses a wake up fifo. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 543 | */ |
| 544 | |
| 545 | #define SENSOR_TYPE_STEP_COUNTER (19) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 546 | #define SENSOR_STRING_TYPE_STEP_COUNTER "android.sensor.step_counter" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 547 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 548 | /* |
| 549 | * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 550 | * reporting-mode: continuous |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 551 | * |
| 552 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead |
| 553 | * of using a gyroscope. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 554 | * |
| 555 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 556 | * version if the system possesses a wake up fifo. |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 557 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 558 | #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) |
| 559 | #define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.geomagnetic_rotation_vector" |
| 560 | |
| 561 | /* |
| 562 | * SENSOR_TYPE_HEART_RATE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 563 | * reporting-mode: on-change |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 564 | * |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 565 | * A sensor of this type returns the current heart rate. |
| 566 | * The events contain the current heart rate in beats per minute (BPM) and the |
| 567 | * status of the sensor during the measurement. See heart_rate_event_t for more |
| 568 | * details. |
| 569 | * |
| 570 | * Because this sensor is on-change, events must be generated when and only |
| 571 | * when heart_rate.bpm or heart_rate.status have changed since the last |
Vinod Krishnan | 74279e3 | 2014-08-28 15:25:13 -0700 | [diff] [blame] | 572 | * event. In particular, upon the first activation, unless the device is known |
| 573 | * to not be on the body, the status field of the first event must be set to |
| 574 | * SENSOR_STATUS_UNRELIABLE. The event should be generated no faster than every |
| 575 | * period_ns passed to setDelay() or to batch(). |
Griff Hazen | f0f67e6 | 2014-08-28 17:02:50 -0700 | [diff] [blame] | 576 | * See the definition of the on-change reporting mode for more information. |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 577 | * |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 578 | * sensor_t.requiredPermission must be set to SENSOR_PERMISSION_BODY_SENSORS. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 579 | * |
| 580 | * Both wake-up and non wake-up versions are useful. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 581 | */ |
| 582 | #define SENSOR_TYPE_HEART_RATE (21) |
| 583 | #define SENSOR_STRING_TYPE_HEART_RATE "android.sensor.heart_rate" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 584 | |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 585 | /* |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 586 | * SENSOR_TYPE_WAKE_UP_TILT_DETECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 587 | * reporting-mode: special (setDelay has no impact) |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 588 | * |
| 589 | * A sensor of this type generates an event each time a tilt event is detected. A tilt event |
| 590 | * should be generated if the direction of the 2-seconds window average gravity changed by at least |
Etienne Le Grand | 53017ef | 2014-05-28 15:42:48 -0700 | [diff] [blame] | 591 | * 35 degrees since the activation or the last trigger of the sensor. |
Etienne Le Grand | 426f14d | 2014-05-29 19:35:48 -0700 | [diff] [blame] | 592 | * reference_estimated_gravity = average of accelerometer measurements over the first |
Etienne Le Grand | 53017ef | 2014-05-28 15:42:48 -0700 | [diff] [blame] | 593 | * 1 second after activation or the estimated gravity at the last |
| 594 | * trigger. |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 595 | * current_estimated_gravity = average of accelerometer measurements over the last 2 seconds. |
Etienne Le Grand | 426f14d | 2014-05-29 19:35:48 -0700 | [diff] [blame] | 596 | * trigger when angle (reference_estimated_gravity, current_estimated_gravity) > 35 degrees |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 597 | * |
| 598 | * Large accelerations without a change in phone orientation should not trigger a tilt event. |
| 599 | * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt |
| 600 | * event, even though the angle of the average acceleration might vary by more than 35 degrees. |
| 601 | * |
| 602 | * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can |
| 603 | * be used as well if they do not increase the power consumption significantly. This is a low power |
| 604 | * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. |
| 605 | * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms |
| 606 | * while reporting this event. The only allowed return value is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 607 | * |
| 608 | * Implement only the wake-up version of this sensor. |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 609 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 610 | #define SENSOR_TYPE_TILT_DETECTOR (22) |
| 611 | #define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 612 | |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 613 | /* |
| 614 | * SENSOR_TYPE_WAKE_GESTURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 615 | * reporting-mode: one-shot |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 616 | * |
| 617 | * A sensor enabling waking up the device based on a device specific motion. |
| 618 | * |
| 619 | * When this sensor triggers, the device behaves as if the power button was |
| 620 | * pressed, turning the screen on. This behavior (turning on the screen when |
| 621 | * this sensor triggers) might be deactivated by the user in the device |
| 622 | * settings. Changes in settings do not impact the behavior of the sensor: |
| 623 | * only whether the framework turns the screen on when it triggers. |
| 624 | * |
| 625 | * The actual gesture to be detected is not specified, and can be chosen by |
| 626 | * the manufacturer of the device. |
| 627 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 628 | * The only allowed value to return is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 629 | * |
| 630 | * Implement only the wake-up version of this sensor. |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 631 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 632 | #define SENSOR_TYPE_WAKE_GESTURE (23) |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 633 | #define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" |
| 634 | |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 635 | /* |
| 636 | * SENSOR_TYPE_GLANCE_GESTURE |
| 637 | * reporting-mode: one-shot |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 638 | * |
| 639 | * A sensor enabling briefly turning the screen on to enable the user to |
| 640 | * glance content on screen based on a specific motion. The device should |
| 641 | * turn the screen off after a few moments. |
| 642 | * |
| 643 | * When this sensor triggers, the device turns the screen on momentarily |
| 644 | * to allow the user to glance notifications or other content while the |
| 645 | * device remains locked in a non-interactive state (dozing). This behavior |
| 646 | * (briefly turning on the screen when this sensor triggers) might be deactivated |
| 647 | * by the user in the device settings. Changes in settings do not impact the |
| 648 | * behavior of the sensor: only whether the framework briefly turns the screen on |
| 649 | * when it triggers. |
| 650 | * |
| 651 | * The actual gesture to be detected is not specified, and can be chosen by |
| 652 | * the manufacturer of the device. |
| 653 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 654 | * The only allowed value to return is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 655 | * |
| 656 | * Implement only the wake-up version of this sensor. |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 657 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 658 | #define SENSOR_TYPE_GLANCE_GESTURE (24) |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 659 | #define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" |
| 660 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 661 | /** |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 662 | * SENSOR_TYPE_PICK_UP_GESTURE |
| 663 | * reporting-mode: one-shot |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 664 | * |
| 665 | * A sensor of this type triggers when the device is picked up regardless of wherever is was |
| 666 | * before (desk, pocket, bag). The only allowed return value is 1.0. |
| 667 | * This sensor de-activates itself immediately after it triggers. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 668 | * |
| 669 | * Implement only the wake-up version of this sensor. |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 670 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 671 | #define SENSOR_TYPE_PICK_UP_GESTURE (25) |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 672 | #define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" |
| 673 | |
Nick Vaccaro | adbfbb7 | 2015-01-13 12:14:28 -0800 | [diff] [blame] | 674 | /* |
| 675 | * SENSOR_TYPE_WRIST_TILT_GESTURE |
| 676 | * trigger-mode: special |
| 677 | * wake-up sensor: yes |
| 678 | * |
| 679 | * A sensor of this type triggers an event each time a tilt of the wrist-worn |
| 680 | * device is detected. |
| 681 | * |
| 682 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 683 | * The only allowed value to return is 1.0. |
| 684 | * |
| 685 | * Implement only the wake-up version of this sensor. |
| 686 | */ |
| 687 | #define SENSOR_TYPE_WRIST_TILT_GESTURE (26) |
| 688 | #define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture" |
| 689 | |
Trevor Bunker | f8e7ed3 | 2016-01-08 10:22:23 -0800 | [diff] [blame] | 690 | /* |
| 691 | * SENSOR_TYPE_DEVICE_ORIENTATION |
| 692 | * reporting-mode: on-change |
| 693 | * |
| 694 | * The current orientation of the device. The value should be reported in the |
| 695 | * first element of the 'data' member variable in sensors_event_t. The only |
| 696 | * values that can be reported are (please refer to Android Sensor Coordinate |
| 697 | * System to understand the X and Y axis direction with respect to default |
| 698 | * orientation): |
| 699 | * - 0: device is in default orientation (Y axis is vertical and points up) |
| 700 | * - 1: device is rotated 90 degrees counter-clockwise from default |
| 701 | * orientation (X axis is vertical and points up) |
| 702 | * - 2: device is rotated 180 degrees from default orientation (Y axis is |
| 703 | * vertical and points down) |
| 704 | * - 3: device is rotated 90 degrees clockwise from default orientation (X axis |
| 705 | * is vertical and points down) |
| 706 | * |
| 707 | * Moving the device to an orientation where the Z axis is vertical (either up |
| 708 | * or down) should not cause a new event to be reported. |
| 709 | * |
| 710 | * To improve the user experience of this sensor, it is recommended to implement |
| 711 | * some physical (i.e., rotation angle) and temporal (i.e., delay) hysteresis. |
| 712 | * In other words, minor or transient rotations should not cause a new event to |
| 713 | * be reported. |
| 714 | * |
| 715 | * This sensor should only be implemented with the help of an accelerometer. |
| 716 | * This is a low power sensor that should reduce the number of interrupts of the |
| 717 | * AP. Do not emulate this sensor in the HAL. |
| 718 | * |
| 719 | * Both wake-up and non wake-up versions are useful. |
| 720 | */ |
| 721 | #define SENSOR_TYPE_DEVICE_ORIENTATION (27) |
| 722 | #define SENSOR_STRING_TYPE_DEVICE_ORIENTATION "android.sensor.device_orientation" |
| 723 | |
Ashutosh Joshi | ed021ea | 2016-01-14 22:28:24 -0800 | [diff] [blame] | 724 | /* |
| 725 | * SENSOR_TYPE_POSE_6DOF |
| 726 | * trigger-mode: continuous |
| 727 | * |
| 728 | * A sensor of this type returns the pose of the device. |
| 729 | * Pose of the device is defined as the orientation of the device from a |
| 730 | * Earth Centered Earth Fixed frame and the translation from an arbitrary |
| 731 | * point at subscription. |
| 732 | * |
| 733 | * This sensor can be high power. It can use any and all of the following |
| 734 | * . Accelerometer |
| 735 | * . Gyroscope |
| 736 | * . Camera |
| 737 | * . Depth Camera |
| 738 | * |
Ashutosh Joshi | ed021ea | 2016-01-14 22:28:24 -0800 | [diff] [blame] | 739 | */ |
| 740 | #define SENSOR_TYPE_POSE_6DOF (28) |
| 741 | #define SENSOR_STRING_TYPE_POSE_6DOF "android.sensor.pose_6dof" |
| 742 | |
Ashutosh Joshi | cb96331 | 2016-01-25 18:48:57 -0800 | [diff] [blame] | 743 | /* |
| 744 | * SENSOR_TYPE_STATIONARY_DETECT |
| 745 | * trigger mode: one shot |
| 746 | * |
| 747 | * A sensor of this type returns an event if the device is still/stationary for |
| 748 | * a while. The period of time to monitor for statinarity should be greater than |
| 749 | * 5 seconds, and less than 10 seconds. |
| 750 | * |
| 751 | * Stationarity here refers to absolute stationarity. eg: device on desk. |
| 752 | * |
| 753 | * The only allowed value to return is 1.0. |
| 754 | */ |
| 755 | #define SENSOR_TYPE_STATIONARY_DETECT (29) |
| 756 | #define SENSOR_STRING_TYPE_STATIONARY_DETECT "android.sensor.stationary_detect" |
| 757 | |
| 758 | /* |
| 759 | * SENSOR_TYPE_MOTION_DETECT |
| 760 | * trigger mode: one shot |
| 761 | * |
| 762 | * A sensor of this type returns an event if the device is not still for |
| 763 | * a while. The period of time to monitor for statinarity should be greater than |
| 764 | * 5 seconds, and less than 10 seconds. |
| 765 | * |
| 766 | * Motion here refers to any mechanism in which the device is causes to be |
| 767 | * moved in its inertial frame. eg: Pickin up the device and walking with it |
| 768 | * to a nearby room may trigger motion wherewas keeping the device on a table |
| 769 | * on a smooth train moving at constant velocity may not trigger motion. |
| 770 | * |
| 771 | * The only allowed value to return is 1.0. |
| 772 | */ |
| 773 | #define SENSOR_TYPE_MOTION_DETECT (30) |
| 774 | #define SENSOR_STRING_TYPE_MOTION_DETECT "android.sensor.motion_detect" |
| 775 | |
| 776 | /* |
| 777 | * SENSOR_TYPE_HEART_BEAT |
| 778 | * trigger mode: continuous |
| 779 | * |
| 780 | * A sensor of this type returns an event everytime a hear beat peak is |
| 781 | * detected. |
| 782 | * |
| 783 | * Peak here ideally corresponds to the positive peak in the QRS complex of |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 784 | * and ECG signal. |
Ashutosh Joshi | cb96331 | 2016-01-25 18:48:57 -0800 | [diff] [blame] | 785 | * |
| 786 | * The sensor is not expected to be optimized for latency. As a guide, a |
| 787 | * latency of up to 10 seconds is acceptable. However the timestamp attached |
| 788 | * to the event should be accurate and should correspond to the time the peak |
| 789 | * occured. |
| 790 | * |
| 791 | * The sensor event contains a parameter for the confidence in the detection |
| 792 | * of the peak where 0.0 represent no information at all, and 1.0 represents |
| 793 | * certainty. |
| 794 | */ |
| 795 | #define SENSOR_TYPE_HEART_BEAT (31) |
| 796 | #define SENSOR_STRING_TYPE_HEART_BEAT "android.sensor.heart_beat" |
| 797 | |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 798 | /** |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 799 | * SENSOR_TYPE_DYNAMIC_SENSOR_META |
| 800 | * trigger-mode: special |
| 801 | * |
| 802 | * A sensor event of this type is received when a dynamic sensor is added to or removed from the |
| 803 | * system. At most one sensor of this type can be present in one sensor HAL implementation and |
| 804 | * presence of a sensor of this type in sensor HAL implementation indicates that this sensor HAL |
| 805 | * supports dynamic sensor feature. Operations, such as batch, activate and setDelay, to this |
| 806 | * special purpose sensor should be treated as no-op and return successful. |
| 807 | * |
| 808 | * A dynamic sensor connection indicates connection of a physical device or instantiation of a |
| 809 | * virtual sensor backed by algorithm; and a dynamic sensor disconnection indicates the the |
| 810 | * opposite. A sensor event of SENSOR_TYPE_DYNAMIC_SENSOR_META type should be delivered regardless |
| 811 | * of the activation status of the sensor in the event of dynamic sensor connection and |
| 812 | * disconnection. In the sensor event, besides the common data entries, "dynamic_sensor_meta", which |
| 813 | * includes fields for connection status, handle of the sensor involved, pointer to sensor_t |
| 814 | * structure and a uuid field, should be populated. |
| 815 | * |
| 816 | * At a dynamic sensor connection event, fields of sensor_t structure referenced by a pointer in |
| 817 | * dynamic_sensor_meta should be filled as if it was regular sensors. Sensor HAL is responsible for |
| 818 | * recovery of memory if the corresponding data is dynamicially allocated. However, the the pointer |
| 819 | * must be valid until the first activate call to the sensor reported in this connection event. At a |
| 820 | * dynamic sensor disconnection, the sensor_t pointer should be NULL. |
| 821 | * |
| 822 | * The sensor handle assigned to dynamic sensors should never be the same as that of any regular |
| 823 | * static sensors, and should be unique until next boot. In another word, if a handle h is used for |
| 824 | * a dynamic sensor A, that same number cannot be used for the same dynamic sensor A or another |
| 825 | * dynamic sensor B even after disconnection of A until reboot. |
| 826 | * |
| 827 | * The UUID field will be used for identifying the sensor in addition to name, vendor and version |
| 828 | * and type. For physical sensors of the same model, all sensors will have the same values in |
| 829 | * sensor_t, but the UUID should be unique and persistent for each individual unit. An all zero UUID |
| 830 | * indicates it is not possible to differentiate individual sensor unit. |
| 831 | * |
| 832 | */ |
| 833 | #define SENSOR_TYPE_DYNAMIC_SENSOR_META (32) |
| 834 | #define SENSOR_STRING_TYPE_DYNAMIC_SENSOR_META "android.sensor.dynamic_sensor_meta" |
| 835 | |
| 836 | /** |
Peng Xu | 0743a5c | 2016-01-21 17:30:02 -0800 | [diff] [blame] | 837 | * SENSOR_TYPE_ADDITIONAL_INFO |
| 838 | * reporting-mode: N/A |
| 839 | * |
| 840 | * This sensor type is for delivering additional sensor information aside from sensor event data. |
| 841 | * Additional information may include sensor front-end group delay, internal calibration parameters, |
| 842 | * noise level metrics, device internal temperature, etc. |
| 843 | * |
| 844 | * This type will never bind to a sensor. In other words, no sensor in the sensor list should be of |
| 845 | * the type SENSOR_TYPE_ADDITIONAL_INFO. If a sensor HAL supports sensor additional information |
| 846 | * feature, it reports sensor_event_t with "sensor" field set to handle of the reporting sensor and |
| 847 | * "type" field set to SENSOR_TYPE_ADDITIONAL_INFO. Delivery of additional information events is |
| 848 | * triggered under two conditions: an enable activate() call or a flush() call to the corresponding |
| 849 | * sensor. |
| 850 | * |
| 851 | * A single additional information report consists of multiple frames. Sequences of these frames are |
| 852 | * ordered using timestamps, which means the timestamps of sequential frames have to be at least 1 |
| 853 | * nanosecond apart from each other. Each frame is a sensor_event_t delivered through the HAL |
| 854 | * interface, with related data stored in the "additional_info" field, which is of type |
| 855 | * additional_info_event_t. The "type" field of additional_info_event_t denotes the nature of the |
| 856 | * payload data (see additional_info_type_t). The "serial" field is used to keep the sequence of |
| 857 | * payload data that spans multiple frames. The first frame of the entire report is always of type |
| 858 | * AINFO_BEGIN, and the last frame is always AINFO_END. |
| 859 | * |
| 860 | * All additional information frames have to be delivered after flush complete event if flush() was |
| 861 | * triggering the report. |
| 862 | */ |
| 863 | #define SENSOR_TYPE_ADDITIONAL_INFO (33) |
| 864 | #define SENSOR_STRING_TYPE_ADDITIONAL_INFO "android.sensor.additional_info" |
| 865 | |
| 866 | /** |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 867 | * Values returned by the accelerometer in various locations in the universe. |
| 868 | * all values are in SI units (m/s^2) |
| 869 | */ |
| 870 | #define GRAVITY_SUN (275.0f) |
| 871 | #define GRAVITY_EARTH (9.80665f) |
| 872 | |
| 873 | /** Maximum magnetic field on Earth's surface */ |
| 874 | #define MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| 875 | |
| 876 | /** Minimum magnetic field on Earth's surface */ |
| 877 | #define MAGNETIC_FIELD_EARTH_MIN (30.0f) |
| 878 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 879 | /** |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 880 | * Possible values of the status field of sensor events. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 881 | */ |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 882 | #define SENSOR_STATUS_NO_CONTACT -1 |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 883 | #define SENSOR_STATUS_UNRELIABLE 0 |
| 884 | #define SENSOR_STATUS_ACCURACY_LOW 1 |
| 885 | #define SENSOR_STATUS_ACCURACY_MEDIUM 2 |
| 886 | #define SENSOR_STATUS_ACCURACY_HIGH 3 |
| 887 | |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 888 | |
| 889 | struct sensor_t; |
| 890 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 891 | /** |
| 892 | * sensor event data |
| 893 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 894 | typedef struct { |
| 895 | union { |
| 896 | float v[3]; |
| 897 | struct { |
| 898 | float x; |
| 899 | float y; |
| 900 | float z; |
| 901 | }; |
| 902 | struct { |
| 903 | float azimuth; |
| 904 | float pitch; |
| 905 | float roll; |
| 906 | }; |
| 907 | }; |
| 908 | int8_t status; |
| 909 | uint8_t reserved[3]; |
| 910 | } sensors_vec_t; |
| 911 | |
| 912 | /** |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 913 | * uncalibrated gyroscope and magnetometer event data |
| 914 | */ |
| 915 | typedef struct { |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 916 | union { |
| 917 | float uncalib[3]; |
| 918 | struct { |
| 919 | float x_uncalib; |
| 920 | float y_uncalib; |
| 921 | float z_uncalib; |
| 922 | }; |
| 923 | }; |
| 924 | union { |
| 925 | float bias[3]; |
| 926 | struct { |
| 927 | float x_bias; |
| 928 | float y_bias; |
| 929 | float z_bias; |
| 930 | }; |
| 931 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 932 | } uncalibrated_event_t; |
| 933 | |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 934 | /** |
| 935 | * Meta data event data |
| 936 | */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 937 | typedef struct meta_data_event { |
| 938 | int32_t what; |
| 939 | int32_t sensor; |
| 940 | } meta_data_event_t; |
| 941 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 942 | /** |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 943 | * Dynamic sensor meta event. See the description of SENSOR_TYPE_DYNAMIC_SENSOR_META type for |
| 944 | * details. |
| 945 | */ |
| 946 | typedef struct dynamic_sensor_meta_event { |
Peng Xu | e20707a | 2016-01-27 18:26:10 -0800 | [diff] [blame] | 947 | int32_t connected; |
| 948 | int32_t handle; |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 949 | const struct sensor_t * sensor; // should be NULL if connected == false |
Peng Xu | 69b5dba | 2016-04-22 22:34:51 -0700 | [diff] [blame] | 950 | uint8_t uuid[16]; // UUID of a dynamic sensor (using RFC 4122 byte order) |
| 951 | // For UUID 12345678-90AB-CDEF-1122-334455667788 the uuid field |
| 952 | // should be initialized as: |
| 953 | // {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x11, ...} |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 954 | } dynamic_sensor_meta_event_t; |
| 955 | |
| 956 | /** |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 957 | * Heart rate event data |
| 958 | */ |
| 959 | typedef struct { |
| 960 | // Heart rate in beats per minute. |
| 961 | // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT |
| 962 | float bpm; |
| 963 | // Status of the sensor for this reading. Set to one SENSOR_STATUS_... |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 964 | // Note that this value should only be set for sensors that explicitly define |
| 965 | // the meaning of this field. This field is not piped through the framework |
| 966 | // for other sensors. |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 967 | int8_t status; |
| 968 | } heart_rate_event_t; |
| 969 | |
Peng Xu | 0743a5c | 2016-01-21 17:30:02 -0800 | [diff] [blame] | 970 | typedef struct { |
| 971 | int32_t type; // type of payload data, see additional_info_type_t |
| 972 | int32_t serial; // sequence number of this frame for this type |
| 973 | union { |
| 974 | // for each frame, a single data type, either int32_t or float, should be used. |
| 975 | int32_t data_int32[14]; |
| 976 | float data_float[14]; |
| 977 | }; |
| 978 | } additional_info_event_t; |
| 979 | |
| 980 | typedef enum additional_info_type { |
| 981 | // |
| 982 | AINFO_BEGIN = 0x0, // Marks the beginning of additional information frames |
| 983 | AINFO_END = 0x1, // Marks the end of additional information frames |
| 984 | // Basic information |
| 985 | AINFO_UNTRACKED_DELAY = 0x10000, // Estimation of the delay that is not tracked by sensor |
| 986 | // timestamps. This includes delay introduced by |
| 987 | // sensor front-end filtering, data transport, etc. |
| 988 | // float[2]: delay in seconds |
| 989 | // standard deviation of estimated value |
| 990 | // |
| 991 | AINFO_INTERNAL_TEMPERATURE, // float: Celsius temperature. |
| 992 | // |
| 993 | AINFO_VEC3_CALIBRATION, // First three rows of a homogeneous matrix, which |
| 994 | // represents calibration to a three-element vector |
| 995 | // raw sensor reading. |
| 996 | // float[12]: 3x4 matrix in row major order |
| 997 | // |
| 998 | AINFO_SENSOR_PLACEMENT, // Location and orientation of sensor element in the |
| 999 | // device frame: origin is the geometric center of the |
| 1000 | // mobile device screen surface; the axis definition |
| 1001 | // corresponds to Android sensor definitions. |
| 1002 | // float[12]: 3x4 matrix in row major order |
| 1003 | // |
| 1004 | AINFO_SAMPLING, // float[2]: raw sample period in seconds, |
| 1005 | // standard deviation of sampling period |
| 1006 | |
| 1007 | // Sampling channel modeling information |
| 1008 | AINFO_CHANNEL_NOISE = 0x20000, // int32_t: noise type |
| 1009 | // float[n]: parameters |
| 1010 | // |
| 1011 | AINFO_CHANNEL_SAMPLER, // float[3]: sample period |
| 1012 | // standard deviation of sample period, |
| 1013 | // quantization unit |
| 1014 | // |
| 1015 | AINFO_CHANNEL_FILTER, // Represents a filter: |
| 1016 | // \sum_j a_j y[n-j] == \sum_i b_i x[n-i] |
| 1017 | // |
| 1018 | // int32_t[3]: number of feedforward coefficients, M, |
| 1019 | // number of feedback coefficients, N, for |
| 1020 | // FIR filter, N=1. |
| 1021 | // bit mask that represents which element to |
| 1022 | // which the filter is applied, bit 0 == 1 |
| 1023 | // means this filter applies to vector |
| 1024 | // element 0. |
| 1025 | // float[M+N]: filter coefficients (b0, b1, ..., BM-1), |
| 1026 | // then (a0, a1, ..., aN-1), a0 is always 1. |
| 1027 | // Multiple frames may be needed for higher |
| 1028 | // number of taps. |
| 1029 | // |
| 1030 | AINFO_CHANNEL_LINEAR_TRANSFORM, // int32_t[2]: size in (row, column) ... 1st frame |
| 1031 | // float[n]: matrix element values in row major order. |
| 1032 | // |
| 1033 | AINFO_CHANNEL_NONLINEAR_MAP, // int32_t[2]: extrapolate method |
| 1034 | // interpolate method |
| 1035 | // float[n]: mapping key points in pairs, (in, out)... |
| 1036 | // (may be used to model saturation) |
| 1037 | // |
| 1038 | AINFO_CHANNEL_RESAMPLER, // int32_t: resample method (0-th order, 1st order...) |
| 1039 | // float[1]: resample ratio (upsampling if < 1.0; |
| 1040 | // downsampling if > 1.0). |
| 1041 | // |
| 1042 | |
| 1043 | // Custom information |
| 1044 | AINFO_CUSTOM_START = 0x10000000, // |
| 1045 | // Debugging |
| 1046 | AINFO_DEBUGGING_START = 0x40000000, // |
| 1047 | } additional_info_type_t; |
| 1048 | |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 1049 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1050 | * Union of the various types of sensor data |
| 1051 | * that can be returned. |
| 1052 | */ |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1053 | typedef struct sensors_event_t { |
| 1054 | /* must be sizeof(struct sensors_event_t) */ |
| 1055 | int32_t version; |
| 1056 | |
| 1057 | /* sensor identifier */ |
| 1058 | int32_t sensor; |
| 1059 | |
| 1060 | /* sensor type */ |
| 1061 | int32_t type; |
| 1062 | |
| 1063 | /* reserved */ |
| 1064 | int32_t reserved0; |
| 1065 | |
| 1066 | /* time is in nanosecond */ |
| 1067 | int64_t timestamp; |
| 1068 | |
| 1069 | union { |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1070 | union { |
| 1071 | float data[16]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1072 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1073 | /* acceleration values are in meter per second per second (m/s^2) */ |
| 1074 | sensors_vec_t acceleration; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1075 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1076 | /* magnetic vector values are in micro-Tesla (uT) */ |
| 1077 | sensors_vec_t magnetic; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1078 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1079 | /* orientation values are in degrees */ |
| 1080 | sensors_vec_t orientation; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1081 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1082 | /* gyroscope values are in rad/s */ |
| 1083 | sensors_vec_t gyro; |
Makarand Karvekar | 3120b58 | 2010-08-11 15:10:10 -0700 | [diff] [blame] | 1084 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1085 | /* temperature is in degrees centigrade (Celsius) */ |
| 1086 | float temperature; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1087 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1088 | /* distance in centimeters */ |
| 1089 | float distance; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1090 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1091 | /* light in SI lux units */ |
| 1092 | float light; |
Mathias Agopian | 1832f55 | 2010-07-29 15:22:30 -0700 | [diff] [blame] | 1093 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1094 | /* pressure in hectopascal (hPa) */ |
| 1095 | float pressure; |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 1096 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1097 | /* relative humidity in percent */ |
| 1098 | float relative_humidity; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1099 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1100 | /* uncalibrated gyroscope values are in rad/s */ |
| 1101 | uncalibrated_event_t uncalibrated_gyro; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 1102 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1103 | /* uncalibrated magnetometer values are in micro-Teslas */ |
| 1104 | uncalibrated_event_t uncalibrated_magnetic; |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1105 | |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 1106 | /* heart rate data containing value in bpm and status */ |
| 1107 | heart_rate_event_t heart_rate; |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 1108 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1109 | /* this is a special event. see SENSOR_TYPE_META_DATA above. |
| 1110 | * sensors_meta_data_event_t events are all reported with a type of |
| 1111 | * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. |
| 1112 | */ |
| 1113 | meta_data_event_t meta_data; |
Peng Xu | e641ba9 | 2016-01-20 00:27:21 -0800 | [diff] [blame] | 1114 | |
| 1115 | /* dynamic sensor meta event. See SENSOR_TYPE_DYNAMIC_SENSOR_META type for details */ |
| 1116 | dynamic_sensor_meta_event_t dynamic_sensor_meta; |
Peng Xu | 0743a5c | 2016-01-21 17:30:02 -0800 | [diff] [blame] | 1117 | |
| 1118 | /* |
| 1119 | * special additional sensor information frame, see |
| 1120 | * SENSOR_TYPE_ADDITIONAL_INFO for details. |
| 1121 | */ |
| 1122 | additional_info_event_t additional_info; |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1123 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 1124 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 1125 | union { |
| 1126 | uint64_t data[8]; |
| 1127 | |
| 1128 | /* step-counter */ |
| 1129 | uint64_t step_counter; |
| 1130 | } u64; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1131 | }; |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 1132 | |
| 1133 | /* Reserved flags for internal use. Set to zero. */ |
| 1134 | uint32_t flags; |
| 1135 | |
| 1136 | uint32_t reserved1[3]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1137 | } sensors_event_t; |
| 1138 | |
| 1139 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1140 | /* see SENSOR_TYPE_META_DATA */ |
| 1141 | typedef sensors_event_t sensors_meta_data_event_t; |
| 1142 | |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1143 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1144 | /** |
| 1145 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 1146 | * and the fields of this data structure must begin with hw_module_t |
| 1147 | * followed by module specific information. |
| 1148 | */ |
| 1149 | struct sensors_module_t { |
| 1150 | struct hw_module_t common; |
| 1151 | |
| 1152 | /** |
| 1153 | * Enumerate all available sensors. The list is returned in "list". |
Colin Cross | 867e1e3 | 2016-10-06 16:44:46 -0700 | [diff] [blame] | 1154 | * return number of sensors in the list |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1155 | */ |
| 1156 | int (*get_sensors_list)(struct sensors_module_t* module, |
| 1157 | struct sensor_t const** list); |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 1158 | |
| 1159 | /** |
| 1160 | * Place the module in a specific mode. The following modes are defined |
| 1161 | * |
Ashutosh Joshi | 050f2e4 | 2015-04-15 13:56:53 -0700 | [diff] [blame] | 1162 | * 0 - Normal operation. Default state of the module. |
Peng Xu | 0743a5c | 2016-01-21 17:30:02 -0800 | [diff] [blame] | 1163 | * 1 - Loopback mode. Data is injected for the supported |
Ashutosh Joshi | 050f2e4 | 2015-04-15 13:56:53 -0700 | [diff] [blame] | 1164 | * sensors by the sensor service in this mode. |
Colin Cross | 867e1e3 | 2016-10-06 16:44:46 -0700 | [diff] [blame] | 1165 | * return 0 on success |
Ashutosh Joshi | 050f2e4 | 2015-04-15 13:56:53 -0700 | [diff] [blame] | 1166 | * -EINVAL if requested mode is not supported |
Aravind Akella | c7f5413 | 2015-06-22 18:26:54 -0700 | [diff] [blame] | 1167 | * -EPERM if operation is not allowed |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 1168 | */ |
| 1169 | int (*set_operation_mode)(unsigned int mode); |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1170 | }; |
| 1171 | |
| 1172 | struct sensor_t { |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 1173 | |
| 1174 | /* Name of this sensor. |
| 1175 | * All sensors of the same "type" must have a different "name". |
| 1176 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1177 | const char* name; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1178 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1179 | /* vendor of the hardware part */ |
| 1180 | const char* vendor; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1181 | |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 1182 | /* version of the hardware part + driver. The value of this field |
| 1183 | * must increase when the driver is updated in a way that changes the |
| 1184 | * output of this sensor. This is important for fused sensors when the |
| 1185 | * fusion algorithm is updated. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 1186 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1187 | int version; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1188 | |
| 1189 | /* handle that identifies this sensors. This handle is used to reference |
| 1190 | * this sensor throughout the HAL API. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1191 | */ |
| 1192 | int handle; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1193 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1194 | /* this sensor's type. */ |
| 1195 | int type; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1196 | |
| 1197 | /* maximum range of this sensor's value in SI units */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1198 | float maxRange; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1199 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1200 | /* smallest difference between two values reported by this sensor */ |
| 1201 | float resolution; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1202 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1203 | /* rough estimate of this sensor's power consumption in mA */ |
| 1204 | float power; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1205 | |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 1206 | /* this value depends on the reporting mode: |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1207 | * |
| 1208 | * continuous: minimum sample period allowed in microseconds |
| 1209 | * on-change : 0 |
| 1210 | * one-shot :-1 |
| 1211 | * special : 0, unless otherwise noted |
| 1212 | */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 1213 | int32_t minDelay; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1214 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1215 | /* number of events reserved for this sensor in the batch mode FIFO. |
| 1216 | * If there is a dedicated FIFO for this sensor, then this is the |
| 1217 | * size of this FIFO. If the FIFO is shared with other sensors, |
| 1218 | * this is the size reserved for that sensor and it can be zero. |
| 1219 | */ |
| 1220 | uint32_t fifoReservedEventCount; |
| 1221 | |
| 1222 | /* maximum number of events of this sensor that could be batched. |
| 1223 | * This is especially relevant when the FIFO is shared between |
| 1224 | * several sensors; this value is then set to the size of that FIFO. |
| 1225 | */ |
| 1226 | uint32_t fifoMaxEventCount; |
| 1227 | |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 1228 | /* type of this sensor as a string. Set to corresponding |
| 1229 | * SENSOR_STRING_TYPE_*. |
| 1230 | * When defining an OEM specific sensor or sensor manufacturer specific |
| 1231 | * sensor, use your reserve domain name as a prefix. |
| 1232 | * ex: com.google.glass.onheaddetector |
| 1233 | * For sensors of known type, the android framework might overwrite this |
| 1234 | * string automatically. |
| 1235 | */ |
| 1236 | const char* stringType; |
| 1237 | |
| 1238 | /* permission required to see this sensor, register to it and receive data. |
| 1239 | * Set to "" if no permission is required. Some sensor types like the |
| 1240 | * heart rate monitor have a mandatory require_permission. |
| 1241 | * For sensors that always require a specific permission, like the heart |
| 1242 | * rate monitor, the android framework might overwrite this string |
| 1243 | * automatically. |
| 1244 | */ |
| 1245 | const char* requiredPermission; |
| 1246 | |
Aravind Akella | 110d2f2 | 2014-09-04 15:36:31 -0700 | [diff] [blame] | 1247 | /* This value is defined only for continuous mode and on-change sensors. It is the delay between |
| 1248 | * two sensor events corresponding to the lowest frequency that this sensor supports. When lower |
| 1249 | * frequencies are requested through batch()/setDelay() the events will be generated at this |
| 1250 | * frequency instead. It can be used by the framework or applications to estimate when the batch |
| 1251 | * FIFO may be full. |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 1252 | * |
| 1253 | * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. |
Aravind Akella | 110d2f2 | 2014-09-04 15:36:31 -0700 | [diff] [blame] | 1254 | * continuous, on-change: maximum sampling period allowed in microseconds. |
| 1255 | * one-shot, special : 0 |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 1256 | * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit |
| 1257 | * on 64 bit architectures only for binary compatibility reasons. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 1258 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 1259 | */ |
| 1260 | #ifdef __LP64__ |
| 1261 | int64_t maxDelay; |
| 1262 | #else |
| 1263 | int32_t maxDelay; |
| 1264 | #endif |
| 1265 | |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 1266 | /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. |
| 1267 | * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. |
| 1268 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 1269 | */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 1270 | #ifdef __LP64__ |
| 1271 | uint64_t flags; |
| 1272 | #else |
| 1273 | uint32_t flags; |
| 1274 | #endif |
| 1275 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1276 | /* reserved fields, must be zero */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 1277 | void* reserved[2]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1278 | }; |
| 1279 | |
| 1280 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1281 | /* |
| 1282 | * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 |
| 1283 | * and is present for backward binary and source compatibility. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 1284 | * See the Sensors HAL interface section for complete descriptions of the |
| 1285 | * following functions: |
| 1286 | * http://source.android.com/devices/sensors/index.html#hal |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1287 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1288 | struct sensors_poll_device_t { |
| 1289 | struct hw_device_t common; |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1290 | int (*activate)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1291 | int sensor_handle, int enabled); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1292 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1293 | int sensor_handle, int64_t sampling_period_ns); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1294 | int (*poll)(struct sensors_poll_device_t *dev, |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 1295 | sensors_event_t* data, int count); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1296 | }; |
| 1297 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1298 | /* |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1299 | * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1300 | */ |
| 1301 | typedef struct sensors_poll_device_1 { |
| 1302 | union { |
| 1303 | /* sensors_poll_device_1 is compatible with sensors_poll_device_t, |
| 1304 | * and can be down-cast to it |
| 1305 | */ |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1306 | struct sensors_poll_device_t v0; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1307 | |
| 1308 | struct { |
| 1309 | struct hw_device_t common; |
| 1310 | |
Peng Xu | aaeeaa4 | 2016-10-05 14:56:54 -0700 | [diff] [blame] | 1311 | /* Activate/de-activate one sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1312 | * |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1313 | * sensor_handle is the handle of the sensor to change. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1314 | * enabled set to 1 to enable, or 0 to disable the sensor. |
| 1315 | * |
Peng Xu | aaeeaa4 | 2016-10-05 14:56:54 -0700 | [diff] [blame] | 1316 | * After sensor de-activation, existing sensor events that have not |
| 1317 | * been picked up by poll() should be abandoned immediately so that |
| 1318 | * subsequent activation will not get stale sensor events (events |
| 1319 | * that is generated prior to the latter activation). |
| 1320 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 1321 | * Return 0 on success, negative errno code otherwise. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1322 | */ |
| 1323 | int (*activate)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1324 | int sensor_handle, int enabled); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1325 | |
| 1326 | /** |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1327 | * Set the events's period in nanoseconds for a given sensor. |
| 1328 | * If sampling_period_ns > max_delay it will be truncated to |
| 1329 | * max_delay and if sampling_period_ns < min_delay it will be |
| 1330 | * replaced by min_delay. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1331 | */ |
| 1332 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1333 | int sensor_handle, int64_t sampling_period_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1334 | |
| 1335 | /** |
| 1336 | * Returns an array of sensor data. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1337 | */ |
| 1338 | int (*poll)(struct sensors_poll_device_t *dev, |
| 1339 | sensors_event_t* data, int count); |
| 1340 | }; |
| 1341 | }; |
| 1342 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1343 | |
| 1344 | /* |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1345 | * Sets a sensor’s parameters, including sampling frequency and maximum |
| 1346 | * report latency. This function can be called while the sensor is |
| 1347 | * activated, in which case it must not cause any sensor measurements to |
| 1348 | * be lost: transitioning from one sampling rate to the other cannot cause |
| 1349 | * lost events, nor can transitioning from a high maximum report latency to |
| 1350 | * a low maximum report latency. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 1351 | * See the Batching sensor results page for details: |
| 1352 | * http://source.android.com/devices/sensors/batching.html |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1353 | */ |
| 1354 | int (*batch)(struct sensors_poll_device_1* dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1355 | int sensor_handle, int flags, int64_t sampling_period_ns, |
| 1356 | int64_t max_report_latency_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1357 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1358 | /* |
| 1359 | * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) |
| 1360 | * to the end of the "batch mode" FIFO for the specified sensor and flushes |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1361 | * the FIFO. |
| 1362 | * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 1363 | * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1364 | * event stream. This applies to all sensors other than one-shot sensors. |
| 1365 | * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate |
| 1366 | * any flush complete metadata. |
Aravind Akella | a7f2cda | 2014-08-21 16:31:14 -0700 | [diff] [blame] | 1367 | * If the sensor is not active at the time flush() is called, flush() should return |
| 1368 | * -EINVAL. |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1369 | */ |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 1370 | int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 1371 | |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 1372 | /* |
Ashutosh Joshi | 050f2e4 | 2015-04-15 13:56:53 -0700 | [diff] [blame] | 1373 | * Inject a single sensor sample to be to this device. |
| 1374 | * data points to the sensor event to be injected |
Colin Cross | 867e1e3 | 2016-10-06 16:44:46 -0700 | [diff] [blame] | 1375 | * return 0 on success |
Aravind Akella | c7f5413 | 2015-06-22 18:26:54 -0700 | [diff] [blame] | 1376 | * -EPERM if operation is not allowed |
Ashutosh Joshi | 050f2e4 | 2015-04-15 13:56:53 -0700 | [diff] [blame] | 1377 | * -EINVAL if sensor event cannot be injected |
Ashutosh Joshi | 6507f50 | 2015-04-03 16:22:32 -0700 | [diff] [blame] | 1378 | */ |
| 1379 | int (*inject_sensor_data)(struct sensors_poll_device_1 *dev, const sensors_event_t *data); |
| 1380 | |
| 1381 | void (*reserved_procs[7])(void); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1382 | |
| 1383 | } sensors_poll_device_1_t; |
| 1384 | |
| 1385 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1386 | /** convenience API for opening and closing a device */ |
| 1387 | |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1388 | static inline int sensors_open(const struct hw_module_t* module, |
| 1389 | struct sensors_poll_device_t** device) { |
| 1390 | return module->methods->open(module, |
Colin Cross | cc8d9f9 | 2016-10-06 16:44:23 -0700 | [diff] [blame^] | 1391 | SENSORS_HARDWARE_POLL, TO_HW_DEVICE_T_OPEN(device)); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 1392 | } |
| 1393 | |
| 1394 | static inline int sensors_close(struct sensors_poll_device_t* device) { |
| 1395 | return device->common.close(&device->common); |
| 1396 | } |
| 1397 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1398 | static inline int sensors_open_1(const struct hw_module_t* module, |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1399 | sensors_poll_device_1_t** device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1400 | return module->methods->open(module, |
Colin Cross | cc8d9f9 | 2016-10-06 16:44:23 -0700 | [diff] [blame^] | 1401 | SENSORS_HARDWARE_POLL, TO_HW_DEVICE_T_OPEN(device)); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1402 | } |
| 1403 | |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1404 | static inline int sensors_close_1(sensors_poll_device_1_t* device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1405 | return device->common.close(&device->common); |
| 1406 | } |
| 1407 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1408 | __END_DECLS |
| 1409 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1410 | #endif // ANDROID_SENSORS_INTERFACE_H |