From 12d39b9ccdd1951d1df6f132b9d46060c820f152 Mon Sep 17 00:00:00 2001 From: Balint Ureczky Date: Thu, 5 Dec 2013 00:03:45 +0100 Subject: take account of RotationVector's new extra parameter Rotation vector has a new 5th parameter introduced in API 18. But the code classified the 5 parameter the same as it would be 3 and overriden the 4th parameter which is unnecessary and also caused an unexpected behavior. Issue #63268: https://code.google.com/p/android/issues/detail?id=63268 Signed-off-by: Balint Ureczky Change-Id: I6f9a5fc401da655695ab03694b4a74dc5be936ed --- core/java/android/hardware/SensorManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java index b931313..ac9189d 100644 --- a/core/java/android/hardware/SensorManager.java +++ b/core/java/android/hardware/SensorManager.java @@ -1359,7 +1359,7 @@ public abstract class SensorManager { float q2 = rotationVector[1]; float q3 = rotationVector[2]; - if (rotationVector.length == 4) { + if (rotationVector.length >= 4) { q0 = rotationVector[3]; } else { q0 = 1 - q1*q1 - q2*q2 - q3*q3; @@ -1416,7 +1416,7 @@ public abstract class SensorManager { * @param Q an array of floats in which to store the computed quaternion */ public static void getQuaternionFromVector(float[] Q, float[] rv) { - if (rv.length == 4) { + if (rv.length >= 4) { Q[0] = rv[3]; } else { Q[0] = 1 - rv[0]*rv[0] - rv[1]*rv[1] - rv[2]*rv[2]; -- cgit v1.1