summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsensors_iio/src/HWSensorBase.cpp14
-rw-r--r--libsensors_iio/src/SensorHAL.cpp4
2 files changed, 12 insertions, 6 deletions
diff --git a/libsensors_iio/src/HWSensorBase.cpp b/libsensors_iio/src/HWSensorBase.cpp
index ea7078b..24ed9f2 100644
--- a/libsensors_iio/src/HWSensorBase.cpp
+++ b/libsensors_iio/src/HWSensorBase.cpp
@@ -303,12 +303,14 @@ int HWSensorBase::FlushData()
{
int err;
- if (GetStatus() && (current_fifo_len > HW_SENSOR_BASE_DEFAULT_IIO_BUFFER_LEN)) {
- err = write_sysfs_int((char *)FILENAME_FLUSH, common_data.iio_sysfs_path, 1);
- if (err < 0) {
- ALOGE("%s: Failed to write flush file \"%s/%s\".",
- common_data.device_name, common_data.iio_sysfs_path, FILENAME_FLUSH);
- return -EINVAL;
+ if (GetStatus()) {
+ if (current_fifo_len > HW_SENSOR_BASE_DEFAULT_IIO_BUFFER_LEN) {
+ err = write_sysfs_int((char *)FILENAME_FLUSH, common_data.iio_sysfs_path, 1);
+ if (err < 0) {
+ ALOGE("%s: Failed to write flush file \"%s/%s\".",
+ common_data.device_name, common_data.iio_sysfs_path, FILENAME_FLUSH);
+ return -EINVAL;
+ }
}
} else
return -EINVAL;
diff --git a/libsensors_iio/src/SensorHAL.cpp b/libsensors_iio/src/SensorHAL.cpp
index e25771f..213cb85 100644
--- a/libsensors_iio/src/SensorHAL.cpp
+++ b/libsensors_iio/src/SensorHAL.cpp
@@ -584,6 +584,10 @@ st_hal_load_free_iio_sysfs_path:
static int st_hal_dev_flush(struct sensors_poll_device_1 *dev, int handle)
{
STSensorHAL_data *hal_data = (STSensorHAL_data *)dev;
+ ALOGD("st_hal_dev_flush type=%d", ((struct sensor_t) hal_data->sensor_t_list[handle]).type);
+ /* One-shot sensor must return -EINVAL and not generate any flush complete metadata event */
+ if (SENSOR_TYPE_SIGNIFICANT_MOTION == ((struct sensor_t) hal_data->sensor_t_list[handle]).type)
+ return -EINVAL;
return hal_data->sensor_classes[handle]->FlushData();
}