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) |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 38 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 39 | /** |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 40 | * Please see the Sensors section of source.android.com for an |
| 41 | * introduction to and detailed descriptions of Android sensor types: |
| 42 | * http://source.android.com/devices/sensors/index.html |
| 43 | */ |
| 44 | |
| 45 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 46 | * The id of this module |
| 47 | */ |
| 48 | #define SENSORS_HARDWARE_MODULE_ID "sensors" |
| 49 | |
| 50 | /** |
| 51 | * Name of the sensors device to open |
| 52 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 53 | #define SENSORS_HARDWARE_POLL "poll" |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. |
| 57 | * A Handle identifies a given sensors. The handle is used to activate |
| 58 | * and/or deactivate sensors. |
| 59 | * In this version of the API there can only be 256 handles. |
| 60 | */ |
| 61 | #define SENSORS_HANDLE_BASE 0 |
| 62 | #define SENSORS_HANDLE_BITS 8 |
| 63 | #define SENSORS_HANDLE_COUNT (1<<SENSORS_HANDLE_BITS) |
| 64 | |
| 65 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 66 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 67 | * **** Deprecated ***** |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 68 | * flags for (*batch)() |
| 69 | * Availability: SENSORS_DEVICE_API_VERSION_1_0 |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 70 | * see (*batch)() documentation for details. |
| 71 | * Deprecated as of SENSORS_DEVICE_API_VERSION_1_3. |
| 72 | * WAKE_UP_* sensors replace WAKE_UPON_FIFO_FULL concept. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 73 | */ |
| 74 | enum { |
| 75 | SENSORS_BATCH_DRY_RUN = 0x00000001, |
| 76 | SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 |
| 77 | }; |
| 78 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 79 | /* |
| 80 | * what field for meta_data_event_t |
| 81 | */ |
| 82 | enum { |
| 83 | /* a previous flush operation has completed */ |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 84 | META_DATA_FLUSH_COMPLETE = 1, |
| 85 | META_DATA_VERSION /* always last, leave auto-assigned */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 88 | /* |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 89 | * The permission to use for body sensors (like heart rate monitors). |
| 90 | * See sensor types for more details on what sensors should require this |
| 91 | * permission. |
| 92 | */ |
| 93 | #define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS" |
| 94 | |
| 95 | /* |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 96 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 97 | * Sensor flags used in sensor_t.flags. |
| 98 | */ |
| 99 | enum { |
| 100 | /* |
| 101 | * Whether this sensor wakes up the AP from suspend mode when data is available. |
| 102 | */ |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 103 | SENSOR_FLAG_WAKE_UP = 1U << 0, |
| 104 | /* |
| 105 | * Reporting modes for various sensors. Each sensor will have exactly one of these modes set. |
| 106 | * The least significant 2nd, 3rd and 4th bits are used to represent four possible reporting |
| 107 | * modes. |
| 108 | */ |
| 109 | SENSOR_FLAG_CONTINUOUS_MODE = 0, // 0000 |
| 110 | SENSOR_FLAG_ON_CHANGE_MODE = 0x2, // 0010 |
| 111 | SENSOR_FLAG_ONE_SHOT_MODE = 0x4, // 0100 |
| 112 | SENSOR_FLAG_SPECIAL_REPORTING_MODE = 0x6 // 0110 |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | /* |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 116 | * Mask and shift for reporting mode sensor flags defined above. |
| 117 | */ |
| 118 | #define REPORTING_MODE_MASK (0xE) |
| 119 | #define REPORTING_MODE_SHIFT (1) |
| 120 | |
| 121 | /* |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 122 | * Sensor type |
| 123 | * |
| 124 | * 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] | 125 | * measures are reported. See the Base sensors and Composite sensors lists |
| 126 | * for complete descriptions: |
| 127 | * http://source.android.com/devices/sensors/base_triggers.html |
| 128 | * http://source.android.com/devices/sensors/composite_sensors.html |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 129 | * |
| 130 | * Device manufacturers (OEMs) can define their own sensor types, for |
| 131 | * their private use by applications or services provided by them. Such |
| 132 | * sensor types are specific to an OEM and can't be exposed in the SDK. |
| 133 | * These types must start at SENSOR_TYPE_DEVICE_PRIVATE_BASE. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 134 | * |
| 135 | * All sensors defined outside of the device private range must correspond to |
| 136 | * a type defined in this file, and must satisfy the characteristics listed in |
| 137 | * the description of the sensor type. |
| 138 | * |
| 139 | * Starting with version SENSORS_DEVICE_API_VERSION_1_2, each sensor also |
| 140 | * has a stringType. |
| 141 | * - StringType of sensors inside of the device private range MUST be prefixed |
| 142 | * by the sensor provider's or OEM reverse domain name. In particular, they |
| 143 | * cannot use the "android.sensor" prefix. |
| 144 | * - StringType of sensors outside of the device private range MUST correspond |
| 145 | * to the one defined in this file (starting with "android.sensor"). |
| 146 | * For example, accelerometers must have |
| 147 | * type=SENSOR_TYPE_ACCELEROMETER and |
| 148 | * stringType=SENSOR_STRING_TYPE_ACCELEROMETER |
| 149 | * |
| 150 | * When android introduces a new sensor type that can replace an OEM-defined |
| 151 | * sensor type, the OEM must use the official sensor type and stringType on |
| 152 | * versions of the HAL that support this new official sensor type. |
| 153 | * |
| 154 | * Example (made up): Suppose Google's Glass team wants to surface a sensor |
| 155 | * detecting that Glass is on a head. |
| 156 | * - Such a sensor is not officially supported in android KitKat |
| 157 | * - Glass devices launching on KitKat can implement a sensor with |
| 158 | * type = 0x10001 and stringType = "com.google.glass.onheaddetector" |
| 159 | * - In L android release, if android decides to define |
| 160 | * SENSOR_TYPE_ON_HEAD_DETECTOR and STRING_SENSOR_TYPE_ON_HEAD_DETECTOR, |
| 161 | * those types should replace the Glass-team-specific types in all future |
| 162 | * launches. |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 163 | * - 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] | 164 | * type (SENSOR_TYPE_ON_HEAD_DETECTOR) and stringType. |
| 165 | * - This way, all applications can now use this sensor. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 166 | */ |
| 167 | |
| 168 | /* |
Mathias Agopian | 1599ec6 | 2013-08-19 14:34:47 -0700 | [diff] [blame] | 169 | * Base for device manufacturers private sensor types. |
| 170 | * These sensor types can't be exposed in the SDK. |
| 171 | */ |
| 172 | #define SENSOR_TYPE_DEVICE_PRIVATE_BASE 0x10000 |
| 173 | |
| 174 | /* |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 175 | * SENSOR_TYPE_META_DATA |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 176 | * reporting-mode: n/a |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 177 | * wake-up sensor: n/a |
| 178 | * |
| 179 | * NO SENSOR OF THAT TYPE MUST BE RETURNED (*get_sensors_list)() |
| 180 | * |
| 181 | * SENSOR_TYPE_META_DATA is a special token used to populate the |
| 182 | * sensors_meta_data_event structure. It doesn't correspond to a physical |
| 183 | * sensor. sensors_meta_data_event are special, they exist only inside |
| 184 | * the HAL and are generated spontaneously, as opposed to be related to |
| 185 | * a physical sensor. |
| 186 | * |
Mathias Agopian | af32a8d | 2013-08-06 20:33:38 -0700 | [diff] [blame] | 187 | * sensors_meta_data_event_t.version must be META_DATA_VERSION |
| 188 | * sensors_meta_data_event_t.sensor must be 0 |
| 189 | * sensors_meta_data_event_t.type must be SENSOR_TYPE_META_DATA |
| 190 | * sensors_meta_data_event_t.reserved must be 0 |
| 191 | * sensors_meta_data_event_t.timestamp must be 0 |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 192 | * |
| 193 | * The payload is a meta_data_event_t, where: |
| 194 | * meta_data_event_t.what can take the following values: |
| 195 | * |
| 196 | * META_DATA_FLUSH_COMPLETE |
| 197 | * This event indicates that a previous (*flush)() call has completed for the sensor |
| 198 | * handle specified in meta_data_event_t.sensor. |
| 199 | * see (*flush)() for more details |
| 200 | * |
| 201 | * All other values for meta_data_event_t.what are reserved and |
| 202 | * must not be used. |
| 203 | * |
| 204 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 205 | #define SENSOR_TYPE_META_DATA (0) |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 206 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 207 | /* |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 208 | * Wake up sensors. |
| 209 | * Each sensor may have either or both a wake-up and a non-wake variant. |
| 210 | * When registered in batch mode, wake-up sensors will wake up the AP when |
| 211 | * their FIFOs are full or when the batch timeout expires. A separate FIFO has |
| 212 | * to be maintained for wake up sensors and non wake up sensors. The non wake-up |
| 213 | * sensors need to overwrite their FIFOs when they are full till the AP wakes up |
| 214 | * and the wake-up sensors will wake-up the AP when their FIFOs are full or when |
| 215 | * the batch timeout expires without losing events. Wake-up and non wake-up variants |
| 216 | * of each sensor can be activated at different rates independently of each other. |
| 217 | * |
| 218 | * Note: Proximity sensor and significant motion sensor which were defined in previous |
| 219 | * releases are also wake-up sensors and should be treated as such. Wake-up one-shot |
| 220 | * sensors like SIGNIFICANT_MOTION cannot be batched, hence the text about batch above |
| 221 | * doesn't apply to them. See the definitions of SENSOR_TYPE_PROXIMITY and |
| 222 | * SENSOR_TYPE_SIGNIFICANT_MOTION for more info. |
| 223 | * |
| 224 | * Set SENSOR_FLAG_WAKE_UP flag for all wake-up sensors. |
| 225 | * |
| 226 | * For example, A device can have two sensors both of SENSOR_TYPE_ACCELEROMETER and |
| 227 | * one of them can be a wake_up sensor (with SENSOR_FLAG_WAKE_UP flag set) and the other |
| 228 | * can be a regular non wake_up sensor. Both of these sensors must be activated/deactivated |
| 229 | * independently of the other. |
| 230 | */ |
| 231 | |
| 232 | /* |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 233 | * SENSOR_TYPE_ACCELEROMETER |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 234 | * reporting-mode: continuous |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 235 | * |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 236 | * All values are in SI units (m/s^2) and measure the acceleration of the |
| 237 | * device minus the force of gravity. |
| 238 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 239 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 240 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 241 | */ |
| 242 | #define SENSOR_TYPE_ACCELEROMETER (1) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 243 | #define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 244 | |
| 245 | /* |
| 246 | * SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 247 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 248 | * |
| 249 | * All values are in micro-Tesla (uT) and measure the geomagnetic |
| 250 | * field in the X, Y and Z axis. |
| 251 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 252 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 253 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 254 | */ |
| 255 | #define SENSOR_TYPE_GEOMAGNETIC_FIELD (2) |
| 256 | #define SENSOR_TYPE_MAGNETIC_FIELD SENSOR_TYPE_GEOMAGNETIC_FIELD |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 257 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 258 | |
| 259 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 260 | * SENSOR_TYPE_ORIENTATION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 261 | * reporting-mode: continuous |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 262 | * |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 263 | * All values are angles in degrees. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 264 | * |
Mathias Agopian | 66a4095 | 2010-07-22 17:11:50 -0700 | [diff] [blame] | 265 | * Orientation sensors return sensor events for all 3 axes at a constant |
| 266 | * rate defined by setDelay(). |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 267 | * |
| 268 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 269 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 270 | */ |
| 271 | #define SENSOR_TYPE_ORIENTATION (3) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 272 | #define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 273 | |
| 274 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 275 | * SENSOR_TYPE_GYROSCOPE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 276 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 277 | * |
Kevin Powell | b01a043 | 2010-07-19 19:12:15 -0700 | [diff] [blame] | 278 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 279 | * around the X, Y and Z axis. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 280 | * |
| 281 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 282 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 283 | */ |
| 284 | #define SENSOR_TYPE_GYROSCOPE (4) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 285 | #define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 286 | |
| 287 | /* |
| 288 | * SENSOR_TYPE_LIGHT |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 289 | * reporting-mode: on-change |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 290 | * |
| 291 | * The light sensor value is returned in SI lux units. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 292 | * |
| 293 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 294 | */ |
| 295 | #define SENSOR_TYPE_LIGHT (5) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 296 | #define SENSOR_STRING_TYPE_LIGHT "android.sensor.light" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 297 | |
| 298 | /* |
| 299 | * SENSOR_TYPE_PRESSURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 300 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 301 | * |
| 302 | * The pressure sensor return the athmospheric pressure in hectopascal (hPa) |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 303 | * |
| 304 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 305 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 306 | */ |
| 307 | #define SENSOR_TYPE_PRESSURE (6) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 308 | #define SENSOR_STRING_TYPE_PRESSURE "android.sensor.pressure" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 309 | |
| 310 | /* SENSOR_TYPE_TEMPERATURE is deprecated in the HAL */ |
| 311 | #define SENSOR_TYPE_TEMPERATURE (7) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 312 | #define SENSOR_STRING_TYPE_TEMPERATURE "android.sensor.temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 313 | |
| 314 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 315 | * SENSOR_TYPE_PROXIMITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 316 | * reporting-mode: on-change |
Mike Lockwood | a241431 | 2009-11-03 10:29:50 -0500 | [diff] [blame] | 317 | * |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 318 | * The proximity sensor which turns the screen off and back on during calls is the |
| 319 | * wake-up proximity sensor. Implement wake-up proximity sensor before implementing |
| 320 | * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag |
| 321 | * SENSOR_FLAG_WAKE_UP. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 322 | * The value corresponds to the distance to the nearest object in centimeters. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 323 | */ |
| 324 | #define SENSOR_TYPE_PROXIMITY (8) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 325 | #define SENSOR_STRING_TYPE_PROXIMITY "android.sensor.proximity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 326 | |
| 327 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 328 | * SENSOR_TYPE_GRAVITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 329 | * reporting-mode: continuous |
Mathias Agopian | 42b743c | 2010-11-22 15:55:32 -0800 | [diff] [blame] | 330 | * |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 331 | * A gravity output indicates the direction of and magnitude of gravity in |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 332 | * the devices's coordinates. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 333 | * |
| 334 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 335 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 336 | */ |
| 337 | #define SENSOR_TYPE_GRAVITY (9) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 338 | #define SENSOR_STRING_TYPE_GRAVITY "android.sensor.gravity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 339 | |
| 340 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 341 | * SENSOR_TYPE_LINEAR_ACCELERATION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 342 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 343 | * |
| 344 | * Indicates the linear acceleration of the device in device coordinates, |
| 345 | * not including gravity. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 346 | * |
| 347 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 348 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 349 | */ |
| 350 | #define SENSOR_TYPE_LINEAR_ACCELERATION (10) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 351 | #define SENSOR_STRING_TYPE_LINEAR_ACCELERATION "android.sensor.linear_acceleration" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 352 | |
| 353 | |
| 354 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 355 | * SENSOR_TYPE_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 356 | * reporting-mode: continuous |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 357 | * |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 358 | * The rotation vector symbolizes the orientation of the device relative to the |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 359 | * East-North-Up coordinates frame. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 360 | * |
| 361 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 362 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 363 | */ |
| 364 | #define SENSOR_TYPE_ROTATION_VECTOR (11) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 365 | #define SENSOR_STRING_TYPE_ROTATION_VECTOR "android.sensor.rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 366 | |
| 367 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 368 | * SENSOR_TYPE_RELATIVE_HUMIDITY |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 369 | * reporting-mode: on-change |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 370 | * |
| 371 | * A relative humidity sensor measures relative ambient air humidity and |
| 372 | * returns a value in percent. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 373 | * |
| 374 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 375 | */ |
| 376 | #define SENSOR_TYPE_RELATIVE_HUMIDITY (12) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 377 | #define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY "android.sensor.relative_humidity" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 378 | |
| 379 | /* |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 380 | * SENSOR_TYPE_AMBIENT_TEMPERATURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 381 | * reporting-mode: on-change |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 382 | * |
| 383 | * The ambient (room) temperature in degree Celsius. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 384 | * |
| 385 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 386 | */ |
| 387 | #define SENSOR_TYPE_AMBIENT_TEMPERATURE (13) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 388 | #define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE "android.sensor.ambient_temperature" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 389 | |
| 390 | /* |
| 391 | * SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 392 | * reporting-mode: continuous |
Mathias Agopian | 54f9dd0 | 2011-03-22 18:42:03 -0700 | [diff] [blame] | 393 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 394 | * Similar to SENSOR_TYPE_MAGNETIC_FIELD, but the hard iron calibration is |
| 395 | * reported separately instead of being included in the measurement. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 396 | * |
| 397 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 398 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 399 | */ |
| 400 | #define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED (14) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 401 | #define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.magnetic_field_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 402 | |
| 403 | /* |
| 404 | * SENSOR_TYPE_GAME_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 405 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 406 | * |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 407 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but not using the geomagnetic |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 408 | * field. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 409 | * |
| 410 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 411 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 412 | */ |
| 413 | #define SENSOR_TYPE_GAME_ROTATION_VECTOR (15) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 414 | #define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR "android.sensor.game_rotation_vector" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 415 | |
| 416 | /* |
| 417 | * SENSOR_TYPE_GYROSCOPE_UNCALIBRATED |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 418 | * reporting-mode: continuous |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 419 | * |
| 420 | * All values are in radians/second and measure the rate of rotation |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 421 | * around the X, Y and Z axis. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 422 | * |
| 423 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 424 | * version if the system possesses a wake up fifo. |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 425 | */ |
| 426 | #define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 427 | #define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED "android.sensor.gyroscope_uncalibrated" |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 428 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 429 | /* |
| 430 | * SENSOR_TYPE_SIGNIFICANT_MOTION |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 431 | * reporting-mode: one-shot |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 432 | * |
| 433 | * A sensor of this type triggers an event each time significant motion |
| 434 | * is detected and automatically disables itself. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 435 | * For Significant Motion sensor to be useful, it must be defined as a |
| 436 | * wake-up sensor. (set SENSOR_FLAG_WAKE_UP). Implement the wake-up significant motion |
| 437 | * sensor. A non wake-up version is not useful. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 438 | * The only allowed value to return is 1.0. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 439 | */ |
| 440 | |
| 441 | #define SENSOR_TYPE_SIGNIFICANT_MOTION (17) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 442 | #define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION "android.sensor.significant_motion" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 443 | |
| 444 | /* |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 445 | * SENSOR_TYPE_STEP_DETECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 446 | * reporting-mode: special |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 447 | * |
| 448 | * 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] | 449 | * by the user. The only allowed value to return is 1.0 and an event |
| 450 | * is generated for each step. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 451 | * |
| 452 | * Both wake-up and non wake-up versions are useful. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 453 | */ |
| 454 | |
Mathias Agopian | 2f276f5 | 2013-01-28 17:54:41 -0800 | [diff] [blame] | 455 | #define SENSOR_TYPE_STEP_DETECTOR (18) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 456 | #define SENSOR_STRING_TYPE_STEP_DETECTOR "android.sensor.step_detector" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 457 | |
| 458 | |
| 459 | /* |
| 460 | * SENSOR_TYPE_STEP_COUNTER |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 461 | * reporting-mode: on-change |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 462 | * |
| 463 | * 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] | 464 | * 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] | 465 | * reset to zero only on a system / android reboot. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 466 | * |
| 467 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 468 | * version if the system possesses a wake up fifo. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 469 | */ |
| 470 | |
| 471 | #define SENSOR_TYPE_STEP_COUNTER (19) |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 472 | #define SENSOR_STRING_TYPE_STEP_COUNTER "android.sensor.step_counter" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 473 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 474 | /* |
| 475 | * SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 476 | * reporting-mode: continuous |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 477 | * |
| 478 | * Similar to SENSOR_TYPE_ROTATION_VECTOR, but using a magnetometer instead |
| 479 | * of using a gyroscope. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 480 | * |
| 481 | * Implement the non-wake-up version of this sensor and implement the wake-up |
| 482 | * version if the system possesses a wake up fifo. |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 483 | */ |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 484 | #define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20) |
| 485 | #define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.geomagnetic_rotation_vector" |
| 486 | |
| 487 | /* |
| 488 | * SENSOR_TYPE_HEART_RATE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 489 | * reporting-mode: on-change |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 490 | * |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 491 | * A sensor of this type returns the current heart rate. |
| 492 | * The events contain the current heart rate in beats per minute (BPM) and the |
| 493 | * status of the sensor during the measurement. See heart_rate_event_t for more |
| 494 | * details. |
| 495 | * |
| 496 | * Because this sensor is on-change, events must be generated when and only |
| 497 | * 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] | 498 | * event. In particular, upon the first activation, unless the device is known |
| 499 | * to not be on the body, the status field of the first event must be set to |
| 500 | * SENSOR_STATUS_UNRELIABLE. The event should be generated no faster than every |
| 501 | * period_ns passed to setDelay() or to batch(). |
Griff Hazen | f0f67e6 | 2014-08-28 17:02:50 -0700 | [diff] [blame^] | 502 | * 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] | 503 | * |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 504 | * sensor_t.requiredPermission must be set to SENSOR_PERMISSION_BODY_SENSORS. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 505 | * |
| 506 | * Both wake-up and non wake-up versions are useful. |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 507 | */ |
| 508 | #define SENSOR_TYPE_HEART_RATE (21) |
| 509 | #define SENSOR_STRING_TYPE_HEART_RATE "android.sensor.heart_rate" |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 510 | |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 511 | /* |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 512 | * SENSOR_TYPE_WAKE_UP_TILT_DETECTOR |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 513 | * reporting-mode: special (setDelay has no impact) |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 514 | * |
| 515 | * A sensor of this type generates an event each time a tilt event is detected. A tilt event |
| 516 | * 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] | 517 | * 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] | 518 | * reference_estimated_gravity = average of accelerometer measurements over the first |
Etienne Le Grand | 53017ef | 2014-05-28 15:42:48 -0700 | [diff] [blame] | 519 | * 1 second after activation or the estimated gravity at the last |
| 520 | * trigger. |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 521 | * 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] | 522 | * trigger when angle (reference_estimated_gravity, current_estimated_gravity) > 35 degrees |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 523 | * |
| 524 | * Large accelerations without a change in phone orientation should not trigger a tilt event. |
| 525 | * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt |
| 526 | * event, even though the angle of the average acceleration might vary by more than 35 degrees. |
| 527 | * |
| 528 | * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can |
| 529 | * be used as well if they do not increase the power consumption significantly. This is a low power |
| 530 | * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. |
| 531 | * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms |
| 532 | * while reporting this event. The only allowed return value is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 533 | * |
| 534 | * Implement only the wake-up version of this sensor. |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 535 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 536 | #define SENSOR_TYPE_TILT_DETECTOR (22) |
| 537 | #define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" |
Aravind Akella | f895c68 | 2014-04-30 11:46:09 -0700 | [diff] [blame] | 538 | |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 539 | /* |
| 540 | * SENSOR_TYPE_WAKE_GESTURE |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 541 | * reporting-mode: one-shot |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 542 | * |
| 543 | * A sensor enabling waking up the device based on a device specific motion. |
| 544 | * |
| 545 | * When this sensor triggers, the device behaves as if the power button was |
| 546 | * pressed, turning the screen on. This behavior (turning on the screen when |
| 547 | * this sensor triggers) might be deactivated by the user in the device |
| 548 | * settings. Changes in settings do not impact the behavior of the sensor: |
| 549 | * only whether the framework turns the screen on when it triggers. |
| 550 | * |
| 551 | * The actual gesture to be detected is not specified, and can be chosen by |
| 552 | * the manufacturer of the device. |
| 553 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 554 | * The only allowed value to return is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 555 | * |
| 556 | * Implement only the wake-up version of this sensor. |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 557 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 558 | #define SENSOR_TYPE_WAKE_GESTURE (23) |
Etienne Le Grand | ba12312 | 2014-05-05 18:20:42 -0700 | [diff] [blame] | 559 | #define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" |
| 560 | |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 561 | /* |
| 562 | * SENSOR_TYPE_GLANCE_GESTURE |
| 563 | * reporting-mode: one-shot |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 564 | * |
| 565 | * A sensor enabling briefly turning the screen on to enable the user to |
| 566 | * glance content on screen based on a specific motion. The device should |
| 567 | * turn the screen off after a few moments. |
| 568 | * |
| 569 | * When this sensor triggers, the device turns the screen on momentarily |
| 570 | * to allow the user to glance notifications or other content while the |
| 571 | * device remains locked in a non-interactive state (dozing). This behavior |
| 572 | * (briefly turning on the screen when this sensor triggers) might be deactivated |
| 573 | * by the user in the device settings. Changes in settings do not impact the |
| 574 | * behavior of the sensor: only whether the framework briefly turns the screen on |
| 575 | * when it triggers. |
| 576 | * |
| 577 | * The actual gesture to be detected is not specified, and can be chosen by |
| 578 | * the manufacturer of the device. |
| 579 | * This sensor must be low power, as it is likely to be activated 24/7. |
| 580 | * The only allowed value to return is 1.0. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 581 | * |
| 582 | * Implement only the wake-up version of this sensor. |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 583 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 584 | #define SENSOR_TYPE_GLANCE_GESTURE (24) |
Jeff Brown | 8df2feb | 2014-07-17 15:11:51 -0700 | [diff] [blame] | 585 | #define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" |
| 586 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 587 | /** |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 588 | * SENSOR_TYPE_PICK_UP_GESTURE |
| 589 | * reporting-mode: one-shot |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 590 | * |
| 591 | * A sensor of this type triggers when the device is picked up regardless of wherever is was |
| 592 | * before (desk, pocket, bag). The only allowed return value is 1.0. |
| 593 | * This sensor de-activates itself immediately after it triggers. |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 594 | * |
| 595 | * Implement only the wake-up version of this sensor. |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 596 | */ |
Aravind Akella | 9057e12 | 2014-07-28 18:01:37 -0700 | [diff] [blame] | 597 | #define SENSOR_TYPE_PICK_UP_GESTURE (25) |
Aravind Akella | 952471e | 2014-07-17 12:40:54 -0700 | [diff] [blame] | 598 | #define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" |
| 599 | |
| 600 | /** |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 601 | * Values returned by the accelerometer in various locations in the universe. |
| 602 | * all values are in SI units (m/s^2) |
| 603 | */ |
| 604 | #define GRAVITY_SUN (275.0f) |
| 605 | #define GRAVITY_EARTH (9.80665f) |
| 606 | |
| 607 | /** Maximum magnetic field on Earth's surface */ |
| 608 | #define MAGNETIC_FIELD_EARTH_MAX (60.0f) |
| 609 | |
| 610 | /** Minimum magnetic field on Earth's surface */ |
| 611 | #define MAGNETIC_FIELD_EARTH_MIN (30.0f) |
| 612 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 613 | /** |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 614 | * Possible values of the status field of sensor events. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 615 | */ |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 616 | #define SENSOR_STATUS_NO_CONTACT -1 |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 617 | #define SENSOR_STATUS_UNRELIABLE 0 |
| 618 | #define SENSOR_STATUS_ACCURACY_LOW 1 |
| 619 | #define SENSOR_STATUS_ACCURACY_MEDIUM 2 |
| 620 | #define SENSOR_STATUS_ACCURACY_HIGH 3 |
| 621 | |
Mathias Agopian | 56f66cc | 2012-11-08 15:57:38 -0800 | [diff] [blame] | 622 | /** |
| 623 | * sensor event data |
| 624 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 625 | typedef struct { |
| 626 | union { |
| 627 | float v[3]; |
| 628 | struct { |
| 629 | float x; |
| 630 | float y; |
| 631 | float z; |
| 632 | }; |
| 633 | struct { |
| 634 | float azimuth; |
| 635 | float pitch; |
| 636 | float roll; |
| 637 | }; |
| 638 | }; |
| 639 | int8_t status; |
| 640 | uint8_t reserved[3]; |
| 641 | } sensors_vec_t; |
| 642 | |
| 643 | /** |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 644 | * uncalibrated gyroscope and magnetometer event data |
| 645 | */ |
| 646 | typedef struct { |
Etienne Le Grand | 28f0411 | 2013-03-27 18:59:10 -0700 | [diff] [blame] | 647 | union { |
| 648 | float uncalib[3]; |
| 649 | struct { |
| 650 | float x_uncalib; |
| 651 | float y_uncalib; |
| 652 | float z_uncalib; |
| 653 | }; |
| 654 | }; |
| 655 | union { |
| 656 | float bias[3]; |
| 657 | struct { |
| 658 | float x_bias; |
| 659 | float y_bias; |
| 660 | float z_bias; |
| 661 | }; |
| 662 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 663 | } uncalibrated_event_t; |
| 664 | |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 665 | /** |
| 666 | * Meta data event data |
| 667 | */ |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 668 | typedef struct meta_data_event { |
| 669 | int32_t what; |
| 670 | int32_t sensor; |
| 671 | } meta_data_event_t; |
| 672 | |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 673 | /** |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 674 | * Heart rate event data |
| 675 | */ |
| 676 | typedef struct { |
| 677 | // Heart rate in beats per minute. |
| 678 | // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT |
| 679 | float bpm; |
| 680 | // 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] | 681 | // Note that this value should only be set for sensors that explicitly define |
| 682 | // the meaning of this field. This field is not piped through the framework |
| 683 | // for other sensors. |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 684 | int8_t status; |
| 685 | } heart_rate_event_t; |
| 686 | |
| 687 | /** |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 688 | * Union of the various types of sensor data |
| 689 | * that can be returned. |
| 690 | */ |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 691 | typedef struct sensors_event_t { |
| 692 | /* must be sizeof(struct sensors_event_t) */ |
| 693 | int32_t version; |
| 694 | |
| 695 | /* sensor identifier */ |
| 696 | int32_t sensor; |
| 697 | |
| 698 | /* sensor type */ |
| 699 | int32_t type; |
| 700 | |
| 701 | /* reserved */ |
| 702 | int32_t reserved0; |
| 703 | |
| 704 | /* time is in nanosecond */ |
| 705 | int64_t timestamp; |
| 706 | |
| 707 | union { |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 708 | union { |
| 709 | float data[16]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 710 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 711 | /* acceleration values are in meter per second per second (m/s^2) */ |
| 712 | sensors_vec_t acceleration; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 713 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 714 | /* magnetic vector values are in micro-Tesla (uT) */ |
| 715 | sensors_vec_t magnetic; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 716 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 717 | /* orientation values are in degrees */ |
| 718 | sensors_vec_t orientation; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 719 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 720 | /* gyroscope values are in rad/s */ |
| 721 | sensors_vec_t gyro; |
Makarand Karvekar | 3120b58 | 2010-08-11 15:10:10 -0700 | [diff] [blame] | 722 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 723 | /* temperature is in degrees centigrade (Celsius) */ |
| 724 | float temperature; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 725 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 726 | /* distance in centimeters */ |
| 727 | float distance; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 728 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 729 | /* light in SI lux units */ |
| 730 | float light; |
Mathias Agopian | 1832f55 | 2010-07-29 15:22:30 -0700 | [diff] [blame] | 731 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 732 | /* pressure in hectopascal (hPa) */ |
| 733 | float pressure; |
Urs Fleisch | d2ed15a | 2010-12-29 17:00:33 +0100 | [diff] [blame] | 734 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 735 | /* relative humidity in percent */ |
| 736 | float relative_humidity; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 737 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 738 | /* uncalibrated gyroscope values are in rad/s */ |
| 739 | uncalibrated_event_t uncalibrated_gyro; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 740 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 741 | /* uncalibrated magnetometer values are in micro-Teslas */ |
| 742 | uncalibrated_event_t uncalibrated_magnetic; |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 743 | |
Etienne Le Grand | 7b36158 | 2014-05-16 11:08:28 -0700 | [diff] [blame] | 744 | /* heart rate data containing value in bpm and status */ |
| 745 | heart_rate_event_t heart_rate; |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 746 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 747 | /* this is a special event. see SENSOR_TYPE_META_DATA above. |
| 748 | * sensors_meta_data_event_t events are all reported with a type of |
| 749 | * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. |
| 750 | */ |
| 751 | meta_data_event_t meta_data; |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 752 | }; |
Etienne Le Grand | ca85814 | 2013-02-26 19:17:20 -0800 | [diff] [blame] | 753 | |
Mathias Agopian | 27e1668 | 2013-07-08 14:00:54 -0700 | [diff] [blame] | 754 | union { |
| 755 | uint64_t data[8]; |
| 756 | |
| 757 | /* step-counter */ |
| 758 | uint64_t step_counter; |
| 759 | } u64; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 760 | }; |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 761 | |
| 762 | /* Reserved flags for internal use. Set to zero. */ |
| 763 | uint32_t flags; |
| 764 | |
| 765 | uint32_t reserved1[3]; |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 766 | } sensors_event_t; |
| 767 | |
| 768 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 769 | /* see SENSOR_TYPE_META_DATA */ |
| 770 | typedef sensors_event_t sensors_meta_data_event_t; |
| 771 | |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 772 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 773 | struct sensor_t; |
| 774 | |
| 775 | /** |
| 776 | * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM |
| 777 | * and the fields of this data structure must begin with hw_module_t |
| 778 | * followed by module specific information. |
| 779 | */ |
| 780 | struct sensors_module_t { |
| 781 | struct hw_module_t common; |
| 782 | |
| 783 | /** |
| 784 | * Enumerate all available sensors. The list is returned in "list". |
| 785 | * @return number of sensors in the list |
| 786 | */ |
| 787 | int (*get_sensors_list)(struct sensors_module_t* module, |
| 788 | struct sensor_t const** list); |
| 789 | }; |
| 790 | |
| 791 | struct sensor_t { |
Mathias Agopian | 1144bea | 2013-01-29 15:52:10 -0800 | [diff] [blame] | 792 | |
| 793 | /* Name of this sensor. |
| 794 | * All sensors of the same "type" must have a different "name". |
| 795 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 796 | const char* name; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 797 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 798 | /* vendor of the hardware part */ |
| 799 | const char* vendor; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 800 | |
Mathias Agopian | e9eaf37 | 2011-11-07 21:32:34 -0800 | [diff] [blame] | 801 | /* version of the hardware part + driver. The value of this field |
| 802 | * must increase when the driver is updated in a way that changes the |
| 803 | * output of this sensor. This is important for fused sensors when the |
| 804 | * fusion algorithm is updated. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 805 | */ |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 806 | int version; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 807 | |
| 808 | /* handle that identifies this sensors. This handle is used to reference |
| 809 | * this sensor throughout the HAL API. |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 810 | */ |
| 811 | int handle; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 812 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 813 | /* this sensor's type. */ |
| 814 | int type; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 815 | |
| 816 | /* 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] | 817 | float maxRange; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 818 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 819 | /* smallest difference between two values reported by this sensor */ |
| 820 | float resolution; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 821 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 822 | /* rough estimate of this sensor's power consumption in mA */ |
| 823 | float power; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 824 | |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 825 | /* this value depends on the reporting mode: |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 826 | * |
| 827 | * continuous: minimum sample period allowed in microseconds |
| 828 | * on-change : 0 |
| 829 | * one-shot :-1 |
| 830 | * special : 0, unless otherwise noted |
| 831 | */ |
Mathias Agopian | 1511e20 | 2010-07-29 15:33:22 -0700 | [diff] [blame] | 832 | int32_t minDelay; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 833 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 834 | /* number of events reserved for this sensor in the batch mode FIFO. |
| 835 | * If there is a dedicated FIFO for this sensor, then this is the |
| 836 | * size of this FIFO. If the FIFO is shared with other sensors, |
| 837 | * this is the size reserved for that sensor and it can be zero. |
| 838 | */ |
| 839 | uint32_t fifoReservedEventCount; |
| 840 | |
| 841 | /* maximum number of events of this sensor that could be batched. |
| 842 | * This is especially relevant when the FIFO is shared between |
| 843 | * several sensors; this value is then set to the size of that FIFO. |
| 844 | */ |
| 845 | uint32_t fifoMaxEventCount; |
| 846 | |
Aravind Akella | 477fbd5 | 2014-04-07 22:46:01 +0000 | [diff] [blame] | 847 | /* type of this sensor as a string. Set to corresponding |
| 848 | * SENSOR_STRING_TYPE_*. |
| 849 | * When defining an OEM specific sensor or sensor manufacturer specific |
| 850 | * sensor, use your reserve domain name as a prefix. |
| 851 | * ex: com.google.glass.onheaddetector |
| 852 | * For sensors of known type, the android framework might overwrite this |
| 853 | * string automatically. |
| 854 | */ |
| 855 | const char* stringType; |
| 856 | |
| 857 | /* permission required to see this sensor, register to it and receive data. |
| 858 | * Set to "" if no permission is required. Some sensor types like the |
| 859 | * heart rate monitor have a mandatory require_permission. |
| 860 | * For sensors that always require a specific permission, like the heart |
| 861 | * rate monitor, the android framework might overwrite this string |
| 862 | * automatically. |
| 863 | */ |
| 864 | const char* requiredPermission; |
| 865 | |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 866 | /* This value is defined only for continuous mode sensors. It is the delay between two |
| 867 | * sensor events corresponding to the lowest frequency that this sensor supports. When |
| 868 | * lower frequencies are requested through batch()/setDelay() the events will be generated |
| 869 | * at this frequency instead. It can be used by the framework or applications to estimate |
| 870 | * when the batch FIFO may be full. |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 871 | * |
| 872 | * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. |
| 873 | * continuous: maximum sampling period allowed in microseconds. |
| 874 | * on-change, one-shot, special : 0 |
| 875 | * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit |
| 876 | * on 64 bit architectures only for binary compatibility reasons. |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 877 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 878 | */ |
| 879 | #ifdef __LP64__ |
| 880 | int64_t maxDelay; |
| 881 | #else |
| 882 | int32_t maxDelay; |
| 883 | #endif |
| 884 | |
Aravind Akella | c841efd | 2014-06-03 19:21:35 -0700 | [diff] [blame] | 885 | /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. |
| 886 | * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. |
| 887 | * Availability: SENSORS_DEVICE_API_VERSION_1_3 |
| 888 | */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 889 | #ifdef __LP64__ |
| 890 | uint64_t flags; |
| 891 | #else |
| 892 | uint32_t flags; |
| 893 | #endif |
| 894 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 895 | /* reserved fields, must be zero */ |
Aravind Akella | 6242f32 | 2014-02-28 18:46:19 -0800 | [diff] [blame] | 896 | void* reserved[2]; |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 897 | }; |
| 898 | |
| 899 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 900 | /* |
| 901 | * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 |
| 902 | * and is present for backward binary and source compatibility. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 903 | * See the Sensors HAL interface section for complete descriptions of the |
| 904 | * following functions: |
| 905 | * http://source.android.com/devices/sensors/index.html#hal |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 906 | */ |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 907 | struct sensors_poll_device_t { |
| 908 | struct hw_device_t common; |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 909 | int (*activate)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 910 | int sensor_handle, int enabled); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 911 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 912 | int sensor_handle, int64_t sampling_period_ns); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 913 | int (*poll)(struct sensors_poll_device_t *dev, |
Mathias Agopian | cdefccd | 2010-07-15 18:29:03 -0700 | [diff] [blame] | 914 | sensors_event_t* data, int count); |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 915 | }; |
| 916 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 917 | /* |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 918 | * 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] | 919 | */ |
| 920 | typedef struct sensors_poll_device_1 { |
| 921 | union { |
| 922 | /* sensors_poll_device_1 is compatible with sensors_poll_device_t, |
| 923 | * and can be down-cast to it |
| 924 | */ |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 925 | struct sensors_poll_device_t v0; |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 926 | |
| 927 | struct { |
| 928 | struct hw_device_t common; |
| 929 | |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 930 | /* Activate/de-activate one sensor. Return 0 on success, negative |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 931 | * |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 932 | * sensor_handle is the handle of the sensor to change. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 933 | * enabled set to 1 to enable, or 0 to disable the sensor. |
| 934 | * |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 935 | * Return 0 on success, negative errno code otherwise. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 936 | */ |
| 937 | int (*activate)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 938 | int sensor_handle, int enabled); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 939 | |
| 940 | /** |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 941 | * Set the events's period in nanoseconds for a given sensor. |
| 942 | * If sampling_period_ns > max_delay it will be truncated to |
| 943 | * max_delay and if sampling_period_ns < min_delay it will be |
| 944 | * replaced by min_delay. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 945 | */ |
| 946 | int (*setDelay)(struct sensors_poll_device_t *dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 947 | int sensor_handle, int64_t sampling_period_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 948 | |
| 949 | /** |
| 950 | * Returns an array of sensor data. |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 951 | */ |
| 952 | int (*poll)(struct sensors_poll_device_t *dev, |
| 953 | sensors_event_t* data, int count); |
| 954 | }; |
| 955 | }; |
| 956 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 957 | |
| 958 | /* |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 959 | * Sets a sensor’s parameters, including sampling frequency and maximum |
| 960 | * report latency. This function can be called while the sensor is |
| 961 | * activated, in which case it must not cause any sensor measurements to |
| 962 | * be lost: transitioning from one sampling rate to the other cannot cause |
| 963 | * lost events, nor can transitioning from a high maximum report latency to |
| 964 | * a low maximum report latency. |
Clay Murphy | 8db1fb4 | 2013-12-19 09:58:28 -0800 | [diff] [blame] | 965 | * See the Batching sensor results page for details: |
| 966 | * http://source.android.com/devices/sensors/batching.html |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 967 | */ |
| 968 | int (*batch)(struct sensors_poll_device_1* dev, |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 969 | int sensor_handle, int flags, int64_t sampling_period_ns, |
| 970 | int64_t max_report_latency_ns); |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 971 | |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 972 | /* |
| 973 | * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) |
| 974 | * 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] | 975 | * the FIFO. |
| 976 | * 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] | 977 | * 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] | 978 | * event stream. This applies to all sensors other than one-shot sensors. |
| 979 | * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate |
| 980 | * any flush complete metadata. |
Aravind Akella | a7f2cda | 2014-08-21 16:31:14 -0700 | [diff] [blame] | 981 | * If the sensor is not active at the time flush() is called, flush() should return |
| 982 | * -EINVAL. |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 983 | */ |
Etienne Le Grand | 772d85a | 2014-08-19 14:30:19 -0700 | [diff] [blame] | 984 | int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); |
Mathias Agopian | 16671c5 | 2013-07-24 21:07:40 -0700 | [diff] [blame] | 985 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 986 | void (*reserved_procs[8])(void); |
| 987 | |
| 988 | } sensors_poll_device_1_t; |
| 989 | |
| 990 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 991 | /** convenience API for opening and closing a device */ |
| 992 | |
Mathias Agopian | b1e212e | 2010-07-08 16:44:54 -0700 | [diff] [blame] | 993 | static inline int sensors_open(const struct hw_module_t* module, |
| 994 | struct sensors_poll_device_t** device) { |
| 995 | return module->methods->open(module, |
| 996 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 997 | } |
| 998 | |
| 999 | static inline int sensors_close(struct sensors_poll_device_t* device) { |
| 1000 | return device->common.close(&device->common); |
| 1001 | } |
| 1002 | |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1003 | static inline int sensors_open_1(const struct hw_module_t* module, |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1004 | sensors_poll_device_1_t** device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1005 | return module->methods->open(module, |
| 1006 | SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); |
| 1007 | } |
| 1008 | |
Andrew Hsieh | 1082c0b | 2012-12-11 20:51:41 -0800 | [diff] [blame] | 1009 | static inline int sensors_close_1(sensors_poll_device_1_t* device) { |
Mathias Agopian | a455772 | 2012-11-28 17:21:55 -0800 | [diff] [blame] | 1010 | return device->common.close(&device->common); |
| 1011 | } |
| 1012 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1013 | __END_DECLS |
| 1014 | |
The Android Open Source Project | f53ebec | 2009-03-03 19:32:14 -0800 | [diff] [blame] | 1015 | #endif // ANDROID_SENSORS_INTERFACE_H |