diff options
author | Aravind Akella <aakella@google.com> | 2013-10-08 14:59:26 -0700 |
---|---|---|
committer | Aravind Akella <aakella@google.com> | 2013-10-09 17:26:01 -0700 |
commit | 701166d9f60a6e1149ff568aec0e03f3f3925292 (patch) | |
tree | c13bc43503cc3140efa88323823a8a79eb90b49c /services/sensorservice | |
parent | d457ec52d7023e9a6112f313cd2bf94293162214 (diff) | |
download | frameworks_native-701166d9f60a6e1149ff568aec0e03f3f3925292.zip frameworks_native-701166d9f60a6e1149ff568aec0e03f3f3925292.tar.gz frameworks_native-701166d9f60a6e1149ff568aec0e03f3f3925292.tar.bz2 |
Change API from flush(handle) to flush(). Call flush on all active sensors in the given SensorEventConnection.
Change-Id: I4ef2bec80406c517903ab9782dc9eaf3fa8b7f36
Diffstat (limited to 'services/sensorservice')
-rw-r--r-- | services/sensorservice/SensorService.cpp | 22 | ||||
-rw-r--r-- | services/sensorservice/SensorService.h | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index b26e572..af605de 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -679,8 +679,12 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, int handle) { if (mInitCheck != NO_ERROR) return mInitCheck; SensorInterface* sensor = mSensorMap.valueFor(handle); - if (sensor == NULL) { - return BAD_VALUE; + if (sensor == NULL) { + return BAD_VALUE; + } + if (sensor->getSensor().getType() == SENSOR_TYPE_SIGNIFICANT_MOTION) { + ALOGE("flush called on Significant Motion sensor"); + return INVALID_OPERATION; } SensorDevice& dev(SensorDevice::getInstance()); @@ -934,8 +938,18 @@ status_t SensorService::SensorEventConnection::setEventRate( return mService->setEventRate(this, handle, samplingPeriodNs); } -status_t SensorService::SensorEventConnection::flushSensor(int handle) { - return mService->flushSensor(this, handle); +status_t SensorService::SensorEventConnection::flush() { + Mutex::Autolock _l(mConnectionLock); + status_t err(NO_ERROR); + for (size_t i = 0; i < mSensorInfo.size(); ++i) { + const int handle = mSensorInfo.keyAt(i); + status_t err_flush = mService->flushSensor(this, handle); + if (err_flush != NO_ERROR) { + ALOGE("Flush error handle=%d %s", handle, strerror(-err_flush)); + } + err = (err_flush != NO_ERROR) ? err_flush : err; + } + return err; } // --------------------------------------------------------------------------- diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 2311bff..2d40071 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -79,7 +79,7 @@ class SensorService : virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs, nsecs_t maxBatchReportLatencyNs, int reservedFlags); virtual status_t setEventRate(int handle, nsecs_t samplingPeriodNs); - virtual status_t flushSensor(int handle); + virtual status_t flush(); // Count the number of flush complete events which are about to be dropped in the buffer. // Increment mPendingFlushEventsToSend in mSensorInfo. These flush complete events will be // sent separately before the next batch of events. |