Loading sensors/common/default/2.X/Sensor.cpp +11 −25 Original line number Diff line number Diff line Loading @@ -57,11 +57,11 @@ const SensorInfo& Sensor::getSensorInfo() const { return mSensorInfo; } void Sensor::batch(int32_t samplingPeriodNs) { if (samplingPeriodNs < mSensorInfo.minDelay * 1000) { samplingPeriodNs = mSensorInfo.minDelay * 1000; } else if (samplingPeriodNs > mSensorInfo.maxDelay * 1000) { samplingPeriodNs = mSensorInfo.maxDelay * 1000; void Sensor::batch(int64_t samplingPeriodNs) { if (samplingPeriodNs < mSensorInfo.minDelay * 1000ll) { samplingPeriodNs = mSensorInfo.minDelay * 1000ll; } else if (samplingPeriodNs > mSensorInfo.maxDelay * 1000ll) { samplingPeriodNs = mSensorInfo.maxDelay * 1000ll; } if (mSamplingPeriodNs != samplingPeriodNs) { Loading Loading @@ -133,6 +133,11 @@ bool Sensor::isWakeUpSensor() { } std::vector<Event> Sensor::readEvents() { // For an accelerometer sensor type, default the z-direction // value to -9.8 float zValue = (mSensorInfo.type == SensorType::ACCELEROMETER) ? -9.8 : 0.0; std::vector<Event> events; Event event; event.sensorHandle = mSensorInfo.sensorHandle; Loading @@ -140,7 +145,7 @@ std::vector<Event> Sensor::readEvents() { event.timestamp = ::android::elapsedRealtimeNano(); event.u.vec3.x = 0; event.u.vec3.y = 0; event.u.vec3.z = 0; event.u.vec3.z = zValue; event.u.vec3.status = SensorStatus::ACCURACY_HIGH; events.push_back(event); return events; Loading Loading @@ -330,25 +335,6 @@ AmbientTempSensor::AmbientTempSensor(int32_t sensorHandle, ISensorsEventCallback mSensorInfo.flags = static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE); }; DeviceTempSensor::DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback) : OnChangeSensor(callback) { mSensorInfo.sensorHandle = sensorHandle; mSensorInfo.name = "Device Temp Sensor"; mSensorInfo.vendor = "Vendor String"; mSensorInfo.version = 1; mSensorInfo.type = SensorType::TEMPERATURE; mSensorInfo.typeAsString = ""; mSensorInfo.maxRange = 80.0f; mSensorInfo.resolution = 0.01f; mSensorInfo.power = 0.001f; mSensorInfo.minDelay = 40 * 1000; // microseconds mSensorInfo.maxDelay = kDefaultMaxDelayUs; mSensorInfo.fifoReservedEventCount = 0; mSensorInfo.fifoMaxEventCount = 0; mSensorInfo.requiredPermission = ""; mSensorInfo.flags = static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE); } RelativeHumiditySensor::RelativeHumiditySensor(int32_t sensorHandle, ISensorsEventCallback* callback) : OnChangeSensor(callback) { Loading sensors/common/default/2.X/Sensor.h +2 −7 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ namespace sensors { namespace V2_X { namespace implementation { static constexpr float kDefaultMaxDelayUs = 10 * 1000 * 1000; static constexpr int32_t kDefaultMaxDelayUs = 10 * 1000 * 1000; class ISensorsEventCallback { public: Loading @@ -54,7 +54,7 @@ class Sensor { virtual ~Sensor(); const SensorInfo& getSensorInfo() const; void batch(int32_t samplingPeriodNs); void batch(int64_t samplingPeriodNs); virtual void activate(bool enable); Result flush(); Loading Loading @@ -113,11 +113,6 @@ class AmbientTempSensor : public OnChangeSensor { AmbientTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback); }; class DeviceTempSensor : public OnChangeSensor { public: DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback); }; class PressureSensor : public Sensor { public: PressureSensor(int32_t sensorHandle, ISensorsEventCallback* callback); Loading sensors/common/default/2.X/Sensors.h +0 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,6 @@ struct Sensors : public ISensorsInterface, public ISensorsEventCallback { AddSensor<AccelSensor>(); AddSensor<GyroSensor>(); AddSensor<AmbientTempSensor>(); AddSensor<DeviceTempSensor>(); AddSensor<PressureSensor>(); AddSensor<MagnetometerSensor>(); AddSensor<LightSensor>(); Loading sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp +4 −14 Original line number Diff line number Diff line Loading @@ -71,9 +71,10 @@ const SensorInfo& Sensor::getSensorInfo() const { return mSensorInfo; } void Sensor::batch(int32_t samplingPeriodNs) { samplingPeriodNs = std::clamp(samplingPeriodNs, mSensorInfo.minDelay * 1000, mSensorInfo.maxDelay * 1000); void Sensor::batch(int64_t samplingPeriodNs) { samplingPeriodNs = std::clamp(samplingPeriodNs, static_cast<int64_t>(mSensorInfo.minDelay) * 1000, static_cast<int64_t>(mSensorInfo.maxDelay) * 1000); if (mSamplingPeriodNs != samplingPeriodNs) { mSamplingPeriodNs = samplingPeriodNs; Loading Loading @@ -323,17 +324,6 @@ AmbientTempSensor::AmbientTempSensor(int32_t sensorHandle, ISensorsEventCallback mSensorInfo.minDelay = 40 * 1000; // microseconds } DeviceTempSensor::DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback) : ContinuousSensor(sensorHandle, callback) { mSensorInfo.name = "Device Temp Sensor"; mSensorInfo.type = SensorType::TEMPERATURE; mSensorInfo.typeAsString = SENSOR_STRING_TYPE_TEMPERATURE; mSensorInfo.maxRange = 80.0f; mSensorInfo.resolution = 0.01f; mSensorInfo.power = 0.001f; mSensorInfo.minDelay = 40 * 1000; // microseconds } RelativeHumiditySensor::RelativeHumiditySensor(int32_t sensorHandle, ISensorsEventCallback* callback) : OnChangeSensor(sensorHandle, callback) { Loading sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.h +1 −6 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class Sensor { virtual ~Sensor(); const SensorInfo& getSensorInfo() const; void batch(int32_t samplingPeriodNs); void batch(int64_t samplingPeriodNs); virtual void activate(bool enable); Result flush(); Loading Loading @@ -114,11 +114,6 @@ class GyroSensor : public ContinuousSensor { std::vector<Event> readEvents() override; }; class DeviceTempSensor : public ContinuousSensor { public: DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback); }; class PressureSensor : public ContinuousSensor { public: PressureSensor(int32_t sensorHandle, ISensorsEventCallback* callback); Loading Loading
sensors/common/default/2.X/Sensor.cpp +11 −25 Original line number Diff line number Diff line Loading @@ -57,11 +57,11 @@ const SensorInfo& Sensor::getSensorInfo() const { return mSensorInfo; } void Sensor::batch(int32_t samplingPeriodNs) { if (samplingPeriodNs < mSensorInfo.minDelay * 1000) { samplingPeriodNs = mSensorInfo.minDelay * 1000; } else if (samplingPeriodNs > mSensorInfo.maxDelay * 1000) { samplingPeriodNs = mSensorInfo.maxDelay * 1000; void Sensor::batch(int64_t samplingPeriodNs) { if (samplingPeriodNs < mSensorInfo.minDelay * 1000ll) { samplingPeriodNs = mSensorInfo.minDelay * 1000ll; } else if (samplingPeriodNs > mSensorInfo.maxDelay * 1000ll) { samplingPeriodNs = mSensorInfo.maxDelay * 1000ll; } if (mSamplingPeriodNs != samplingPeriodNs) { Loading Loading @@ -133,6 +133,11 @@ bool Sensor::isWakeUpSensor() { } std::vector<Event> Sensor::readEvents() { // For an accelerometer sensor type, default the z-direction // value to -9.8 float zValue = (mSensorInfo.type == SensorType::ACCELEROMETER) ? -9.8 : 0.0; std::vector<Event> events; Event event; event.sensorHandle = mSensorInfo.sensorHandle; Loading @@ -140,7 +145,7 @@ std::vector<Event> Sensor::readEvents() { event.timestamp = ::android::elapsedRealtimeNano(); event.u.vec3.x = 0; event.u.vec3.y = 0; event.u.vec3.z = 0; event.u.vec3.z = zValue; event.u.vec3.status = SensorStatus::ACCURACY_HIGH; events.push_back(event); return events; Loading Loading @@ -330,25 +335,6 @@ AmbientTempSensor::AmbientTempSensor(int32_t sensorHandle, ISensorsEventCallback mSensorInfo.flags = static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE); }; DeviceTempSensor::DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback) : OnChangeSensor(callback) { mSensorInfo.sensorHandle = sensorHandle; mSensorInfo.name = "Device Temp Sensor"; mSensorInfo.vendor = "Vendor String"; mSensorInfo.version = 1; mSensorInfo.type = SensorType::TEMPERATURE; mSensorInfo.typeAsString = ""; mSensorInfo.maxRange = 80.0f; mSensorInfo.resolution = 0.01f; mSensorInfo.power = 0.001f; mSensorInfo.minDelay = 40 * 1000; // microseconds mSensorInfo.maxDelay = kDefaultMaxDelayUs; mSensorInfo.fifoReservedEventCount = 0; mSensorInfo.fifoMaxEventCount = 0; mSensorInfo.requiredPermission = ""; mSensorInfo.flags = static_cast<uint32_t>(SensorFlagBits::ON_CHANGE_MODE); } RelativeHumiditySensor::RelativeHumiditySensor(int32_t sensorHandle, ISensorsEventCallback* callback) : OnChangeSensor(callback) { Loading
sensors/common/default/2.X/Sensor.h +2 −7 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ namespace sensors { namespace V2_X { namespace implementation { static constexpr float kDefaultMaxDelayUs = 10 * 1000 * 1000; static constexpr int32_t kDefaultMaxDelayUs = 10 * 1000 * 1000; class ISensorsEventCallback { public: Loading @@ -54,7 +54,7 @@ class Sensor { virtual ~Sensor(); const SensorInfo& getSensorInfo() const; void batch(int32_t samplingPeriodNs); void batch(int64_t samplingPeriodNs); virtual void activate(bool enable); Result flush(); Loading Loading @@ -113,11 +113,6 @@ class AmbientTempSensor : public OnChangeSensor { AmbientTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback); }; class DeviceTempSensor : public OnChangeSensor { public: DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback); }; class PressureSensor : public Sensor { public: PressureSensor(int32_t sensorHandle, ISensorsEventCallback* callback); Loading
sensors/common/default/2.X/Sensors.h +0 −1 Original line number Diff line number Diff line Loading @@ -64,7 +64,6 @@ struct Sensors : public ISensorsInterface, public ISensorsEventCallback { AddSensor<AccelSensor>(); AddSensor<GyroSensor>(); AddSensor<AmbientTempSensor>(); AddSensor<DeviceTempSensor>(); AddSensor<PressureSensor>(); AddSensor<MagnetometerSensor>(); AddSensor<LightSensor>(); Loading
sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.cpp +4 −14 Original line number Diff line number Diff line Loading @@ -71,9 +71,10 @@ const SensorInfo& Sensor::getSensorInfo() const { return mSensorInfo; } void Sensor::batch(int32_t samplingPeriodNs) { samplingPeriodNs = std::clamp(samplingPeriodNs, mSensorInfo.minDelay * 1000, mSensorInfo.maxDelay * 1000); void Sensor::batch(int64_t samplingPeriodNs) { samplingPeriodNs = std::clamp(samplingPeriodNs, static_cast<int64_t>(mSensorInfo.minDelay) * 1000, static_cast<int64_t>(mSensorInfo.maxDelay) * 1000); if (mSamplingPeriodNs != samplingPeriodNs) { mSamplingPeriodNs = samplingPeriodNs; Loading Loading @@ -323,17 +324,6 @@ AmbientTempSensor::AmbientTempSensor(int32_t sensorHandle, ISensorsEventCallback mSensorInfo.minDelay = 40 * 1000; // microseconds } DeviceTempSensor::DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback) : ContinuousSensor(sensorHandle, callback) { mSensorInfo.name = "Device Temp Sensor"; mSensorInfo.type = SensorType::TEMPERATURE; mSensorInfo.typeAsString = SENSOR_STRING_TYPE_TEMPERATURE; mSensorInfo.maxRange = 80.0f; mSensorInfo.resolution = 0.01f; mSensorInfo.power = 0.001f; mSensorInfo.minDelay = 40 * 1000; // microseconds } RelativeHumiditySensor::RelativeHumiditySensor(int32_t sensorHandle, ISensorsEventCallback* callback) : OnChangeSensor(sensorHandle, callback) { Loading
sensors/common/default/2.X/multihal/tests/fake_subhal/Sensor.h +1 −6 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class Sensor { virtual ~Sensor(); const SensorInfo& getSensorInfo() const; void batch(int32_t samplingPeriodNs); void batch(int64_t samplingPeriodNs); virtual void activate(bool enable); Result flush(); Loading Loading @@ -114,11 +114,6 @@ class GyroSensor : public ContinuousSensor { std::vector<Event> readEvents() override; }; class DeviceTempSensor : public ContinuousSensor { public: DeviceTempSensor(int32_t sensorHandle, ISensorsEventCallback* callback); }; class PressureSensor : public ContinuousSensor { public: PressureSensor(int32_t sensorHandle, ISensorsEventCallback* callback); Loading