sensors.h File Reference
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
#include <cutils/native_handle.h>

Go to the source code of this file.

Data Structures

struct  sensors_vec_t
 
struct  uncalibrated_event_t
 
struct  meta_data_event
 
struct  heart_rate_event_t
 
struct  sensors_event_t
 
struct  sensors_module_t
 
struct  sensor_t
 
struct  sensors_poll_device_t
 
struct  sensors_poll_device_1
 

Macros

#define SENSORS_HEADER_VERSION   1
 
#define SENSORS_MODULE_API_VERSION_0_1   HARDWARE_MODULE_API_VERSION(0, 1)
 
#define SENSORS_DEVICE_API_VERSION_0_1   HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_0   HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_1   HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_2   HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_3   HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION)
 
#define SENSORS_DEVICE_API_VERSION_1_4   HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION)
 
#define SENSORS_HARDWARE_MODULE_ID   "sensors"
 
#define SENSORS_HARDWARE_POLL   "poll"
 
#define SENSORS_HANDLE_BASE   0
 
#define SENSORS_HANDLE_BITS   8
 
#define SENSORS_HANDLE_COUNT   (1<<SENSORS_HANDLE_BITS)
 
#define SENSOR_PERMISSION_BODY_SENSORS   "android.permission.BODY_SENSORS"
 
#define REPORTING_MODE_MASK   (0xE)
 
#define REPORTING_MODE_SHIFT   (1)
 
#define DATA_INJECTION_MASK   (0x10)
 
#define DATA_INJECTION_SHIFT   (4)
 
#define SENSOR_TYPE_DEVICE_PRIVATE_BASE   0x10000
 
#define SENSOR_TYPE_META_DATA   (0)
 
#define SENSOR_TYPE_ACCELEROMETER   (1)
 
#define SENSOR_STRING_TYPE_ACCELEROMETER   "android.sensor.accelerometer"
 
#define SENSOR_TYPE_GEOMAGNETIC_FIELD   (2)
 
#define SENSOR_TYPE_MAGNETIC_FIELD   SENSOR_TYPE_GEOMAGNETIC_FIELD
 
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD   "android.sensor.magnetic_field"
 
#define SENSOR_TYPE_ORIENTATION   (3)
 
#define SENSOR_STRING_TYPE_ORIENTATION   "android.sensor.orientation"
 
#define SENSOR_TYPE_GYROSCOPE   (4)
 
#define SENSOR_STRING_TYPE_GYROSCOPE   "android.sensor.gyroscope"
 
#define SENSOR_TYPE_LIGHT   (5)
 
#define SENSOR_STRING_TYPE_LIGHT   "android.sensor.light"
 
#define SENSOR_TYPE_PRESSURE   (6)
 
#define SENSOR_STRING_TYPE_PRESSURE   "android.sensor.pressure"
 
#define SENSOR_TYPE_TEMPERATURE   (7)
 
#define SENSOR_STRING_TYPE_TEMPERATURE   "android.sensor.temperature"
 
#define SENSOR_TYPE_PROXIMITY   (8)
 
#define SENSOR_STRING_TYPE_PROXIMITY   "android.sensor.proximity"
 
#define SENSOR_TYPE_GRAVITY   (9)
 
#define SENSOR_STRING_TYPE_GRAVITY   "android.sensor.gravity"
 
#define SENSOR_TYPE_LINEAR_ACCELERATION   (10)
 
#define SENSOR_STRING_TYPE_LINEAR_ACCELERATION   "android.sensor.linear_acceleration"
 
#define SENSOR_TYPE_ROTATION_VECTOR   (11)
 
#define SENSOR_STRING_TYPE_ROTATION_VECTOR   "android.sensor.rotation_vector"
 
#define SENSOR_TYPE_RELATIVE_HUMIDITY   (12)
 
#define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY   "android.sensor.relative_humidity"
 
#define SENSOR_TYPE_AMBIENT_TEMPERATURE   (13)
 
#define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE   "android.sensor.ambient_temperature"
 
#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED   (14)
 
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED   "android.sensor.magnetic_field_uncalibrated"
 
#define SENSOR_TYPE_GAME_ROTATION_VECTOR   (15)
 
#define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR   "android.sensor.game_rotation_vector"
 
#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED   (16)
 
#define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED   "android.sensor.gyroscope_uncalibrated"
 
#define SENSOR_TYPE_SIGNIFICANT_MOTION   (17)
 
#define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION   "android.sensor.significant_motion"
 
#define SENSOR_TYPE_STEP_DETECTOR   (18)
 
#define SENSOR_STRING_TYPE_STEP_DETECTOR   "android.sensor.step_detector"
 
#define SENSOR_TYPE_STEP_COUNTER   (19)
 
#define SENSOR_STRING_TYPE_STEP_COUNTER   "android.sensor.step_counter"
 
