diff options
| author | 2011-02-09 13:06:00 -0800 | |
|---|---|---|
| committer | 2011-02-09 13:06:00 -0800 | |
| commit | ada1b6f297596cac4451edbc83df060a31cdda68 (patch) | |
| tree | c871e06265c3bacb1eba65edef78923e82ca3cd3 | |
| parent | 07cefd3cc3d8d27750e4fc725d9aec86250750dd (diff) | |
| parent | 7dce874f0dae08627137044e25d6efb573dc37f5 (diff) | |
Merge "fix [3421350] Killing a game that uses the accelerometer renders the device unable to sleep" into gingerbread
| -rw-r--r-- | services/sensorservice/SensorService.cpp | 13 | ||||
| -rw-r--r-- | services/sensorservice/SensorService.h | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index ea5e5ccd8e25..697e879207ec 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -293,18 +293,21 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection() return result; } -void SensorService::cleanupConnection(const wp<SensorEventConnection>& connection) +void SensorService::cleanupConnection(SensorEventConnection* c) { Mutex::Autolock _l(mLock); + const wp<SensorEventConnection> connection(c); size_t size = mActiveSensors.size(); for (size_t i=0 ; i<size ; ) { - SensorRecord* rec = mActiveSensors.valueAt(i); - if (rec && rec->removeConnection(connection)) { - int handle = mActiveSensors.keyAt(i); + int handle = mActiveSensors.keyAt(i); + if (c->hasSensor(handle)) { SensorInterface* sensor = mSensorMap.valueFor( handle ); if (sensor) { - sensor->activate(connection.unsafe_get(), false); + sensor->activate(c, false); } + } + SensorRecord* rec = mActiveSensors.valueAt(i); + if (rec && rec->removeConnection(connection)) { mActiveSensors.removeItemsAt(i, 1); mActiveVirtualSensors.removeItem(handle); delete rec; diff --git a/services/sensorservice/SensorService.h b/services/sensorservice/SensorService.h index 540c7e2a5fe8..21f12bdbcf42 100644 --- a/services/sensorservice/SensorService.h +++ b/services/sensorservice/SensorService.h @@ -129,7 +129,7 @@ class SensorService : public: static char const* getServiceName() { return "sensorservice"; } - void cleanupConnection(const wp<SensorEventConnection>& connection); + void cleanupConnection(SensorEventConnection* connection); status_t enable(const sp<SensorEventConnection>& connection, int handle); status_t disable(const sp<SensorEventConnection>& connection, int handle); status_t setEventRate(const sp<SensorEventConnection>& connection, int handle, nsecs_t ns); |