Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1213)

Unified Diff: content/browser/device_sensors/sensor_manager_android.cc

Issue 661413003: Android: add support for Device Orientation on devices where ROTATION_VECTOR is not availabl… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test when rotation vector is not available Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/device_sensors/sensor_manager_android.cc
diff --git a/content/browser/device_sensors/sensor_manager_android.cc b/content/browser/device_sensors/sensor_manager_android.cc
index abc37927dabd33130e233fca062e4310a980404c..11de85ae68cabb799855e123bf597401d787a1db 100644
--- a/content/browser/device_sensors/sensor_manager_android.cc
+++ b/content/browser/device_sensors/sensor_manager_android.cc
@@ -31,7 +31,8 @@ SensorManagerAndroid::SensorManagerAndroid()
device_orientation_buffer_(NULL),
is_light_buffer_ready_(false),
is_motion_buffer_ready_(false),
- is_orientation_buffer_ready_(false) {
+ is_orientation_buffer_ready_(false),
+ is_using_backup_sensors_for_orientation_(false) {
memset(received_motion_data_, 0, sizeof(received_motion_data_));
device_sensors_.Reset(Java_DeviceSensors_getInstance(
AttachCurrentThread(), base::android::GetApplicationContext()));
@@ -67,7 +68,7 @@ void SensorManagerAndroid::GotOrientation(
if (!is_orientation_buffer_ready_) {
SetOrientationBufferReadyStatus(true);
- updateRotationVectorHistogram(true);
+ updateRotationVectorHistogram(!is_using_backup_sensors_for_orientation_);
}
}
@@ -173,6 +174,11 @@ int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() {
AttachCurrentThread(), device_sensors_.obj());
}
+bool SensorManagerAndroid::isUsingBackupSensorsForOrientation() {
+ DCHECK(!device_sensors_.is_null());
+ return Java_DeviceSensors_isUsingBackupSensorsForOrientation(
+ AttachCurrentThread(), device_sensors_.obj());
+}
// ----- Shared memory API methods
@@ -308,6 +314,9 @@ bool SensorManagerAndroid::StartFetchingDeviceOrientationData(
if (!success)
updateRotationVectorHistogram(false);
+ else
+ is_using_backup_sensors_for_orientation_ =
+ isUsingBackupSensorsForOrientation();
return success;
}

Powered by Google App Engine
This is Rietveld 408576698