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()));
if (!is_orientation_buffer_ready_) {
SetOrientationBufferReadyStatus(true);
- updateRotationVectorHistogram(true);
+ updateRotationVectorHistogram(!is_using_backup_sensors_for_orientation_);
}
}
bool SensorManagerAndroid::Start(EventType event_type) {
DCHECK(!device_sensors_.is_null());
- int rate_in_milliseconds = (event_type == kTypeLight)
- ? kLightSensorIntervalMillis
- : kInertialSensorIntervalMillis;
+ int rate_in_microseconds = (event_type == kTypeLight)
+ ? kLightSensorIntervalMicroseconds
+ : kInertialSensorIntervalMicroseconds;
return Java_DeviceSensors_start(AttachCurrentThread(),
device_sensors_.obj(),
reinterpret_cast<intptr_t>(this),
static_cast<jint>(event_type),
- rate_in_milliseconds);
+ rate_in_microseconds);
}
void SensorManagerAndroid::Stop(EventType event_type) {
AttachCurrentThread(), device_sensors_.obj());
}
+bool SensorManagerAndroid::isUsingBackupSensorsForOrientation() {
+ DCHECK(!device_sensors_.is_null());
+ return Java_DeviceSensors_isUsingBackupSensorsForOrientation(
+ AttachCurrentThread(), device_sensors_.obj());
+}
// ----- Shared memory API methods
received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] ==
number_active_device_motion_sensors_) {
device_motion_buffer_->seqlock.WriteBegin();
- device_motion_buffer_->data.interval = kInertialSensorIntervalMillis;
+ device_motion_buffer_->data.interval =
+ kInertialSensorIntervalMicroseconds / 1000.;
device_motion_buffer_->seqlock.WriteEnd();
SetMotionBufferReadyStatus(true);
if (!success)
updateRotationVectorHistogram(false);
+ else
+ is_using_backup_sensors_for_orientation_ =
+ isUsingBackupSensorsForOrientation();
return success;
}