summaryrefslogtreecommitdiff
path: root/include/android/sensor.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/android/sensor.h')
-rw-r--r--include/android/sensor.h76
1 files changed, 35 insertions, 41 deletions
diff --git a/include/android/sensor.h b/include/android/sensor.h
index 9dc6983e50..eb407794d1 100644
--- a/include/android/sensor.h
+++ b/include/android/sensor.h
@@ -52,13 +52,6 @@
#include <math.h>
#include <stdint.h>
-#if !defined(__INTRODUCED_IN)
-#define __INTRODUCED_IN(__api_level) /* nothing */
-#endif
-#if !defined(__DEPRECATED_IN)
-#define __DEPRECATED_IN(__api_level) __attribute__((__deprecated__))
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -228,8 +221,8 @@ enum {
*
* If a device supports the sensor additional information feature, it will
* report additional information events via {@link ASensorEvent} and will
- * have the type of {@link ASensorEvent} set to
- * {@link ASENSOR_TYPE_ADDITIONAL_INFO} and the sensor of {@link ASensorEvent} set
+ * have {@link ASensorEvent#type} set to
+ * {@link ASENSOR_TYPE_ADDITIONAL_INFO} and {@link ASensorEvent#sensor} set
* to the handle of the reporting sensor.
*
* Additional information reports consist of multiple frames ordered by
@@ -428,10 +421,6 @@ typedef struct ADynamicSensorEvent {
} ADynamicSensorEvent;
typedef struct AAdditionalInfoEvent {
- /**
- * Event type, such as ASENSOR_ADDITIONAL_INFO_BEGIN, ASENSOR_ADDITIONAL_INFO_END and others.
- * Refer to {@link ASENSOR_TYPE_ADDITIONAL_INFO} for the expected reporting behavior.
- */
int32_t type;
int32_t serial;
union {
@@ -440,36 +429,24 @@ typedef struct AAdditionalInfoEvent {
};
} AAdditionalInfoEvent;
-/**
- * Information that describes a sensor event, refer to
- * <a href="/reference/android/hardware/SensorEvent">SensorEvent</a> for additional
- * documentation.
- */
/* NOTE: changes to this struct has to be backward compatible */
typedef struct ASensorEvent {
int32_t version; /* sizeof(struct ASensorEvent) */
- int32_t sensor; /** The sensor that generates this event */
- int32_t type; /** Sensor type for the event, such as {@link ASENSOR_TYPE_ACCELEROMETER} */
- int32_t reserved0; /** do not use */
- /**
- * The time in nanoseconds at which the event happened, and its behavior
- * is identical to <a href="/reference/android/hardware/SensorEvent#timestamp">
- * SensorEvent::timestamp</a> in Java API.
- */
+ int32_t sensor;
+ int32_t type;
+ int32_t reserved0;
int64_t timestamp;
union {
union {
float data[16];
ASensorVector vector;
ASensorVector acceleration;
- ASensorVector gyro;
ASensorVector magnetic;
float temperature;
float distance;
float light;
float pressure;
float relative_humidity;
- AUncalibratedEvent uncalibrated_acceleration;
AUncalibratedEvent uncalibrated_gyro;
AUncalibratedEvent uncalibrated_magnetic;
AMetaDataEvent meta_data;
@@ -576,8 +553,13 @@ typedef ASensorRef const* ASensorList;
* ASensorManager* sensorManager = ASensorManager_getInstance();
*
*/
-ASensorManager* ASensorManager_getInstance() __DEPRECATED_IN(26);
+#if __ANDROID_API__ >= 26
+__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance();
+#else
+ASensorManager* ASensorManager_getInstance();
+#endif
+#if __ANDROID_API__ >= 26
/**
* Get a reference to the sensor manager. ASensorManager is a singleton
* per package as different packages may have access to different sensors.
@@ -589,6 +571,7 @@ ASensorManager* ASensorManager_getInstance() __DEPRECATED_IN(26);
* Available since API level 26.
*/
ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName) __INTRODUCED_IN(26);
+#endif
/**
* Returns the list of available sensors.
@@ -601,6 +584,7 @@ int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list);
*/
ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
+#if __ANDROID_API__ >= 21
/**
* Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
* of this type and wakeUp properties exists.
@@ -608,6 +592,7 @@ ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type
* Available since API level 21.
*/
ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp) __INTRODUCED_IN(21);
+#endif
/**
* Creates a new sensor event queue and associate it with a looper.
@@ -624,6 +609,7 @@ ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager,
*/
int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);
+#if __ANDROID_API__ >= 26
/**
* Create direct channel based on shared memory
*
@@ -667,10 +653,9 @@ int ASensorManager_createHardwareBufferDirectChannel(
/**
* Destroy a direct channel
*
- * Destroy a direct channel previously created by using one of
- * ASensorManager_create*DirectChannel() derivative functions.
- * Note that the buffer used for creating the direct channel does not get destroyed with
- * ASensorManager_destroyDirectChannel and has to be closed or released separately.
+ * Destroy a direct channel previously created using {@link ASensorManager_createDirectChannel}.
+ * The buffer used for creating direct channel does not get destroyed with
+ * {@link ASensorManager_destroy} and has to be close or released separately.
*
* Available since API level 26.
*
@@ -716,11 +701,12 @@ void ASensorManager_destroyDirectChannel(ASensorManager* manager, int channelId)
* \param channelId channel id (a positive integer) returned from
* {@link ASensorManager_createSharedMemoryDirectChannel} or
* {@link ASensorManager_createHardwareBufferDirectChannel}.
- * \param rate one of predefined ASENSOR_DIRECT_RATE_... that is supported by the sensor.
+ *
* \return positive token for success or negative error code.
*/
int ASensorManager_configureDirectReport(ASensorManager* manager,
ASensor const* sensor, int channelId, int rate) __INTRODUCED_IN(26);
+#endif /* __ANDROID_API__ >= 26 */
/*****************************************************************************/
@@ -733,7 +719,7 @@ int ASensorManager_configureDirectReport(ASensorManager* manager,
* \param queue {@link ASensorEventQueue} for sensor event to be report to.
* \param sensor {@link ASensor} to be enabled.
* \param samplingPeriodUs sampling period of sensor in microseconds.
- * \param maxBatchReportLatencyUs maximum time interval between two batches of sensor events are
+ * \param maxBatchReportLatencyus maximum time interval between two batch of sensor events are
* delievered in microseconds. For sensor streaming, set to 0.
* \return 0 on success or a negative error code on failure.
*/
@@ -793,7 +779,7 @@ int ASensorEventQueue_hasEvents(ASensorEventQueue* queue);
* Retrieve next available events from the queue to a specified event array.
*
* \param queue {@link ASensorEventQueue} to get events from
- * \param events pointer to an array of {@link ASensorEvent}.
+ * \param events pointer to an array of {@link ASensorEvents}.
* \param count max number of event that can be filled into array event.
* \return number of events returned on success; negative error code when
* no events are pending or an error has occurred.
@@ -809,11 +795,12 @@ int ASensorEventQueue_hasEvents(ASensorEventQueue* queue);
*/
ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, ASensorEvent* events, size_t count);
+#if __ANDROID_API__ >= 29
/**
* Request that {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to be delivered on
* the given {@link ASensorEventQueue}.
*
- * Sensor data events are always delivered to the {@link ASensorEventQueue}.
+ * Sensor data events are always delivered to the {@ASensorEventQueue}.
*
* The {@link ASENSOR_TYPE_ADDITIONAL_INFO} events will be returned through
* {@link ASensorEventQueue_getEvents}. The client is responsible for checking
@@ -832,6 +819,7 @@ ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, ASensorEvent* even
* \return 0 on success or a negative error code on failure
*/
int ASensorEventQueue_requestAdditionalInfoEvents(ASensorEventQueue* queue, bool enable) __INTRODUCED_IN(29);
+#endif /* __ANDROID_API__ >= 29 */
/*****************************************************************************/
@@ -862,6 +850,7 @@ float ASensor_getResolution(ASensor const* sensor);
*/
int ASensor_getMinDelay(ASensor const* sensor);
+#if __ANDROID_API__ >= 21
/**
* Returns the maximum size of batches for this sensor. Batches will often be
* smaller, as the hardware fifo might be used for other sensors.
@@ -897,7 +886,9 @@ int ASensor_getReportingMode(ASensor const* sensor) __INTRODUCED_IN(21);
* Available since API level 21.
*/
bool ASensor_isWakeUpSensor(ASensor const* sensor) __INTRODUCED_IN(21);
+#endif /* __ANDROID_API__ >= 21 */
+#if __ANDROID_API__ >= 26
/**
* Test if sensor supports a certain type of direct channel.
*
@@ -905,7 +896,7 @@ bool ASensor_isWakeUpSensor(ASensor const* sensor) __INTRODUCED_IN(21);
*
* \param sensor a {@link ASensor} to denote the sensor to be checked.
* \param channelType Channel type constant, either
- * {@link ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY}
+ * {@ASENSOR_DIRECT_CHANNEL_TYPE_SHARED_MEMORY}
* or {@link ASENSOR_DIRECT_CHANNEL_TYPE_HARDWARE_BUFFER}.
* \returns true if sensor supports the specified direct channel type.
*/
@@ -923,24 +914,27 @@ bool ASensor_isDirectChannelTypeSupported(ASensor const* sensor, int channelType
* does not support direct report.
*/
int ASensor_getHighestDirectReportRateLevel(ASensor const* sensor) __INTRODUCED_IN(26);
+#endif /* __ANDROID_API__ >= 26 */
+#if __ANDROID_API__ >= 29
/**
* Returns the sensor's handle.
*
* The handle identifies the sensor within the system and is included in the
- * sensor field of {@link ASensorEvent}, including those sent with type
+ * {@link ASensorEvent#sensor} field of sensor events, including those sent with type
* {@link ASENSOR_TYPE_ADDITIONAL_INFO}.
*
* A sensor's handle is able to be used to map {@link ASENSOR_TYPE_ADDITIONAL_INFO} events to the
* sensor that generated the event.
*
* It is important to note that the value returned by {@link ASensor_getHandle} is not the same as
- * the value returned by the Java API <a href="/reference/android/hardware/Sensor#getId()">
- * android.hardware.Sensor's getId()</a> and no mapping exists between the values.
+ * the value returned by the Java API {@link android.hardware.Sensor#getId} and no mapping exists
+ * between the values.
*
* Available since API level 29.
*/
int ASensor_getHandle(ASensor const* sensor) __INTRODUCED_IN(29);
+#endif /* __ANDROID_API__ >= 29 */
#ifdef __cplusplus
};