blob: 6402389e1b45a420b5ad8a702ead14070e3a03f2 [file] [log] [blame]
Mathias Agopiane1c61d32012-03-23 14:19:36 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
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
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070017/**
18 * @addtogroup Sensor
19 * @{
20 */
21
22/**
23 * @file sensor.h
24 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070025
26#ifndef ANDROID_SENSOR_H
27#define ANDROID_SENSOR_H
28
29/******************************************************************
30 *
31 * IMPORTANT NOTICE:
32 *
33 * This file is part of Android's set of stable system headers
34 * exposed by the Android NDK (Native Development Kit).
35 *
36 * Third-party source AND binary code relies on the definitions
37 * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
38 *
39 * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
40 * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
41 * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
42 * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
43 */
44
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070045/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -070046 * Structures and functions to receive and process sensor events in
47 * native code.
48 *
49 */
50
Dan Albert43dcd0e2017-04-25 12:24:28 -070051#include <stdbool.h>
Mathias Agopiane1c61d32012-03-23 14:19:36 -070052#include <sys/types.h>
53
54#include <android/looper.h>
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070061/**
62 * Sensor types.
Johan Euphrosine7d319fc2015-08-20 18:13:43 -070063 * (keep in sync with hardware/sensors.h)
Mathias Agopiane1c61d32012-03-23 14:19:36 -070064 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -070065enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070066 /**
67 * {@link ASENSOR_TYPE_ACCELEROMETER}
68 * reporting-mode: continuous
69 *
70 * All values are in SI units (m/s^2) and measure the acceleration of the
71 * device minus the force of gravity.
72 */
Johan Euphrosine7d319fc2015-08-20 18:13:43 -070073 ASENSOR_TYPE_ACCELEROMETER = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070074 /**
75 * {@link ASENSOR_TYPE_MAGNETIC_FIELD}
76 * reporting-mode: continuous
77 *
78 * All values are in micro-Tesla (uT) and measure the geomagnetic
79 * field in the X, Y and Z axis.
80 */
Johan Euphrosine7d319fc2015-08-20 18:13:43 -070081 ASENSOR_TYPE_MAGNETIC_FIELD = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070082 /**
83 * {@link ASENSOR_TYPE_GYROSCOPE}
84 * reporting-mode: continuous
85 *
86 * All values are in radians/second and measure the rate of rotation
87 * around the X, Y and Z axis.
88 */
Johan Euphrosine7d319fc2015-08-20 18:13:43 -070089 ASENSOR_TYPE_GYROSCOPE = 4,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070090 /**
91 * {@link ASENSOR_TYPE_LIGHT}
92 * reporting-mode: on-change
93 *
94 * The light sensor value is returned in SI lux units.
95 */
Johan Euphrosine7d319fc2015-08-20 18:13:43 -070096 ASENSOR_TYPE_LIGHT = 5,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -070097 /**
98 * {@link ASENSOR_TYPE_PROXIMITY}
99 * reporting-mode: on-change
100 *
101 * The proximity sensor which turns the screen off and back on during calls is the
102 * wake-up proximity sensor. Implement wake-up proximity sensor before implementing
103 * a non wake-up proximity sensor. For the wake-up proximity sensor set the flag
104 * SENSOR_FLAG_WAKE_UP.
105 * The value corresponds to the distance to the nearest object in centimeters.
106 */
Johan Euphrosine7d319fc2015-08-20 18:13:43 -0700107 ASENSOR_TYPE_PROXIMITY = 8,
108 /**
109 * {@link ASENSOR_TYPE_LINEAR_ACCELERATION}
110 * reporting-mode: continuous
111 *
112 * All values are in SI units (m/s^2) and measure the acceleration of the
113 * device not including the force of gravity.
114 */
115 ASENSOR_TYPE_LINEAR_ACCELERATION = 10
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700116};
117
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700118/**
119 * Sensor accuracy measure.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700120 */
121enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700122 /** no contact */
Etienne Le Grand630e31d2014-05-22 17:15:08 -0700123 ASENSOR_STATUS_NO_CONTACT = -1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700124 /** unreliable */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700125 ASENSOR_STATUS_UNRELIABLE = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700126 /** low accuracy */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700127 ASENSOR_STATUS_ACCURACY_LOW = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700128 /** medium accuracy */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700129 ASENSOR_STATUS_ACCURACY_MEDIUM = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700130 /** high accuracy */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700131 ASENSOR_STATUS_ACCURACY_HIGH = 3
132};
133
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700134/**
Aravind Akella0e025c52014-06-03 19:19:57 -0700135 * Sensor Reporting Modes.
136 */
137enum {
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700138 /** continuous reporting */
Aravind Akella0e025c52014-06-03 19:19:57 -0700139 AREPORTING_MODE_CONTINUOUS = 0,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700140 /** reporting on change */
Aravind Akella0e025c52014-06-03 19:19:57 -0700141 AREPORTING_MODE_ON_CHANGE = 1,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700142 /** on shot reporting */
Aravind Akella0e025c52014-06-03 19:19:57 -0700143 AREPORTING_MODE_ONE_SHOT = 2,
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700144 /** special trigger reporting */
Aravind Akella0e025c52014-06-03 19:19:57 -0700145 AREPORTING_MODE_SPECIAL_TRIGGER = 3
146};
147
148/*
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700149 * A few useful constants
150 */
151
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700152/** Earth's gravity in m/s^2 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700153#define ASENSOR_STANDARD_GRAVITY (9.80665f)
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700154/** Maximum magnetic field on Earth's surface in uT */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700155#define ASENSOR_MAGNETIC_FIELD_EARTH_MAX (60.0f)
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700156/** Minimum magnetic field on Earth's surface in uT*/
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700157#define ASENSOR_MAGNETIC_FIELD_EARTH_MIN (30.0f)
158
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700159/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700160 * A sensor event.
161 */
162
163/* NOTE: Must match hardware/sensors.h */
164typedef struct ASensorVector {
165 union {
166 float v[3];
167 struct {
168 float x;
169 float y;
170 float z;
171 };
172 struct {
173 float azimuth;
174 float pitch;
175 float roll;
176 };
177 };
178 int8_t status;
179 uint8_t reserved[3];
180} ASensorVector;
181
Aravind Akella724d91d2013-06-27 12:04:23 -0700182typedef struct AMetaDataEvent {
183 int32_t what;
184 int32_t sensor;
185} AMetaDataEvent;
186
187typedef struct AUncalibratedEvent {
Peng Xu9e720462016-01-26 18:48:54 -0800188 union {
189 float uncalib[3];
190 struct {
191 float x_uncalib;
192 float y_uncalib;
193 float z_uncalib;
194 };
Aravind Akella724d91d2013-06-27 12:04:23 -0700195 };
Peng Xu9e720462016-01-26 18:48:54 -0800196 union {
197 float bias[3];
198 struct {
199 float x_bias;
200 float y_bias;
201 float z_bias;
202 };
Aravind Akella724d91d2013-06-27 12:04:23 -0700203 };
Aravind Akella724d91d2013-06-27 12:04:23 -0700204} AUncalibratedEvent;
205
Etienne Le Grand630e31d2014-05-22 17:15:08 -0700206typedef struct AHeartRateEvent {
Peng Xu9e720462016-01-26 18:48:54 -0800207 float bpm;
208 int8_t status;
Etienne Le Grand630e31d2014-05-22 17:15:08 -0700209} AHeartRateEvent;
210
Peng Xu2576cb62016-01-20 00:22:09 -0800211typedef struct ADynamicSensorEvent {
Peng Xu9e720462016-01-26 18:48:54 -0800212 int32_t connected;
213 int32_t handle;
Peng Xu2576cb62016-01-20 00:22:09 -0800214} ADynamicSensorEvent;
215
Peng Xu9e720462016-01-26 18:48:54 -0800216typedef struct {
217 int32_t type;
218 int32_t serial;
219 union {
220 int32_t data_int32[14];
221 float data_float[14];
222 };
223} AAdditionalInfoEvent;
224
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700225/* NOTE: Must match hardware/sensors.h */
226typedef struct ASensorEvent {
227 int32_t version; /* sizeof(struct ASensorEvent) */
228 int32_t sensor;
229 int32_t type;
230 int32_t reserved0;
231 int64_t timestamp;
232 union {
Mathias Agopianba02cd22013-07-03 16:20:57 -0700233 union {
234 float data[16];
235 ASensorVector vector;
236 ASensorVector acceleration;
237 ASensorVector magnetic;
238 float temperature;
239 float distance;
240 float light;
241 float pressure;
Aravind Akella724d91d2013-06-27 12:04:23 -0700242 float relative_humidity;
243 AUncalibratedEvent uncalibrated_gyro;
244 AUncalibratedEvent uncalibrated_magnetic;
245 AMetaDataEvent meta_data;
Etienne Le Grand630e31d2014-05-22 17:15:08 -0700246 AHeartRateEvent heart_rate;
Peng Xu2576cb62016-01-20 00:22:09 -0800247 ADynamicSensorEvent dynamic_sensor_meta;
Peng Xu9e720462016-01-26 18:48:54 -0800248 AAdditionalInfoEvent additional_info;
Mathias Agopianba02cd22013-07-03 16:20:57 -0700249 };
250 union {
251 uint64_t data[8];
252 uint64_t step_counter;
253 } u64;
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700254 };
Aravind Akella9a844cf2014-02-11 18:58:52 -0800255
256 uint32_t flags;
257 int32_t reserved1[3];
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700258} ASensorEvent;
259
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700260struct ASensorManager;
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700261/**
262 * {@link ASensorManager} is an opaque type to manage sensors and
263 * events queues.
264 *
265 * {@link ASensorManager} is a singleton that can be obtained using
266 * ASensorManager_getInstance().
267 *
268 * This file provides a set of functions that uses {@link
269 * ASensorManager} to access and list hardware sensors, and
270 * create and destroy event queues:
271 * - ASensorManager_getSensorList()
272 * - ASensorManager_getDefaultSensor()
273 * - ASensorManager_getDefaultSensorEx()
274 * - ASensorManager_createEventQueue()
275 * - ASensorManager_destroyEventQueue()
276 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700277typedef struct ASensorManager ASensorManager;
278
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700279
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700280struct ASensorEventQueue;
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700281/**
282 * {@link ASensorEventQueue} is an opaque type that provides access to
283 * {@link ASensorEvent} from hardware sensors.
284 *
285 * A new {@link ASensorEventQueue} can be obtained using ASensorManager_createEventQueue().
286 *
287 * This file provides a set of functions to enable and disable
288 * sensors, check and get events, and set event rates on a {@link
289 * ASensorEventQueue}.
290 * - ASensorEventQueue_enableSensor()
291 * - ASensorEventQueue_disableSensor()
292 * - ASensorEventQueue_hasEvents()
293 * - ASensorEventQueue_getEvents()
294 * - ASensorEventQueue_setEventRate()
295 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700296typedef struct ASensorEventQueue ASensorEventQueue;
297
298struct ASensor;
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700299/**
300 * {@link ASensor} is an opaque type that provides information about
301 * an hardware sensors.
302 *
303 * A {@link ASensor} pointer can be obtained using
304 * ASensorManager_getDefaultSensor(),
305 * ASensorManager_getDefaultSensorEx() or from a {@link ASensorList}.
306 *
307 * This file provides a set of functions to access properties of a
308 * {@link ASensor}:
309 * - ASensor_getName()
310 * - ASensor_getVendor()
311 * - ASensor_getType()
312 * - ASensor_getResolution()
313 * - ASensor_getMinDelay()
314 * - ASensor_getFifoMaxEventCount()
315 * - ASensor_getFifoReservedEventCount()
316 * - ASensor_getStringType()
317 * - ASensor_getReportingMode()
318 * - ASensor_isWakeUpSensor()
319 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700320typedef struct ASensor ASensor;
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700321/**
322 * {@link ASensorRef} is a type for constant pointers to {@link ASensor}.
323 *
324 * This is used to define entry in {@link ASensorList} arrays.
325 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700326typedef ASensor const* ASensorRef;
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700327/**
328 * {@link ASensorList} is an array of reference to {@link ASensor}.
329 *
330 * A {@link ASensorList} can be initialized using ASensorManager_getSensorList().
331 */
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700332typedef ASensorRef const* ASensorList;
333
334/*****************************************************************************/
335
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700336/**
Svet Ganov5fa32d42015-05-07 10:50:59 -0700337 * Get a reference to the sensor manager. ASensorManager is a singleton
338 * per package as different packages may have access to different sensors.
339 *
340 * Deprecated: Use ASensorManager_getInstanceForPackage(const char*) instead.
341 *
342 * Example:
343 *
344 * ASensorManager* sensorManager = ASensorManager_getInstance();
345 *
346 */
Peng Xu77a61e52017-07-17 16:40:50 -0700347#if __ANDROID_API__ >= __ANDROID_API_O__
Svet Ganov5fa32d42015-05-07 10:50:59 -0700348__attribute__ ((deprecated)) ASensorManager* ASensorManager_getInstance();
Peng Xu77a61e52017-07-17 16:40:50 -0700349#else
350ASensorManager* ASensorManager_getInstance();
351#endif
Svet Ganov5fa32d42015-05-07 10:50:59 -0700352
Peng Xu77a61e52017-07-17 16:40:50 -0700353#if __ANDROID_API__ >= __ANDROID_API_O__
Svet Ganov5fa32d42015-05-07 10:50:59 -0700354/*
355 * Get a reference to the sensor manager. ASensorManager is a singleton
356 * per package as different packages may have access to different sensors.
357 *
358 * Example:
359 *
360 * ASensorManager* sensorManager = ASensorManager_getInstanceForPackage("foo.bar.baz");
361 *
362 */
363ASensorManager* ASensorManager_getInstanceForPackage(const char* packageName);
Peng Xu77a61e52017-07-17 16:40:50 -0700364#endif
Svet Ganov5fa32d42015-05-07 10:50:59 -0700365
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700366/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700367 * Returns the list of available sensors.
368 */
369int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list);
370
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700371/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700372 * Returns the default sensor for the given type, or NULL if no sensor
Aravind Akellab37ba392014-08-05 14:53:07 -0700373 * of that type exists.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700374 */
375ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type);
376
Dan Albert494ed552016-09-23 15:57:45 -0700377#if __ANDROID_API__ >= 21
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700378/**
Aravind Akellab37ba392014-08-05 14:53:07 -0700379 * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor
380 * of this type and wakeUp properties exists.
381 */
382ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type,
383 bool wakeUp);
Dan Albert494ed552016-09-23 15:57:45 -0700384#endif
Aravind Akellab37ba392014-08-05 14:53:07 -0700385
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700386/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700387 * Creates a new sensor event queue and associate it with a looper.
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700388 *
389 * "ident" is a identifier for the events that will be returned when
390 * calling ALooper_pollOnce(). The identifier must be >= 0, or
391 * ALOOPER_POLL_CALLBACK if providing a non-NULL callback.
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700392 */
393ASensorEventQueue* ASensorManager_createEventQueue(ASensorManager* manager,
394 ALooper* looper, int ident, ALooper_callbackFunc callback, void* data);
395
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700396/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700397 * Destroys the event queue and free all resources associated to it.
398 */
399int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* queue);
400
401
402/*****************************************************************************/
403
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700404/**
Aniroop Mathurda94fd82015-11-03 01:47:46 +0530405 * Enable the selected sensor with a specified sampling period and max batch report latency.
406 * Returns a negative error code on failure.
Aniroop Mathure96e5772016-12-13 00:04:06 +0530407 * Note: To disable the selected sensor, use ASensorEventQueue_disableSensor() same as before.
Aniroop Mathurda94fd82015-11-03 01:47:46 +0530408 */
409int ASensorEventQueue_registerSensor(ASensorEventQueue* queue, ASensor const* sensor,
410 int32_t samplingPeriodUs, int maxBatchReportLatencyUs);
411
412/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700413 * Enable the selected sensor. Returns a negative error code on failure.
414 */
415int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor);
416
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700417/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700418 * Disable the selected sensor. Returns a negative error code on failure.
419 */
420int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor);
421
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700422/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700423 * Sets the delivery rate of events in microseconds for the given sensor.
424 * Note that this is a hint only, generally event will arrive at a higher
425 * rate. It is an error to set a rate inferior to the value returned by
426 * ASensor_getMinDelay().
427 * Returns a negative error code on failure.
428 */
429int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec);
430
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700431/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700432 * Returns true if there are one or more events available in the
433 * sensor queue. Returns 1 if the queue has events; 0 if
434 * it does not have events; and a negative value if there is an error.
435 */
436int ASensorEventQueue_hasEvents(ASensorEventQueue* queue);
437
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700438/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700439 * Returns the next available events from the queue. Returns a negative
440 * value if no events are available or an error has occurred, otherwise
441 * the number of events returned.
442 *
443 * Examples:
444 * ASensorEvent event;
445 * ssize_t numEvent = ASensorEventQueue_getEvents(queue, &event, 1);
446 *
447 * ASensorEvent eventBuffer[8];
448 * ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8);
449 *
450 */
451ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue,
452 ASensorEvent* events, size_t count);
453
454
455/*****************************************************************************/
456
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700457/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700458 * Returns this sensor's name (non localized)
459 */
460const char* ASensor_getName(ASensor const* sensor);
461
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700462/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700463 * Returns this sensor's vendor's name (non localized)
464 */
465const char* ASensor_getVendor(ASensor const* sensor);
466
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700467/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700468 * Return this sensor's type
469 */
470int ASensor_getType(ASensor const* sensor);
471
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700472/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700473 * Returns this sensors's resolution
474 */
475float ASensor_getResolution(ASensor const* sensor);
476
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700477/**
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700478 * Returns the minimum delay allowed between events in microseconds.
479 * A value of zero means that this sensor doesn't report events at a
480 * constant rate, but rather only when a new data is available.
481 */
482int ASensor_getMinDelay(ASensor const* sensor);
483
Dan Albert494ed552016-09-23 15:57:45 -0700484#if __ANDROID_API__ >= 21
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700485/**
Aravind Akella70018042014-04-07 22:52:37 +0000486 * Returns the maximum size of batches for this sensor. Batches will often be
487 * smaller, as the hardware fifo might be used for other sensors.
488 */
489int ASensor_getFifoMaxEventCount(ASensor const* sensor);
490
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700491/**
Aravind Akella70018042014-04-07 22:52:37 +0000492 * Returns the hardware batch fifo size reserved to this sensor.
493 */
494int ASensor_getFifoReservedEventCount(ASensor const* sensor);
495
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700496/**
Aravind Akella70018042014-04-07 22:52:37 +0000497 * Returns this sensor's string type.
498 */
499const char* ASensor_getStringType(ASensor const* sensor);
500
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700501/**
Aravind Akella0e025c52014-06-03 19:19:57 -0700502 * Returns the reporting mode for this sensor. One of AREPORTING_MODE_* constants.
503 */
504int ASensor_getReportingMode(ASensor const* sensor);
505
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700506/**
Aravind Akellab37ba392014-08-05 14:53:07 -0700507 * Returns true if this is a wake up sensor, false otherwise.
508 */
509bool ASensor_isWakeUpSensor(ASensor const* sensor);
Dan Albert494ed552016-09-23 15:57:45 -0700510#endif /* __ANDROID_API__ >= 21 */
Aravind Akellab37ba392014-08-05 14:53:07 -0700511
Mathias Agopiane1c61d32012-03-23 14:19:36 -0700512#ifdef __cplusplus
513};
514#endif
515
516#endif // ANDROID_SENSOR_H
Johan Euphrosinebf6d5e02015-03-27 17:15:43 -0700517
518/** @} */