#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR   (20)
 
#define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR   "android.sensor.geomagnetic_rotation_vector"
 
#define SENSOR_TYPE_HEART_RATE   (21)
 
#define SENSOR_STRING_TYPE_HEART_RATE   "android.sensor.heart_rate"
 
#define SENSOR_TYPE_TILT_DETECTOR   (22)
 
#define SENSOR_STRING_TYPE_TILT_DETECTOR   "android.sensor.tilt_detector"
 
#define SENSOR_TYPE_WAKE_GESTURE   (23)
 
#define SENSOR_STRING_TYPE_WAKE_GESTURE   "android.sensor.wake_gesture"
 
#define SENSOR_TYPE_GLANCE_GESTURE   (24)
 
#define SENSOR_STRING_TYPE_GLANCE_GESTURE   "android.sensor.glance_gesture"
 
#define SENSOR_TYPE_PICK_UP_GESTURE   (25)
 
#define SENSOR_STRING_TYPE_PICK_UP_GESTURE   "android.sensor.pick_up_gesture"
 
#define SENSOR_TYPE_WRIST_TILT_GESTURE   (26)
 
#define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE   "android.sensor.wrist_tilt_gesture"
 
#define GRAVITY_SUN   (275.0f)
 
#define GRAVITY_EARTH   (9.80665f)
 
#define MAGNETIC_FIELD_EARTH_MAX   (60.0f)
 
#define MAGNETIC_FIELD_EARTH_MIN   (30.0f)
 
#define SENSOR_STATUS_NO_CONTACT   -1
 
#define SENSOR_STATUS_UNRELIABLE   0
 
#define SENSOR_STATUS_ACCURACY_LOW   1
 
#define SENSOR_STATUS_ACCURACY_MEDIUM   2
 
#define SENSOR_STATUS_ACCURACY_HIGH   3
 

Typedefs

typedef struct meta_data_event meta_data_event_t
 
typedef struct sensors_event_t sensors_event_t
 
typedef sensors_event_t sensors_meta_data_event_t
 
typedef struct
sensors_poll_device_1 
sensors_poll_device_1_t
 

Enumerations

enum  { SENSORS_BATCH_DRY_RUN = 0x00000001, SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002 }
 
enum  { META_DATA_FLUSH_COMPLETE = 1, META_DATA_VERSION }
 
enum  { SENSOR_HAL_NORMAL_MODE = 0, SENSOR_HAL_DATA_INJECTION_MODE = 0x1 }
 
enum  {
  SENSOR_FLAG_WAKE_UP = 1U << 0, SENSOR_FLAG_CONTINUOUS_MODE = 0, SENSOR_FLAG_ON_CHANGE_MODE = 0x2, SENSOR_FLAG_ONE_SHOT_MODE = 0x4,
  SENSOR_FLAG_SPECIAL_REPORTING_MODE = 0x6, SENSOR_FLAG_SUPPORTS_DATA_INJECTION = 0x8
}
 

Macro Definition Documentation

#define DATA_INJECTION_MASK   (0x10)

Definition at line 162 of file sensors.h.

#define DATA_INJECTION_SHIFT   (4)

Definition at line 163 of file sensors.h.

#define GRAVITY_EARTH   (9.80665f)

Definition at line 665 of file sensors.h.

#define GRAVITY_SUN   (275.0f)

Values returned by the accelerometer in various locations in the universe. all values are in SI units (m/s^2)

Definition at line 664 of file sensors.h.

#define MAGNETIC_FIELD_EARTH_MAX   (60.0f)

Maximum magnetic field on Earth's surface

Definition at line 668 of file sensors.h.

#define MAGNETIC_FIELD_EARTH_MIN   (30.0f)

Minimum magnetic field on Earth's surface

Definition at line 671 of file sensors.h.

#define REPORTING_MODE_MASK   (0xE)

Definition at line 156 of file sensors.h.

#define REPORTING_MODE_SHIFT   (1)

Definition at line 157 of file sensors.h.

#define SENSOR_PERMISSION_BODY_SENSORS   "android.permission.BODY_SENSORS"

Definition at line 94 of file sensors.h.

#define SENSOR_STATUS_ACCURACY_HIGH   3

Definition at line 680 of file sensors.h.

#define SENSOR_STATUS_ACCURACY_LOW   1

Definition at line 678 of file sensors.h.

#define SENSOR_STATUS_ACCURACY_MEDIUM   2

Definition at line 679 of file sensors.h.

#define SENSOR_STATUS_NO_CONTACT   -1

Possible values of the status field of sensor events.

Definition at line 676 of file sensors.h.

#define SENSOR_STATUS_UNRELIABLE   0

Definition at line 677 of file sensors.h.

#define SENSOR_STRING_TYPE_ACCELEROMETER   "android.sensor.accelerometer"

