diff options
| author | 2017-03-08 01:30:59 +0000 | |
|---|---|---|
| committer | 2017-03-08 01:31:05 +0000 | |
| commit | d3fcb6ca24f11e5621b9068f18e347f53ac29124 (patch) | |
| tree | c0c56fba09749d107c62baf8caf892d4b6fa4caa | |
| parent | 077f132c19e731d25973bbab1c6dc319beb3f460 (diff) | |
| parent | da8385cb97ba40ab87e7e9b8d5b7c8f0ba5ba0fd (diff) | |
Merge "Add ASensorEventQueue_registerSensor and default error value"
| -rw-r--r-- | include/android/sensor.h | 28 | ||||
| -rw-r--r-- | libs/sensor/SensorEventQueue.cpp | 2 | ||||
| -rw-r--r-- | libs/sensor/include/sensor/SensorEventQueue.h | 2 |
3 files changed, 21 insertions, 11 deletions
diff --git a/include/android/sensor.h b/include/android/sensor.h index a5e5c057f8..d9998ba425 100644 --- a/include/android/sensor.h +++ b/include/android/sensor.h @@ -48,16 +48,22 @@ * */ -#include <sys/types.h> - #include <android/looper.h> +#include <sys/types.h> +#include <math.h> +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif typedef struct AHardwareBuffer AHardwareBuffer; +#define ASENSOR_RESOLUTION_INVALID (nanf("")) +#define ASENSOR_FIFO_COUNT_INVALID (-1) +#define ASENSOR_DELAY_INVALID INT32_MIN + /** * Sensor types. * (keep in sync with hardware/sensors.h) @@ -112,7 +118,11 @@ enum { * All values are in SI units (m/s^2) and measure the acceleration of the * device not including the force of gravity. */ - ASENSOR_TYPE_LINEAR_ACCELERATION = 10 + ASENSOR_TYPE_LINEAR_ACCELERATION = 10, + /** + * Invalid sensor type. Returned by {@link ASensor_getType} as error value. + */ + ASENSOR_TYPE_INVALID = -1 }; /** @@ -142,7 +152,9 @@ enum { /** on shot reporting */ AREPORTING_MODE_ONE_SHOT = 2, /** special trigger reporting */ - AREPORTING_MODE_SPECIAL_TRIGGER = 3 + AREPORTING_MODE_SPECIAL_TRIGGER = 3, + /** invalid reporting mode */ + AREPORTING_MODE_INVALID = -1 }; /** @@ -397,8 +409,7 @@ ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type * Returns the default sensor with the given type and wakeUp properties or NULL if no sensor * of this type and wakeUp properties exists. */ -ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, - bool wakeUp); +ASensor const* ASensorManager_getDefaultSensorEx(ASensorManager* manager, int type, bool wakeUp); #endif /** @@ -516,7 +527,7 @@ int ASensorManager_configureDirectReport( * Note: To disable the selected sensor, use ASensorEventQueue_disableSensor() same as before. */ int ASensorEventQueue_registerSensor(ASensorEventQueue* queue, ASensor const* sensor, - int32_t samplingPeriodUs, int maxBatchReportLatencyUs); + int32_t samplingPeriodUs, int64_t maxBatchReportLatencyUs); /** * Enable the selected sensor. Returns a negative error code on failure. @@ -557,8 +568,7 @@ int ASensorEventQueue_hasEvents(ASensorEventQueue* queue); * ssize_t numEvent = ASensorEventQueue_getEvents(queue, eventBuffer, 8); * */ -ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, - ASensorEvent* events, size_t count); +ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, ASensorEvent* events, size_t count); /*****************************************************************************/ diff --git a/libs/sensor/SensorEventQueue.cpp b/libs/sensor/SensorEventQueue.cpp index 8ba3ebe17d..6f68fb5f7b 100644 --- a/libs/sensor/SensorEventQueue.cpp +++ b/libs/sensor/SensorEventQueue.cpp @@ -135,7 +135,7 @@ status_t SensorEventQueue::disableSensor(Sensor const* sensor) const { } status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs, - int maxBatchReportLatencyUs, int reservedFlags) const { + int64_t maxBatchReportLatencyUs, int reservedFlags) const { return mSensorEventConnection->enableDisable(handle, true, us2ns(samplingPeriodUs), us2ns(maxBatchReportLatencyUs), reservedFlags); } diff --git a/libs/sensor/include/sensor/SensorEventQueue.h b/libs/sensor/include/sensor/SensorEventQueue.h index 84b6ab25de..a03c7eeea3 100644 --- a/libs/sensor/include/sensor/SensorEventQueue.h +++ b/libs/sensor/include/sensor/SensorEventQueue.h @@ -84,7 +84,7 @@ public: status_t setEventRate(Sensor const* sensor, nsecs_t ns) const; // these are here only to support SensorManager.java - status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs, + status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int64_t maxBatchReportLatencyUs, int reservedFlags) const; status_t disableSensor(int32_t handle) const; status_t flush() const; |