Skip to content

Commit

Permalink
Add rounding to the GRAVITY sensor.
Browse files Browse the repository at this point in the history
For privacy, the accuracy of precision of acceleration is rounded to
0.1 m/s². The new sensor "GRAVITY" is based on acceleration, but
rounding is missing.

This patch applies the same rounding for both and removes the
"default" case. This will force creator of new SensorType to make
an explicit decision in the future.

+CC engedy@ who discussed this during security/privacy meeting.

Bug: 1163993
Change-Id: I8d3ff04421794aed1899711f018bc579d2bf8200
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2684575
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852328}
  • Loading branch information
ArthurSonzogni authored and Chromium LUCI CQ committed Feb 9, 2021
1 parent ad4d2f3 commit 8d43c26
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions services/device/generic_sensor/platform_sensor_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,29 @@ void RoundOrientationEulerReading(SensorReadingXYZ* reading) {
void RoundSensorReading(SensorReading* reading, mojom::SensorType sensor_type) {
switch (sensor_type) {
case mojom::SensorType::ACCELEROMETER:
FALLTHROUGH;
case mojom::SensorType::GRAVITY:
case mojom::SensorType::LINEAR_ACCELERATION:
RoundAccelerometerReading(&reading->accel);
break;

case mojom::SensorType::GYROSCOPE:
RoundGyroscopeReading(&reading->gyro);
break;

case mojom::SensorType::ABSOLUTE_ORIENTATION_EULER_ANGLES:
FALLTHROUGH;
case mojom::SensorType::RELATIVE_ORIENTATION_EULER_ANGLES:
RoundOrientationEulerReading(&reading->orientation_euler);
break;

case mojom::SensorType::ABSOLUTE_ORIENTATION_QUATERNION:
FALLTHROUGH;
case mojom::SensorType::RELATIVE_ORIENTATION_QUATERNION:
RoundOrientationQuaternionReading(&reading->orientation_quat);
break;
default:

case mojom::SensorType::AMBIENT_LIGHT:
case mojom::SensorType::MAGNETOMETER:
case mojom::SensorType::PRESSURE:
case mojom::SensorType::PROXIMITY:
break;
}
}
Expand Down

0 comments on commit 8d43c26

Please sign in to comment.