Loading services/sensorservice/SensorDevice.cpp +8 −4 Original line number Original line Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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; } } } } Loading services/sensorservice/SensorDevice.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -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, Loading Loading
services/sensorservice/SensorDevice.cpp +8 −4 Original line number Original line Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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; } } } } Loading
services/sensorservice/SensorDevice.h +3 −0 Original line number Original line Diff line number Diff line Loading @@ -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, Loading