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

Commit c8ad44b4 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Revert "Extend background app behavior for direct channel"

This reverts commit 14c96b10.

Bug: 74395023
Test: Revert

Change-Id: I8f41272ce8b26fa72724c6b2cf0c50b9953ee4a4
parent fb64fca3
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -93,23 +93,6 @@ sp<BitTube> SensorService::SensorDirectConnection::getSensorChannel() const {
    return nullptr;
}

void SensorService::SensorDirectConnection::updateSensorSubscriptions() {
    if (!hasSensorAccess()) {
        stopAll(true /* backupRecord */);
    } else {
        recoverAll();
    }
}

void SensorService::SensorDirectConnection::setSensorAccess(bool hasAccess) {
    mHasSensorAccess = hasAccess;
    updateSensorSubscriptions();
}

bool SensorService::SensorDirectConnection::hasSensorAccess() const {
    return mHasSensorAccess && !mService->mSensorPrivacyPolicy->isSensorPrivacyEnabled();
}

status_t SensorService::SensorDirectConnection::enableDisable(
        int handle, bool enabled, nsecs_t samplingPeriodNs, nsecs_t maxBatchReportLatencyNs,
        int reservedFlags) {
+0 −6
Original line number Diff line number Diff line
@@ -54,9 +54,6 @@ public:
    // called by SensorService when return to NORMAL mode.
    void recoverAll();

    void updateSensorSubscriptions();

    void setSensorAccess(bool hasAccess);
protected:
    virtual ~SensorDirectConnection();
    // ISensorEventConnection functions
@@ -69,7 +66,6 @@ protected:
    virtual int32_t configureChannel(int handle, int rateLevel);
    virtual void destroy();
private:
    bool hasSensorAccess() const;
    const sp<SensorService> mService;
    const uid_t mUid;
    const sensors_direct_mem_t mMem;
@@ -80,8 +76,6 @@ private:
    std::unordered_map<int, int> mActivated;
    std::unordered_map<int, int> mActivatedBackup;

    std::atomic_bool mHasSensorAccess = true;

    mutable Mutex mDestroyLock;
    bool mDestroyed;
};
+2 −9
Original line number Diff line number Diff line
@@ -302,7 +302,6 @@ void SensorService::onFirstRef() {
void SensorService::setSensorAccess(uid_t uid, bool hasAccess) {
    ConnectionSafeAutolock connLock = mConnectionHolder.lock(mLock);
    const auto& connections = connLock.getActiveConnections();
    const auto& directConnections = connLock.getDirectConnections();

    mLock.unlock();
    for (const sp<SensorEventConnection>& conn : connections) {
@@ -310,12 +309,6 @@ void SensorService::setSensorAccess(uid_t uid, bool hasAccess) {
            conn->setSensorAccess(hasAccess);
        }
    }

    for (const sp<SensorDirectConnection>& conn : directConnections) {
        if (conn->getUid() == uid) {
            conn->setSensorAccess(hasAccess);
        }
    }
}

const Sensor& SensorService::registerSensor(SensorInterface* s, bool isDebug, bool isVirtual) {
@@ -652,7 +645,7 @@ void SensorService::disableAllSensorsLocked(ConnectionSafeAutolock* connLock) {
        connection->updateSensorSubscriptions();
    }
    for (const sp<SensorDirectConnection>& connection : connLock->getDirectConnections()) {
        connection->updateSensorSubscriptions();
        connection->stopAll(true /* backupRecord */);
    }
    dev.disableAllSensors();
    // Clear all pending flush connections for all active sensors. If one of the active
@@ -683,7 +676,7 @@ void SensorService::enableAllSensorsLocked(ConnectionSafeAutolock* connLock) {
        connection->updateSensorSubscriptions();
    }
    for (const sp<SensorDirectConnection>& connection : connLock->getDirectConnections()) {
        connection->updateSensorSubscriptions();
        connection->recoverAll();
    }
}