From db5b4bce9e65ec9c2c7762b601297e4abadbc22a Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 3 Feb 2011 14:52:47 -0800 Subject: [PATCH] fix [3421350] Killing a game that uses the accelerometer renders the device unable to sleep when an app dies, make sure to disable all sensors that process is connected to, regardless of wether this was the LAST connection to this sensor. Change-Id: I9c72b1792eee03815304674d5c2f25b5270e4748 --- services/sensorservice/SensorService.cpp | 13 ++++++++----- 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 ea5e5ccd8..697e87920 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -293,18 +293,21 @@ sp SensorService::createSensorEventConnection() return result; } -void SensorService::cleanupConnection(const wp& connection) +void SensorService::cleanupConnection(SensorEventConnection* c) { Mutex::Autolock _l(mLock); + const wp connection(c); size_t size = mActiveSensors.size(); for (size_t i=0 ; iremoveConnection(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 540c7e2a5..21f12bdbc 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& connection); + void cleanupConnection(SensorEventConnection* connection); status_t enable(const sp& connection, int handle); status_t disable(const sp& connection, int handle); status_t setEventRate(const sp& connection, int handle, nsecs_t ns);