Loading services/sensorservice/SensorService.cpp +7 −1 Original line number Original line Diff line number Diff line Loading @@ -1748,17 +1748,22 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, const int halVersion = dev.getHalDeviceVersion(); const int halVersion = dev.getHalDeviceVersion(); status_t err(NO_ERROR); status_t err(NO_ERROR); Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); size_t numSensors = 0; // Loop through all sensors for this connection and call flush on each of them. // Loop through all sensors for this connection and call flush on each of them. for (int handle : connection->getActiveSensorHandles()) { for (int handle : connection->getActiveSensorHandles()) { sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle); sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle); if (sensor == nullptr) { if (sensor == nullptr) { continue; continue; } } numSensors++; if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) { if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) { ALOGE("flush called on a one-shot sensor"); ALOGE("flush called on a one-shot sensor"); err = INVALID_OPERATION; err = INVALID_OPERATION; continue; continue; } } if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) { if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) { // For older devices just increment pending flush count which will send a trivial // For older devices just increment pending flush count which will send a trivial // flush complete event. // flush complete event. Loading @@ -1776,7 +1781,8 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, err = (err_flush != NO_ERROR) ? err_flush : err; err = (err_flush != NO_ERROR) ? err_flush : err; } } } } return err; return (numSensors == 0) ? INVALID_OPERATION : err; } } bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, Loading Loading
services/sensorservice/SensorService.cpp +7 −1 Original line number Original line Diff line number Diff line Loading @@ -1748,17 +1748,22 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, const int halVersion = dev.getHalDeviceVersion(); const int halVersion = dev.getHalDeviceVersion(); status_t err(NO_ERROR); status_t err(NO_ERROR); Mutex::Autolock _l(mLock); Mutex::Autolock _l(mLock); size_t numSensors = 0; // Loop through all sensors for this connection and call flush on each of them. // Loop through all sensors for this connection and call flush on each of them. for (int handle : connection->getActiveSensorHandles()) { for (int handle : connection->getActiveSensorHandles()) { sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle); sp<SensorInterface> sensor = getSensorInterfaceFromHandle(handle); if (sensor == nullptr) { if (sensor == nullptr) { continue; continue; } } numSensors++; if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) { if (sensor->getSensor().getReportingMode() == AREPORTING_MODE_ONE_SHOT) { ALOGE("flush called on a one-shot sensor"); ALOGE("flush called on a one-shot sensor"); err = INVALID_OPERATION; err = INVALID_OPERATION; continue; continue; } } if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) { if (halVersion <= SENSORS_DEVICE_API_VERSION_1_0 || isVirtualSensor(handle)) { // For older devices just increment pending flush count which will send a trivial // For older devices just increment pending flush count which will send a trivial // flush complete event. // flush complete event. Loading @@ -1776,7 +1781,8 @@ status_t SensorService::flushSensor(const sp<SensorEventConnection>& connection, err = (err_flush != NO_ERROR) ? err_flush : err; err = (err_flush != NO_ERROR) ? err_flush : err; } } } } return err; return (numSensors == 0) ? INVALID_OPERATION : err; } } bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, bool SensorService::canAccessSensor(const Sensor& sensor, const char* operation, Loading