Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7dce874f authored by Mathias Agopian's avatar Mathias Agopian
Browse files

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: I400fa1c1389b2bd05a1d19abea8a35ec5bcba273
parent 40684946
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -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);
        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;
+1 −1
Original line number Diff line number Diff line
@@ -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);