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

Commit 39432497 authored by Brian Stack's avatar Brian Stack Committed by android-build-merger
Browse files

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

am: 6b6cee2c

Change-Id: I504c1e029fcbe952916999278123de111d10cbe4
parents fea9de6e 6b6cee2c
Loading
Loading
Loading
Loading
+8 −4
Original line number 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.numActiveClients() == 1) {
              // This is the first connection, we need to activate the underlying h/w sensor.
            if (info.numActiveClients() > 0 && !info.isActive) {
                actuateHardware = true;
            }
        } else {
@@ -631,6 +630,11 @@ status_t SensorDevice::activateLocked(void* ident, int handle, int enabled) {
        if (err != NO_ERROR && enabled) {
            // Failure when enabling the sensor. Clean up on failure.
            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 Diff line number Diff line
@@ -165,6 +165,9 @@ private:
        // requested by the client.
        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
        // in the KeyedVector above.
        status_t setBatchParamsForIdent(void* ident, int flags, int64_t samplingPeriodNs,