tree: 6559d62e86d4f3b236368a18893b2a1b9b3c7a05 [path history] [tgz]
  1. BUILD.gn
  2. DEPS
  3. OWNERS
  4. README.md
  5. absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.cc
  6. absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.h
  7. android/
  8. generic_sensor_consts.h
  9. generic_sensor_service_unittest.cc
  10. linear_acceleration_fusion_algorithm_using_accelerometer.cc
  11. linear_acceleration_fusion_algorithm_using_accelerometer.h
  12. linux/
  13. orientation_euler_angles_fusion_algorithm_using_quaternion.cc
  14. orientation_euler_angles_fusion_algorithm_using_quaternion.h
  15. orientation_quaternion_fusion_algorithm_using_euler_angles.cc
  16. orientation_quaternion_fusion_algorithm_using_euler_angles.h
  17. orientation_util.cc
  18. orientation_util.h
  19. platform_sensor.cc
  20. platform_sensor.h
  21. platform_sensor_accelerometer_mac.cc
  22. platform_sensor_accelerometer_mac.h
  23. platform_sensor_ambient_light_mac.cc
  24. platform_sensor_ambient_light_mac.h
  25. platform_sensor_and_provider_unittest_linux.cc
  26. platform_sensor_and_provider_unittest_win.cc
  27. platform_sensor_android.cc
  28. platform_sensor_android.h
  29. platform_sensor_fusion.cc
  30. platform_sensor_fusion.h
  31. platform_sensor_fusion_algorithm.cc
  32. platform_sensor_fusion_algorithm.h
  33. platform_sensor_linux.cc
  34. platform_sensor_linux.h
  35. platform_sensor_provider.cc
  36. platform_sensor_provider.h
  37. platform_sensor_provider_android.cc
  38. platform_sensor_provider_android.h
  39. platform_sensor_provider_base.cc
  40. platform_sensor_provider_base.h
  41. platform_sensor_provider_linux.cc
  42. platform_sensor_provider_linux.h
  43. platform_sensor_provider_mac.cc
  44. platform_sensor_provider_mac.h
  45. platform_sensor_provider_unittest_android.cc
  46. platform_sensor_provider_win.cc
  47. platform_sensor_provider_win.h
  48. platform_sensor_reader_linux.cc
  49. platform_sensor_reader_linux.h
  50. platform_sensor_reader_win.cc
  51. platform_sensor_reader_win.h
  52. platform_sensor_win.cc
  53. platform_sensor_win.h
  54. relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.cc
  55. relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.h
  56. sensor_impl.cc
  57. sensor_impl.h
  58. sensor_provider_impl.cc
  59. sensor_provider_impl.h
services/device/generic_sensor/README.md

Sensors

services/device/generic_sensor contains the platform-specific parts of the Sensor APIs implementation.

Sensors Mojo interfaces are defined in the services/public/interfaces subdirectory.

The JS bindings are implemented in third_party/WebKit/Source/modules/sensor.

Platform Support

Support for the SensorTypes defined by the Mojo interface is summarized in this table. An empty cell indicates that the sensor type is not supported on that platform.

SensorTypeAndroidLinuxmacOSWindows
AMBIENT_LIGHTTYPE_LIGHTin_illuminanceAppleLMUControllerSENSOR_TYPE_AMBIENT_LIGHT
PROXIMITY
ACCELEROMETERTYPE_ACCELEROMETERin_accelSMCMotionSensorSENSOR_TYPE_ACCELEROMETER_3D
LINEAR_ACCELEROMETERTYPE_LINEAR_ACCELEROMETERACCELEROMETER (*)
GYROSCOPETYPE_GYROSCOPEin_anglvelSENSOR_TYPE_GYROMETER_3D
MAGNETOMETERTYPE_MAGNETIC_FIELDin_magnSENSOR_TYPE_COMPASS_3D
PRESSURE
ABSOLUTE_ORIENTATION_EULER_ANGLESSENSOR_TYPE_INCLINOMETER_3D
ABSOLUTE_ORIENTATION_QUATERNIONTYPE_ROTATION_VECTORSENSOR_TYPE_AGGREGATED_DEVICE_ORIENTATION
RELATIVE_ORIENTATION_EULER_ANGLESACCELEROMETER (*)ACCELEROMETER (*)
RELATIVE_ORIENTATION_QUATERNIONTYPE_GAME_ROTATION_VECTORRELATIVE_ORIENTATION_EULER_ANGLES (*)RELATIVE_ORIENTATION_EULER_ANGLES (*)

(Note: “*” means the sensor type is provided by sensor fusion.)

Android

Sensors are implemented by passing through values provided by the Sensor class. The values in the “Android” column of the table above correspond to the integer constants from the android.hardware.Sensor used to provide data for a SensorType.

Linux (and Chrome OS)

Sensors are implemented by reading values from the IIO subsystem. The values in the “Linux” column of the table above are the prefix of the sysfs files Chrome searches for to provide data for a SensorType. The RELATIVE_ORIENTATION_EULER_ANGLES sensor type is provided by interpreting the value that can be read from the ACCELEROMETER. The RELATIVE_ORIENTATION_QUATERNION sensor type is provided by interpreting the value that can be read from the RELATIVE_ORIENTATION_EULER_ANGLES.

macOS

On this platform there is limited support for sensors. The AMBIENT_LIGHT sensor type is provided by interpreting the value that can be read from the LMU. The ACCELEROMETER sensor type is provided by interpreting the value that can be read from the SMCMotionSensor. The RELATIVE_ORIENTATION_EULER_ANGLES sensor type is provided by interpreting the value that can be read from the ACCELEROMETER. The RELATIVE_ORIENTATION_QUATERNION sensor type is provided by interpreting the value that can be read from the RELATIVE_ORIENTATION_EULER_ANGLES.

Windows

Sensors are implemented by passing through values provided by the Sensor API. The values in the “Windows” column of the table above correspond to the names of the sensor type GUIDs used to provide data for a SensorType. The LINEAR_ACCELEROMETER sensor type is provided by implementing a low-pass-filter over the values returned by the ACCELEROMETER in order to remove the contribution of the gravitational force.

Testing

Sensors platform unit tests are located in the current directory and its subdirectories.

The sensors unit tests file for Android is android/junit/src/org/chromium/device/sensors/PlatformSensorAndProviderTest.java.

Sensors browser tests are located in content/test/data/generic_sensor.

Design Documents

Please refer to the design documentation for more details.