summaryrefslogtreecommitdiffstats
path: root/core/java/android/hardware
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-10-29 16:55:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-10-29 16:55:40 -0700
commitecd580d7dabfce40690a0e820087e169e7c30865 (patch)
tree3fcfaaff77b434bf71a1c947ca213d84e665fdf8 /core/java/android/hardware
parent88ae0ae4848ce894612397957cf4de6a6a50a394 (diff)
parentfdd714f8d52a7ab2b96839b7cfe8ed917417383b (diff)
downloadframeworks_base-ecd580d7dabfce40690a0e820087e169e7c30865.zip
frameworks_base-ecd580d7dabfce40690a0e820087e169e7c30865.tar.gz
frameworks_base-ecd580d7dabfce40690a0e820087e169e7c30865.tar.bz2
am fdd714f8: am 0da554ac: Merge "fix an overflow in the orientation sensonr calculations" into jb-mr1-dev
* commit 'fdd714f8d52a7ab2b96839b7cfe8ed917417383b': fix an overflow in the orientation sensonr calculations
Diffstat (limited to 'core/java/android/hardware')
-rw-r--r--core/java/android/hardware/LegacySensorManager.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/java/android/hardware/LegacySensorManager.java b/core/java/android/hardware/LegacySensorManager.java
index 62c194f..f959093 100644
--- a/core/java/android/hardware/LegacySensorManager.java
+++ b/core/java/android/hardware/LegacySensorManager.java
@@ -371,7 +371,7 @@ final class LegacySensorManager {
private static final float PREDICTION_RATIO = 1.0f/3.0f;
private static final float PREDICTION_TIME = (SENSORS_RATE_MS*COUNT/1000.0f)*PREDICTION_RATIO;
private float mV[] = new float[COUNT*2];
- private float mT[] = new float[COUNT*2];
+ private long mT[] = new long[COUNT*2];
private int mIndex;
public LmsFilter() {
@@ -381,7 +381,6 @@ final class LegacySensorManager {
public float filter(long time, float in) {
float v = in;
final float ns = 1.0f / 1000000000.0f;
- final float t = time*ns;
float v1 = mV[mIndex];
if ((v-v1) > 180) {
v -= 360;
@@ -396,9 +395,9 @@ final class LegacySensorManager {
if (mIndex >= COUNT*2)
mIndex = COUNT;
mV[mIndex] = v;
- mT[mIndex] = t;
+ mT[mIndex] = time;
mV[mIndex-COUNT] = v;
- mT[mIndex-COUNT] = t;
+ mT[mIndex-COUNT] = time;
float A, B, C, D, E;
float a, b;
@@ -408,8 +407,8 @@ final class LegacySensorManager {
for (i=0 ; i<COUNT-1 ; i++) {
final int j = mIndex - 1 - i;
final float Z = mV[j];
- final float T = 0.5f*(mT[j] + mT[j+1]) - t;
- float dT = mT[j] - mT[j+1];
+ final float T = (mT[j]/2 + mT[j+1]/2 - time)*ns;
+ float dT = (mT[j] - mT[j+1])*ns;
dT *= dT;
A += Z*dT;
B += T*(T*dT);