Index: content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java b/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java |
index ecb9d626479bd0283bd290e42fef55265061735a..d70e9b9845466f4385761f3624150c95b46d171e 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/DeviceMotionAndOrientation.java |
@@ -48,7 +48,7 @@ class DeviceMotionAndOrientation implements SensorEventListener { |
private Object mNativePtrLock = new Object(); |
// The acceleration vector including gravity expressed in the body frame. |
- private float[] mAccelerationVector; |
+ private float[] mAccelerationIncludingGravityVector;; |
bulach
2013/06/13 09:49:35
nit: double ;;
timvolodine
2013/06/13 14:00:40
Done.
|
// The geomagnetic vector expressed in the body frame. |
private float[] mMagneticFieldVector; |
@@ -80,6 +80,7 @@ class DeviceMotionAndOrientation implements SensorEventListener { |
final Set<Integer> mActiveSensors = Sets.newHashSet(); |
boolean mDeviceMotionIsActive = false; |
boolean mDeviceOrientationIsActive = false; |
+ int mNumberActiveDeviceMotionSensors = 0; |
bulach
2013/06/13 09:49:35
nit: seems unused
timvolodine
2013/06/13 14:00:40
Done.
|
protected DeviceMotionAndOrientation() { |
} |
@@ -120,6 +121,13 @@ class DeviceMotionAndOrientation implements SensorEventListener { |
} |
} |
+ @CalledByNative |
+ public int getNumberActiveDeviceMotionSensors() { |
+ Set<Integer> deviceMotionSensors = Sets.newHashSet(DEVICE_MOTION_SENSORS); |
+ deviceMotionSensors.removeAll(mActiveSensors); |
+ return DEVICE_MOTION_SENSORS.size() - deviceMotionSensors.size(); |
+ } |
+ |
/** |
* Stop listening to sensors for a given event type. Ensures that sensors are not disabled |
* if they are still in use by a different event type. |
@@ -174,14 +182,19 @@ class DeviceMotionAndOrientation implements SensorEventListener { |
switch (type) { |
case Sensor.TYPE_ACCELEROMETER: |
- if (mAccelerationVector == null) { |
- mAccelerationVector = new float[3]; |
+ if (mAccelerationIncludingGravityVector == null) { |
+ mAccelerationIncludingGravityVector = new float[3]; |
} |
- System.arraycopy(values, 0, mAccelerationVector, 0, |
- mAccelerationVector.length); |
+ System.arraycopy(values, 0, mAccelerationIncludingGravityVector, |
+ 0, mAccelerationIncludingGravityVector.length); |
if (mDeviceMotionIsActive) { |
- gotAccelerationIncludingGravity(mAccelerationVector[0], mAccelerationVector[1], |
- mAccelerationVector[2]); |
+ gotAccelerationIncludingGravity( |
+ mAccelerationIncludingGravityVector[0], |
+ mAccelerationIncludingGravityVector[1], |
+ mAccelerationIncludingGravityVector[2]); |
+ } |
+ if (mDeviceOrientationIsActive) { |
+ getOrientationUsingGetRotationMatrix(); |
} |
break; |
case Sensor.TYPE_LINEAR_ACCELERATION: |
@@ -200,19 +213,18 @@ class DeviceMotionAndOrientation implements SensorEventListener { |
} |
System.arraycopy(values, 0, mMagneticFieldVector, 0, |
mMagneticFieldVector.length); |
+ if (mDeviceOrientationIsActive) { |
+ getOrientationUsingGetRotationMatrix(); |
+ } |
break; |
default: |
// Unexpected |
return; |
} |
- |
- if (mDeviceOrientationIsActive) { |
- getOrientationUsingGetRotationMatrix(); |
- } |
} |
private void getOrientationUsingGetRotationMatrix() { |
- if (mAccelerationVector == null || mMagneticFieldVector == null) { |
+ if (mAccelerationIncludingGravityVector == null || mMagneticFieldVector == null) { |
return; |
} |
@@ -220,8 +232,8 @@ class DeviceMotionAndOrientation implements SensorEventListener { |
// The rotation matrix that transforms from the body frame to the earth |
// frame. |
float[] deviceRotationMatrix = new float[9]; |
- if (!SensorManager.getRotationMatrix(deviceRotationMatrix, null, mAccelerationVector, |
- mMagneticFieldVector)) { |
+ if (!SensorManager.getRotationMatrix(deviceRotationMatrix, null, |
+ mAccelerationIncludingGravityVector, mMagneticFieldVector)) { |
return; |
} |