Skip to content

Commit ada1b6f

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "fix [3421350] Killing a game that uses the accelerometer renders the device unable to sleep" into gingerbread
2 parents 07cefd3 + 7dce874 commit ada1b6f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

services/sensorservice/SensorService.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,21 @@ sp<ISensorEventConnection> SensorService::createSensorEventConnection()
293293
return result;
294294
}
295295

296-
void SensorService::cleanupConnection(const wp<SensorEventConnection>& connection)
296+
void SensorService::cleanupConnection(SensorEventConnection* c)
297297
{
298298
Mutex::Autolock _l(mLock);
299+
const wp<SensorEventConnection> connection(c);
299300
size_t size = mActiveSensors.size();
300301
for (size_t i=0 ; i<size ; ) {
301-
SensorRecord* rec = mActiveSensors.valueAt(i);
302-
if (rec && rec->removeConnection(connection)) {
303-
int handle = mActiveSensors.keyAt(i);
302+
int handle = mActiveSensors.keyAt(i);
303+
if (c->hasSensor(handle)) {
304304
SensorInterface* sensor = mSensorMap.valueFor( handle );
305305
if (sensor) {
306-
sensor->activate(connection.unsafe_get(), false);
306+
sensor->activate(c, false);
307307
}
308+
}
309+
SensorRecord* rec = mActiveSensors.valueAt(i);
310+
if (rec && rec->removeConnection(connection)) {
308311
mActiveSensors.removeItemsAt(i, 1);
309312
mActiveVirtualSensors.removeItem(handle);
310313
delete rec;

services/sensorservice/SensorService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SensorService :
129129
public:
130130
static char const* getServiceName() { return "sensorservice"; }
131131

132-
void cleanupConnection(const wp<SensorEventConnection>& connection);
132+
void cleanupConnection(SensorEventConnection* connection);
133133
status_t enable(const sp<SensorEventConnection>& connection, int handle);
134134
status_t disable(const sp<SensorEventConnection>& connection, int handle);
135135
status_t setEventRate(const sp<SensorEventConnection>& connection, int handle, nsecs_t ns);

0 commit comments

Comments
 (0)