Loading services/sensorservice/SensorService.cpp +11 −1 Original line number Original line Diff line number Diff line Loading @@ -480,6 +480,11 @@ String8 SensorService::getSensorName(int handle) const { return result; return result; } } bool SensorService::isVirtualSensor(int handle) const { SensorInterface* sensor = mSensorMap.valueFor(handle); return sensor->isVirtual(); } Vector<Sensor> SensorService::getSensorList() Vector<Sensor> SensorService::getSensorList() { { char value[PROPERTY_VALUE_MAX]; char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -858,6 +863,11 @@ status_t SensorService::SensorEventConnection::sendEvents( } } } } // Early return if there are no events for this connection. if (count == 0) { return status_t(NO_ERROR); } // NOTE: ASensorEvent and sensors_event_t are the same type // NOTE: ASensorEvent and sensors_event_t are the same type ssize_t size = SensorEventQueue::write(mChannel, ssize_t size = SensorEventQueue::write(mChannel, reinterpret_cast<ASensorEvent const*>(scratch), count); reinterpret_cast<ASensorEvent const*>(scratch), count); Loading Loading @@ -922,7 +932,7 @@ status_t SensorService::SensorEventConnection::flush() { // 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 (size_t i = 0; i < mSensorInfo.size(); ++i) { for (size_t i = 0; i < mSensorInfo.size(); ++i) { const int handle = mSensorInfo.keyAt(i); const int handle = mSensorInfo.keyAt(i); if (halVersion < SENSORS_DEVICE_API_VERSION_1_1) { if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 || mService->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. FlushInfo& flushInfo = mSensorInfo.editValueFor(handle); FlushInfo& flushInfo = mSensorInfo.editValueFor(handle); Loading services/sensorservice/SensorService.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -130,6 +130,7 @@ class SensorService : DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const; DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const; String8 getSensorName(int handle) const; String8 getSensorName(int handle) const; bool isVirtualSensor(int handle) const; void recordLastValue(sensors_event_t const * buffer, size_t count); void recordLastValue(sensors_event_t const * buffer, size_t count); static void sortEventBuffer(sensors_event_t* buffer, size_t count); static void sortEventBuffer(sensors_event_t* buffer, size_t count); Sensor registerSensor(SensorInterface* sensor); Sensor registerSensor(SensorInterface* sensor); Loading Loading
services/sensorservice/SensorService.cpp +11 −1 Original line number Original line Diff line number Diff line Loading @@ -480,6 +480,11 @@ String8 SensorService::getSensorName(int handle) const { return result; return result; } } bool SensorService::isVirtualSensor(int handle) const { SensorInterface* sensor = mSensorMap.valueFor(handle); return sensor->isVirtual(); } Vector<Sensor> SensorService::getSensorList() Vector<Sensor> SensorService::getSensorList() { { char value[PROPERTY_VALUE_MAX]; char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -858,6 +863,11 @@ status_t SensorService::SensorEventConnection::sendEvents( } } } } // Early return if there are no events for this connection. if (count == 0) { return status_t(NO_ERROR); } // NOTE: ASensorEvent and sensors_event_t are the same type // NOTE: ASensorEvent and sensors_event_t are the same type ssize_t size = SensorEventQueue::write(mChannel, ssize_t size = SensorEventQueue::write(mChannel, reinterpret_cast<ASensorEvent const*>(scratch), count); reinterpret_cast<ASensorEvent const*>(scratch), count); Loading Loading @@ -922,7 +932,7 @@ status_t SensorService::SensorEventConnection::flush() { // 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 (size_t i = 0; i < mSensorInfo.size(); ++i) { for (size_t i = 0; i < mSensorInfo.size(); ++i) { const int handle = mSensorInfo.keyAt(i); const int handle = mSensorInfo.keyAt(i); if (halVersion < SENSORS_DEVICE_API_VERSION_1_1) { if (halVersion < SENSORS_DEVICE_API_VERSION_1_1 || mService->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. FlushInfo& flushInfo = mSensorInfo.editValueFor(handle); FlushInfo& flushInfo = mSensorInfo.editValueFor(handle); Loading
services/sensorservice/SensorService.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -130,6 +130,7 @@ class SensorService : DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const; DefaultKeyedVector<int, SensorInterface*> getActiveVirtualSensors() const; String8 getSensorName(int handle) const; String8 getSensorName(int handle) const; bool isVirtualSensor(int handle) const; void recordLastValue(sensors_event_t const * buffer, size_t count); void recordLastValue(sensors_event_t const * buffer, size_t count); static void sortEventBuffer(sensors_event_t* buffer, size_t count); static void sortEventBuffer(sensors_event_t* buffer, size_t count); Sensor registerSensor(SensorInterface* sensor); Sensor registerSensor(SensorInterface* sensor); Loading