summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAravind Akella <aakella@google.com>2013-10-08 14:59:26 -0700
committerThe Android Automerger <android-build@google.com>2013-10-11 12:42:13 -0700
commit4c4cd9c8cc91ec4d221ceabd58b84ab226bd38f1 (patch)
treed072a671aabe0adba9a2aecd7a58ced55f5092e5
parenta8b5982c32f6232428e9dcab691bb0bca6f72d63 (diff)
downloadnative-4c4cd9c8cc91ec4d221ceabd58b84ab226bd38f1.tar.gz
Change API from flush(handle) to flush(). Call flush on all active sensors in the given SensorEventConnection.
Change-Id: I4ef2bec80406c517903ab9782dc9eaf3fa8b7f36
-rw-r--r--include/gui/ISensorEventConnection.h2
-rw-r--r--include/gui/SensorEventQueue.h2
-rw-r--r--libs/gui/ISensorEventConnection.cpp6
-rw-r--r--libs/gui/SensorEventQueue.cpp4
-rw-r--r--services/sensorservice/SensorService.cpp22
-rw-r--r--services/sensorservice/SensorService.h2
6 files changed, 25 insertions, 13 deletions
diff --git a/include/gui/ISensorEventConnection.h b/include/gui/ISensorEventConnection.h
index 00eecc4796..f64c6b8604 100644
--- a/include/gui/ISensorEventConnection.h
+++ b/include/gui/ISensorEventConnection.h
@@ -39,7 +39,7 @@ public:
virtual status_t enableDisable(int handle, bool enabled, nsecs_t samplingPeriodNs,
nsecs_t maxBatchReportLatencyNs, int reservedFlags) = 0;
virtual status_t setEventRate(int handle, nsecs_t ns) = 0;
- virtual status_t flushSensor(int handle) = 0;
+ virtual status_t flush() = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/gui/SensorEventQueue.h b/include/gui/SensorEventQueue.h
index a3a9daa6d4..0bfc7a0dfc 100644
--- a/include/gui/SensorEventQueue.h
+++ b/include/gui/SensorEventQueue.h
@@ -74,7 +74,7 @@ public:
status_t enableSensor(int32_t handle, int32_t samplingPeriodUs, int maxBatchReportLatencyUs,
int reservedFlags) const;
status_t disableSensor(int32_t handle) const;
- status_t flushSensor(int32_t handle) const;
+ status_t flush() const;
private:
sp<Looper> getLooper() const;
diff --git a/libs/gui/ISensorEventConnection.cpp b/libs/gui/ISensorEventConnection.cpp
index a80c661cb3..28fcb53d8f 100644
--- a/libs/gui/ISensorEventConnection.cpp
+++ b/libs/gui/ISensorEventConnection.cpp
@@ -77,10 +77,9 @@ public:
return reply.readInt32();
}
- virtual status_t flushSensor(int handle) {
+ virtual status_t flush() {
Parcel data, reply;
data.writeInterfaceToken(ISensorEventConnection::getInterfaceDescriptor());
- data.writeInt32(handle);
remote()->transact(FLUSH_SENSOR, data, &reply);
return reply.readInt32();
}
@@ -122,8 +121,7 @@ status_t BnSensorEventConnection::onTransact(
} break;
case FLUSH_SENSOR: {
CHECK_INTERFACE(ISensorEventConnection, data, reply);
- int handle = data.readInt32();
- status_t result = flushSensor(handle);
+ status_t result = flush();
reply->writeInt32(result);
return NO_ERROR;
} break;
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index ab50c1d730..c3656718db 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -132,8 +132,8 @@ status_t SensorEventQueue::enableSensor(int32_t handle, int32_t samplingPeriodUs
us2ns(maxBatchReportLatencyUs), reservedFlags);
}
-status_t SensorEventQueue::flushSensor(int32_t handle) const {
- return mSensorEventConnection->flushSensor(handle);
+status_t SensorEventQueue::flush() const {
+ return mSensorEventConnection->flush();
}
status_t SensorEventQueue::disableSensor(int32_t handle) const {
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index b26e5722fa..af605deb66 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 2311bff290..2d40071a48 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.