diff options
author | Aravind Akella <aakella@google.com> | 2013-10-25 23:16:59 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-10-25 23:16:59 +0000 |
commit | 46417b845a257d6725adf048a3cfad6306218e9b (patch) | |
tree | 04a04465925c3a46ad72565190f5bbc93100fe32 | |
parent | 708cc794f6ccd4d31e0a00a23b289272c665adc1 (diff) | |
parent | b4099e77ec2bf8e9d4259ff30f0cb1d621deed91 (diff) | |
download | native-46417b845a257d6725adf048a3cfad6306218e9b.tar.gz |
Merge "Bug fixes for SensorService" into klp-dev
-rw-r--r-- | services/sensorservice/SensorService.cpp | 12 | ||||
-rw-r--r-- | services/sensorservice/SensorService.h | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 555d843549..a2f4332793 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -480,6 +480,11 @@ String8 SensorService::getSensorName(int handle) const { return result; } +bool SensorService::isVirtualSensor(int handle) const { + SensorInterface* sensor = mSensorMap.valueFor(handle); + return sensor->isVirtual(); +} + Vector<Sensor> SensorService::getSensorList() { char value[PROPERTY_VALUE_MAX]; @@ -858,6 +863,11 @@ status_t SensorService::SensorEventConnection::sendEvents( } } + // Early return if there are no events for this connection. + if (count == 0) { + return status_t(NO_ERROR); + } + // NOTE: ASensorEvent and sensors_event_t are the same type ssize_t size = SensorEventQueue::write(mChannel, reinterpret_cast<ASensorEvent const*>(scratch), count); @@ -922,7 +932,7 @@ status_t SensorService::SensorEventConnection::flush() { // Loop through all sensors for this connection and call flush on each of them. for (size_t i = 0; i < mSensorInfo.size(); ++i) { const int handle = mSensorInfo.keyAt(i); - if (halVersion < SENSORS_DEVICE_API_VERSION_1_1) { + if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 || mService->isVirtualSensor(handle)) { // For older devices just increment pending flush count which will send a trivial // flush complete event. FlushInfo& flushInfo = mSensorInfo.editValueFor(handle); diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 6c1691a030..c9683197f5 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -130,6 +130,7 @@ class SensorService : DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const; String8 getSensorName(int handle) const; + bool isVirtualSensor(int handle) const; void recordLastValue(sensors_event_t const * buffer, size_t count); static void sortEventBuffer(sensors_event_t* buffer, size_t count); Sensor registerSensor(SensorInterface* sensor); |