Merge "fix [3421350] Killing a game that uses the accelerometer renders the device unable to sleep" into honeycomb

This commit is contained in:
Mathias Agopian
2011-02-03 15:38:15 -08:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 6 deletions

View File

@ -293,18 +293,21 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection()
return result; return result;
} }
void SensorService::cleanupConnection(const wp<SensorEventConnection>& connection) void SensorService::cleanupConnection(SensorEventConnection* c)
{ {
Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock);
const wp<SensorEventConnection> connection(c);
size_t size = mActiveSensors.size(); size_t size = mActiveSensors.size();
for (size_t i=0 ; i<size ; ) { for (size_t i=0 ; i<size ; ) {
SensorRecord* rec = mActiveSensors.valueAt(i); int handle = mActiveSensors.keyAt(i);
if (rec && rec->removeConnection(connection)) { if (c->hasSensor(handle)) {
int handle = mActiveSensors.keyAt(i);
SensorInterface* sensor = mSensorMap.valueFor( handle ); SensorInterface* sensor = mSensorMap.valueFor( handle );
if (sensor) { 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); mActiveSensors.removeItemsAt(i, 1);
mActiveVirtualSensors.removeItem(handle); mActiveVirtualSensors.removeItem(handle);
delete rec; delete rec;

View File

@ -129,7 +129,7 @@ class SensorService :
public: public:
static char const* getServiceName() { return "sensorservice"; } 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 enable(const sp<SensorEventConnection>& connection, int handle);
status_t disable(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); status_t setEventRate(const sp<SensorEventConnection>& connection, int handle, nsecs_t ns);