diff options
author | Mathias Agopian <mathias@google.com> | 2010-11-29 17:26:51 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2012-06-27 17:07:54 -0700 |
commit | 50b66767f6c5635430483393e17d15969dfe2f05 (patch) | |
tree | 62204a2e607a9e53abb466befadae3240650de66 /services/sensorservice/RotationVectorSensor.cpp | |
parent | 87c9dbb728febe9ce035874796c58f308043879d (diff) | |
download | frameworks_native-50b66767f6c5635430483393e17d15969dfe2f05.zip frameworks_native-50b66767f6c5635430483393e17d15969dfe2f05.tar.gz frameworks_native-50b66767f6c5635430483393e17d15969dfe2f05.tar.bz2 |
fix [3237242] sensormanager sensor active count gets out of sync
whether a physical sensor needed to be active or not was managed by
a simpe reference counter; unfortunatelly nothing prevented it to
get out of sync if a sensor was disabled more than once.
sensorservice already maintainted a list of all the "clients"
connected to a physical sensor; we now use that list to determine if
a sensor should be enabled. This can never be "out-of-sync" since
this is the only data structure linking a sensor to a user of that
sensor.
also removed the isEnabled() method, which was never used and
implemented wrongly (since it didn't take into account that a sensor
could be disabled for a client but not of another).
Change-Id: I789affb877728ca957e99f7ba749def37c4db1c7
Diffstat (limited to 'services/sensorservice/RotationVectorSensor.cpp')
-rw-r--r-- | services/sensorservice/RotationVectorSensor.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/services/sensorservice/RotationVectorSensor.cpp b/services/sensorservice/RotationVectorSensor.cpp index 50cd6be..418e7f8 100644 --- a/services/sensorservice/RotationVectorSensor.cpp +++ b/services/sensorservice/RotationVectorSensor.cpp @@ -34,7 +34,6 @@ static inline T clamp(T v) { RotationVectorSensor::RotationVectorSensor(sensor_t const* list, size_t count) : mSensorDevice(SensorDevice::getInstance()), - mEnabled(false), mALowPass(M_SQRT1_2, 5.0f), mAX(mALowPass), mAY(mALowPass), mAZ(mALowPass), mMLowPass(M_SQRT1_2, 2.5f), @@ -133,19 +132,12 @@ bool RotationVectorSensor::process(sensors_event_t* outEvent, return false; } -bool RotationVectorSensor::isEnabled() const { - return mEnabled; -} - status_t RotationVectorSensor::activate(void* ident, bool enabled) { - if (mEnabled != enabled) { - mSensorDevice.activate(this, mAcc.getHandle(), enabled); - mSensorDevice.activate(this, mMag.getHandle(), enabled); - mEnabled = enabled; - if (enabled) { - mMagTime = 0; - mAccTime = 0; - } + mSensorDevice.activate(this, mAcc.getHandle(), enabled); + mSensorDevice.activate(this, mMag.getHandle(), enabled); + if (enabled) { + mMagTime = 0; + mAccTime = 0; } return NO_ERROR; } |