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

Commit 6b6cee2c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Track if sensor is active" into qt-dev

parents 3d6cc993 0c305fe0
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -579,8 +579,7 @@ status_t SensorDevice::activateLocked(void* ident, int handle, int enabled) {
        }
        }


        if (info.batchParams.indexOfKey(ident) >= 0) {
        if (info.batchParams.indexOfKey(ident) >= 0) {
          if (info.numActiveClients() == 1) {
            if (info.numActiveClients() > 0 && !info.isActive) {
              // This is the first connection, we need to activate the underlying h/w sensor.
                actuateHardware = true;
                actuateHardware = true;
            }
            }
        } else {
        } else {
@@ -631,6 +630,11 @@ status_t SensorDevice::activateLocked(void* ident, int handle, int enabled) {
        if (err != NO_ERROR && enabled) {
        if (err != NO_ERROR && enabled) {
            // Failure when enabling the sensor. Clean up on failure.
            // Failure when enabling the sensor. Clean up on failure.
            info.removeBatchParamsForIdent(ident);
            info.removeBatchParamsForIdent(ident);
        } else {
            // Update the isActive flag if there is no error. If there is an error when disabling a
            // sensor, still set the flag to false since the batch parameters have already been
            // removed. This ensures that everything remains in-sync.
            info.isActive = enabled;
        }
        }
    }
    }


+3 −0
Original line number Original line Diff line number Diff line
@@ -165,6 +165,9 @@ private:
        // requested by the client.
        // requested by the client.
        KeyedVector<void*, BatchParams> batchParams;
        KeyedVector<void*, BatchParams> batchParams;


        // Flag to track if the sensor is active
        bool isActive = false;

        // Sets batch parameters for this ident. Returns error if this ident is not already present
        // Sets batch parameters for this ident. Returns error if this ident is not already present
        // in the KeyedVector above.
        // in the KeyedVector above.
        status_t setBatchParamsForIdent(void* ident, int flags, int64_t samplingPeriodNs,
        status_t setBatchParamsForIdent(void* ident, int flags, int64_t samplingPeriodNs,