diff options
Diffstat (limited to 'services/sensorservice/SensorDeviceUtils.h')
-rw-r--r-- | services/sensorservice/SensorDeviceUtils.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/services/sensorservice/SensorDeviceUtils.h b/services/sensorservice/SensorDeviceUtils.h index 255f7e107c..c232f0b408 100644 --- a/services/sensorservice/SensorDeviceUtils.h +++ b/services/sensorservice/SensorDeviceUtils.h @@ -19,7 +19,6 @@ #include <android/hidl/manager/1.0/IServiceNotification.h> #include <hardware/sensors.h> -#include <utils/Log.h> #include <cmath> #include <condition_variable> @@ -32,23 +31,20 @@ using ::android::hidl::manager::V1_0::IServiceNotification; namespace android { namespace SensorDeviceUtils { -// Quantizes a single value to (a fractional factor of) a sensor's resolution. Typically we -// increase the value of the sensor's nominal resolution to ensure that sensor accuracy -// improvements, like runtime calibration, are not masked during requantization. -inline void quantizeValue(float *value, double resolution, double factor = 0.125) { - if (resolution == 0) { - return; - } - - double incRes = factor * resolution; +// Quantizes a single value using a sensor's resolution. +inline void quantizeValue(float *value, double resolution) { + // Increase the value of the sensor's nominal resolution to ensure that + // sensor accuracy improvements, like runtime calibration, are not masked + // during requantization. + double incRes = 0.125 * resolution; *value = round(static_cast<double>(*value) / incRes) * incRes; } // Ensures a sensor event doesn't provide values finer grained than its sensor resolution allows. void quantizeSensorEventValues(sensors_event_t *event, float resolution); -// Returns the expected resolution value for the given sensor -float resolutionForSensor(const sensor_t &sensor); +// Provides a default resolution for simple sensor types if one wasn't provided by the HAL. +float defaultResolutionForType(int type); class HidlServiceRegistrationWaiter : public IServiceNotification { public: |