diff options
| author | Mathias Agopian <mathias@google.com> | 2010-11-29 17:26:51 -0800 |
|---|---|---|
| committer | Mathias Agopian <mathias@google.com> | 2010-11-30 15:41:16 -0800 |
| commit | b483d5cd134cda393824fd8e9c1a5443bd868ae6 (patch) | |
| tree | 69874006f190dd4a8407f297a04538f61ea27267 /services/sensorservice/SensorInterface.cpp | |
| parent | 186b68b74417e8ef73f2083769166e7785df6c30 (diff) | |
| download | frameworks_base-b483d5cd134cda393824fd8e9c1a5443bd868ae6.zip frameworks_base-b483d5cd134cda393824fd8e9c1a5443bd868ae6.tar.gz frameworks_base-b483d5cd134cda393824fd8e9c1a5443bd868ae6.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/SensorInterface.cpp')
| -rw-r--r-- | services/sensorservice/SensorInterface.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/services/sensorservice/SensorInterface.cpp b/services/sensorservice/SensorInterface.cpp index 93d23d9..be8eaff 100644 --- a/services/sensorservice/SensorInterface.cpp +++ b/services/sensorservice/SensorInterface.cpp @@ -32,7 +32,7 @@ SensorInterface::~SensorInterface() HardwareSensor::HardwareSensor(const sensor_t& sensor) : mSensorDevice(SensorDevice::getInstance()), - mSensor(&sensor), mEnabled(false) + mSensor(&sensor) { LOGI("%s", sensor.name); } @@ -46,15 +46,8 @@ bool HardwareSensor::process(sensors_event_t* outEvent, return true; } -bool HardwareSensor::isEnabled() const { - return mEnabled; -} - -status_t HardwareSensor::activate(void* ident,bool enabled) { - status_t err = mSensorDevice.activate(ident, mSensor.getHandle(), enabled); - if (err == NO_ERROR) - mEnabled = enabled; - return err; +status_t HardwareSensor::activate(void* ident, bool enabled) { + return mSensorDevice.activate(ident, mSensor.getHandle(), enabled); } status_t HardwareSensor::setDelay(void* ident, int handle, int64_t ns) { |
