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