diff options
| author | 2020-10-05 21:51:12 +0000 | |
|---|---|---|
| committer | 2020-10-05 21:51:12 +0000 | |
| commit | 209c251c169d7eb3534aafba2c0eb64b9221f083 (patch) | |
| tree | 15610e6c7c54792154006977d748b80291816144 | |
| parent | d0f1f1e3653c54f9be8efea3b143250e3bf1d9ae (diff) | |
| parent | c69e2a45aa9a41ed64671725aae920b4629d6dcf (diff) | |
Merge "Don't quantize max range with a resolution of 0"
| -rw-r--r-- | services/sensorservice/SensorDevice.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/services/sensorservice/SensorDevice.cpp b/services/sensorservice/SensorDevice.cpp index 8a282e2382..e355594176 100644 --- a/services/sensorservice/SensorDevice.cpp +++ b/services/sensorservice/SensorDevice.cpp @@ -153,12 +153,18 @@ void SensorDevice::initializeSensorList() { SensorDeviceUtils::defaultResolutionForType(sensor.type); } - double promotedResolution = sensor.resolution; - double promotedMaxRange = sensor.maxRange; - if (fmod(promotedMaxRange, promotedResolution) != 0) { - ALOGW("%s's max range %f is not a multiple of the resolution %f", - sensor.name, sensor.maxRange, sensor.resolution); - SensorDeviceUtils::quantizeValue(&sensor.maxRange, promotedResolution); + // Some sensors don't have a default resolution and will be left at 0. + // Don't crash in this case since CTS will verify that devices don't go to + // production with a resolution of 0. + if (sensor.resolution != 0) { + double promotedResolution = sensor.resolution; + double promotedMaxRange = sensor.maxRange; + if (fmod(promotedMaxRange, promotedResolution) != 0) { + ALOGW("%s's max range %f is not a multiple of the resolution %f", + sensor.name, sensor.maxRange, sensor.resolution); + SensorDeviceUtils::quantizeValue( + &sensor.maxRange, promotedResolution); + } } } |