Definition at line 287 of file sensors.h.

#define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE   "android.sensor.ambient_temperature"

Definition at line 432 of file sensors.h.

#define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR   "android.sensor.game_rotation_vector"

Definition at line 458 of file sensors.h.

#define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR   "android.sensor.geomagnetic_rotation_vector"

Definition at line 529 of file sensors.h.

#define SENSOR_STRING_TYPE_GLANCE_GESTURE   "android.sensor.glance_gesture"

Definition at line 629 of file sensors.h.

#define SENSOR_STRING_TYPE_GRAVITY   "android.sensor.gravity"

Definition at line 382 of file sensors.h.

#define SENSOR_STRING_TYPE_GYROSCOPE   "android.sensor.gyroscope"

Definition at line 329 of file sensors.h.

#define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED   "android.sensor.gyroscope_uncalibrated"

Definition at line 471 of file sensors.h.

#define SENSOR_STRING_TYPE_HEART_RATE   "android.sensor.heart_rate"

Definition at line 553 of file sensors.h.

#define SENSOR_STRING_TYPE_LIGHT   "android.sensor.light"

Definition at line 340 of file sensors.h.

#define SENSOR_STRING_TYPE_LINEAR_ACCELERATION   "android.sensor.linear_acceleration"

Definition at line 395 of file sensors.h.

#define SENSOR_STRING_TYPE_MAGNETIC_FIELD   "android.sensor.magnetic_field"

Definition at line 301 of file sensors.h.

#define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED   "android.sensor.magnetic_field_uncalibrated"

Definition at line 445 of file sensors.h.

#define SENSOR_STRING_TYPE_ORIENTATION   "android.sensor.orientation"

Definition at line 316 of file sensors.h.

#define SENSOR_STRING_TYPE_PICK_UP_GESTURE   "android.sensor.pick_up_gesture"

Definition at line 642 of file sensors.h.

#define SENSOR_STRING_TYPE_PRESSURE   "android.sensor.pressure"

Definition at line 352 of file sensors.h.

#define SENSOR_STRING_TYPE_PROXIMITY   "android.sensor.proximity"

Definition at line 369 of file sensors.h.

#define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY   "android.sensor.relative_humidity"

Definition at line 421 of file sensors.h.

#define SENSOR_STRING_TYPE_ROTATION_VECTOR   "android.sensor.rotation_vector"

Definition at line 409 of file sensors.h.

#define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION   "android.sensor.significant_motion"

Definition at line 486 of file sensors.h.

#define SENSOR_STRING_TYPE_STEP_COUNTER   "android.sensor.step_counter"

Definition at line 516 of file sensors.h.

#define SENSOR_STRING_TYPE_STEP_DETECTOR   "android.sensor.step_detector"

Definition at line 500 of file sensors.h.

#define SENSOR_STRING_TYPE_TEMPERATURE   "android.sensor.temperature"

Definition at line 356 of file sensors.h.

#define SENSOR_STRING_TYPE_TILT_DETECTOR   "android.sensor.tilt_detector"

Definition at line 581 of file sensors.h.

#define SENSOR_STRING_TYPE_WAKE_GESTURE   "android.sensor.wake_gesture"

Definition at line 603 of file sensors.h.

#define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE   "android.sensor.wrist_tilt_gesture"

Definition at line 658 of file sensors.h.

#define SENSOR_TYPE_ACCELEROMETER   (1)

Definition at line 286 of file sensors.h.

#define SENSOR_TYPE_AMBIENT_TEMPERATURE   (13)

Definition at line 431 of file sensors.h.

#define SENSOR_TYPE_DEVICE_PRIVATE_BASE   0x10000

Definition at line 216 of file sensors.h.

#define SENSOR_TYPE_GAME_ROTATION_VECTOR   (15)

Definition at line 457 of file sensors.h.

#define SENSOR_TYPE_GEOMAGNETIC_FIELD   (2)

Definition at line 299 of file sensors.h.

#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR   (20)

Definition at line 528 of file sensors.h.

#define SENSOR_TYPE_GLANCE_GESTURE   (24)

Definition at line 628 of file sensors.h.

#define SENSOR_TYPE_GRAVITY   (9)

Definition at line 381 of file sensors.h.

#define SENSOR_TYPE_GYROSCOPE   (4)

Definition at line 328 of file sensors.h.

#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED   (16)

Definition at line 470 of file sensors.h.

#define SENSOR_TYPE_HEART_RATE   (21)

Definition at line 552 of file sensors.h.

#define SENSOR_TYPE_LIGHT   (5)

Definition at line 339 of file sensors.h.

#define SENSOR_TYPE_LINEAR_ACCELERATION   (10)

Definition at line 394 of file sensors.h.

