[Android] Implement 3-way sensor fallback for Device Orientation.
commit843f048e90026b00dadbca5c34e01694ea943785
authortimvolodine <timvolodine@chromium.org>
Fri, 21 Aug 2015 23:40:42 +0000 (21 16:40 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 21 Aug 2015 23:41:36 +0000 (21 23:41 +0000)
tree3e999e1be634f356707c723b6b58b30637f979b5
parent6d3eef8b93327c14611f9315e06201ba1a9ec1fa
[Android] Implement 3-way sensor fallback for Device Orientation.

Implement 3-way fallback using 3 sets of sensors for Device Orientation.
The implementation is behind the experimental features flag.

The 3 options in decreasing order of preference are:
A: GAME_ROTATION_VECTOR (relative)
B: ROTATION_VECTOR (absolute)
C: combination of ACCELEROMETER and MAGNETIC_FIELD (absolute)

Some of the sensors may not be available depending on the device and Android
version, so the 3-way fallback ensures selection of the best possible option.
Option A also makes sure the "absolute" property of Device Orientation events
is set to false. This patch also includes the necessary modifications for
UMA logging.

The reasons behind using GAME_ROTATION_VECTOR as first choice for Device
Orientation include better accuracy in the presence of magnetic field and
consistency with Safari on iOS, see crbug.com/397824 and crbug.com/520546
for more details.

BUG=397824,520546

Review URL: https://codereview.chromium.org/1060213004

Cr-Commit-Position: refs/heads/master@{#344911}
content/browser/device_sensors/sensor_manager_android.cc
content/browser/device_sensors/sensor_manager_android.h
content/browser/device_sensors/sensor_manager_android_unittest.cc
content/public/android/java/src/org/chromium/content/browser/DeviceSensors.java
content/public/android/javatests/src/org/chromium/content/browser/DeviceSensorsTest.java
tools/metrics/histograms/histograms.xml