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

Commit a8f3fd4e authored by Brian Duddie's avatar Brian Duddie Committed by Automerger Merge Worker
Browse files

Fix batterystats update on sensor connection cleanup am: 7be8557f

parents cf4f8519 7be8557f
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -74,23 +74,6 @@ void BatteryService::disableSensorImpl(uid_t uid, int handle) {
    }
}

void BatteryService::cleanupImpl(uid_t uid) {
    if (checkService()) {
        Mutex::Autolock _l(mActivationsLock);
        int64_t identity = IPCThreadState::self()->clearCallingIdentity();
        for (size_t i=0 ; i<mActivations.size() ; ) {
            const Info& info(mActivations[i]);
            if (info.uid == uid) {
                mBatteryStatService->noteStopSensor(info.uid, info.handle);
                mActivations.removeAt(i);
            } else {
              i++;
            }
        }
        IPCThreadState::self()->restoreCallingIdentity(identity);
    }
}

bool BatteryService::checkService() {
    if (mBatteryStatService == nullptr) {
        const sp<IServiceManager> sm(defaultServiceManager());
+0 −4
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ class BatteryService : public Singleton<BatteryService> {

    void enableSensorImpl(uid_t uid, int handle);
    void disableSensorImpl(uid_t uid, int handle);
    void cleanupImpl(uid_t uid);

    struct Info {
        uid_t uid;
@@ -58,9 +57,6 @@ public:
    static void disableSensor(uid_t uid, int handle) {
        BatteryService::getInstance().disableSensorImpl(uid, handle);
    }
    static void cleanup(uid_t uid) {
        BatteryService::getInstance().cleanupImpl(uid);
    }
};

// ---------------------------------------------------------------------------
+3 −2
Original line number Diff line number Diff line
@@ -1611,7 +1611,9 @@ void SensorService::cleanupConnection(SensorEventConnection* c) {
            } else {
                ALOGE("sensor interface of handle=0x%08x is null!", handle);
            }
            c->removeSensor(handle);
            if (c->removeSensor(handle)) {
                BatteryService::disableSensor(c->getUid(), handle);
            }
        }
        SensorRecord* rec = mActiveSensors.valueAt(i);
        ALOGE_IF(!rec, "mActiveSensors[%zu] is null (handle=0x%08x)!", i, handle);
@@ -1631,7 +1633,6 @@ void SensorService::cleanupConnection(SensorEventConnection* c) {
    }
    c->updateLooperRegistration(mLooper);
    mConnectionHolder.removeEventConnection(connection);
    BatteryService::cleanup(c->getUid());
    if (c->needsWakeLock()) {
        checkWakeLockStateLocked(&connLock);
    }