diff options
| author | Mathias Agopian <mathias@google.com> | 2010-11-15 13:19:46 -0800 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-11-15 13:19:46 -0800 |
| commit | f11bf284d355e2a8378c6a37a7ed702705ec6144 (patch) | |
| tree | 7b8e8d446873b87312e54bf6c384312596f2cdd7 /services/sensorservice/SensorService.cpp | |
| parent | 99866c111bd72a6cc9be17b127cd40ec9396ca7d (diff) | |
| parent | 305bc0fe977f6197bfae847dbaf58916cf8980ba (diff) | |
| download | frameworks_base-f11bf284d355e2a8378c6a37a7ed702705ec6144.zip frameworks_base-f11bf284d355e2a8378c6a37a7ed702705ec6144.tar.gz frameworks_base-f11bf284d355e2a8378c6a37a7ed702705ec6144.tar.bz2 | |
am 305bc0fe: Merge "Fix a race condition in sensormanager" into gingerbread
* commit '305bc0fe977f6197bfae847dbaf58916cf8980ba':
Fix a race condition in sensormanager
Diffstat (limited to 'services/sensorservice/SensorService.cpp')
| -rw-r--r-- | services/sensorservice/SensorService.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index b5e73ac..22a45df 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -464,6 +464,7 @@ void SensorService::SensorEventConnection::onFirstRef() } bool SensorService::SensorEventConnection::addSensor(int32_t handle) { + Mutex::Autolock _l(mConnectionLock); if (mSensorInfo.indexOfKey(handle) <= 0) { SensorInfo info; mSensorInfo.add(handle, info); @@ -473,6 +474,7 @@ bool SensorService::SensorEventConnection::addSensor(int32_t handle) { } bool SensorService::SensorEventConnection::removeSensor(int32_t handle) { + Mutex::Autolock _l(mConnectionLock); if (mSensorInfo.removeItem(handle) >= 0) { return true; } @@ -480,16 +482,19 @@ bool SensorService::SensorEventConnection::removeSensor(int32_t handle) { } bool SensorService::SensorEventConnection::hasSensor(int32_t handle) const { + Mutex::Autolock _l(mConnectionLock); return mSensorInfo.indexOfKey(handle) >= 0; } bool SensorService::SensorEventConnection::hasAnySensor() const { + Mutex::Autolock _l(mConnectionLock); return mSensorInfo.size() ? true : false; } status_t SensorService::SensorEventConnection::setEventRateLocked( int handle, nsecs_t ns) { + Mutex::Autolock _l(mConnectionLock); ssize_t index = mSensorInfo.indexOfKey(handle); if (index >= 0) { SensorInfo& info = mSensorInfo.editValueFor(handle); @@ -506,6 +511,7 @@ status_t SensorService::SensorEventConnection::sendEvents( // filter out events not for this connection size_t count = 0; if (scratch) { + Mutex::Autolock _l(mConnectionLock); size_t i=0; while (i<numEvents) { const int32_t curr = buffer[i].sensor; |