#define SENSOR_TYPE_MAGNETIC_FIELD   SENSOR_TYPE_GEOMAGNETIC_FIELD

Definition at line 300 of file sensors.h.

#define SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED   (14)

Definition at line 444 of file sensors.h.

#define SENSOR_TYPE_META_DATA   (0)

Definition at line 249 of file sensors.h.

#define SENSOR_TYPE_ORIENTATION   (3)

Definition at line 315 of file sensors.h.

#define SENSOR_TYPE_PICK_UP_GESTURE   (25)

SENSOR_TYPE_PICK_UP_GESTURE reporting-mode: one-shot

A sensor of this type triggers when the device is picked up regardless of wherever is was before (desk, pocket, bag). The only allowed return value is 1.0. This sensor de-activates itself immediately after it triggers.

Implement only the wake-up version of this sensor.

Definition at line 641 of file sensors.h.

#define SENSOR_TYPE_PRESSURE   (6)

Definition at line 351 of file sensors.h.

#define SENSOR_TYPE_PROXIMITY   (8)

Definition at line 368 of file sensors.h.

#define SENSOR_TYPE_RELATIVE_HUMIDITY   (12)

Definition at line 420 of file sensors.h.

#define SENSOR_TYPE_ROTATION_VECTOR   (11)

Definition at line 408 of file sensors.h.

#define SENSOR_TYPE_SIGNIFICANT_MOTION   (17)

Definition at line 485 of file sensors.h.

#define SENSOR_TYPE_STEP_COUNTER   (19)

Definition at line 515 of file sensors.h.

#define SENSOR_TYPE_STEP_DETECTOR   (18)

Definition at line 499 of file sensors.h.

#define SENSOR_TYPE_TEMPERATURE   (7)

Definition at line 355 of file sensors.h.

#define SENSOR_TYPE_TILT_DETECTOR   (22)

Definition at line 580 of file sensors.h.

#define SENSOR_TYPE_WAKE_GESTURE   (23)

Definition at line 602 of file sensors.h.

#define SENSOR_TYPE_WRIST_TILT_GESTURE   (26)

Definition at line 657 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_0_1   HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION)

Definition at line 33 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_0   HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION)

Definition at line 34 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_1   HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION)

Definition at line 35 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_2   HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION)

Definition at line 36 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_3   HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION)

Definition at line 37 of file sensors.h.

#define SENSORS_DEVICE_API_VERSION_1_4   HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION)

Definition at line 38 of file sensors.h.

#define SENSORS_HANDLE_BASE   0

Handles must be higher than SENSORS_HANDLE_BASE and must be unique. A Handle identifies a given sensors. The handle is used to activate and/or deactivate sensors. In this version of the API there can only be 256 handles.

Definition at line 62 of file sensors.h.

#define SENSORS_HANDLE_BITS   8

Definition at line 63 of file sensors.h.

#define SENSORS_HANDLE_COUNT   (1<<SENSORS_HANDLE_BITS)

Definition at line 64 of file sensors.h.

#define SENSORS_HARDWARE_MODULE_ID   "sensors"

Please see the Sensors section of source.android.com for an introduction to and detailed descriptions of Android sensor types: http://source.android.com/devices/sensors/index.html The id of this module

Definition at line 49 of file sensors.h.

#define SENSORS_HARDWARE_POLL   "poll"

Name of the sensors device to open

Definition at line 54 of file sensors.h.

#define SENSORS_HEADER_VERSION   1

Definition at line 31 of file sensors.h.

#define SENSORS_MODULE_API_VERSION_0_1   HARDWARE_MODULE_API_VERSION(0, 1)

Definition at line 32 of file sensors.h.

Typedef Documentation

Meta data event data

Union of the various types of sensor data that can be returned.

Definition at line 830 of file sensors.h.

Enumeration Type Documentation

anonymous enum
Enumerator
SENSORS_BATCH_DRY_RUN 
SENSORS_BATCH_WAKE_UPON_FIFO_FULL 

Definition at line 75 of file sensors.h.

anonymous enum
Enumerator
META_DATA_FLUSH_COMPLETE 
META_DATA_VERSION 

Definition at line 83 of file sensors.h.

anonymous enum
Enumerator
SENSOR_HAL_NORMAL_MODE 
SENSOR_HAL_DATA_INJECTION_MODE 

Definition at line 100 of file sensors.h.

anonymous enum
Enumerator
SENSOR_FLAG_WAKE_UP 
SENSOR_FLAG_CONTINUOUS_MODE 
SENSOR_FLAG_ON_CHANGE_MODE 
SENSOR_FLAG_ONE_SHOT_MODE 
SENSOR_FLAG_SPECIAL_REPORTING_MODE 
SENSOR_FLAG_SUPPORTS_DATA_INJECTION 

Definition at line 123 of file sensors.h.