summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steve Block <steveblock@google.com> 2010-10-06 08:30:13 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-10-06 08:30:13 -0700
commite86b8a18df0964a84952c654fd25a0de0814737f (patch)
tree9ae1a15b7874996743a36b999e609e385e228920
parentc9d5b31f84f5c8b5db690491031369556ed7fee9 (diff)
parent8980343b13137aba5bd11d0d961360c03689d434 (diff)
Merge "Make sure that we send the DeviceOrientation error event only once"
-rwxr-xr-xcore/java/android/webkit/DeviceOrientationService.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/webkit/DeviceOrientationService.java b/core/java/android/webkit/DeviceOrientationService.java
index 4ff849ea0162..9b866d35e840 100755
--- a/core/java/android/webkit/DeviceOrientationService.java
+++ b/core/java/android/webkit/DeviceOrientationService.java
@@ -41,6 +41,7 @@ final class DeviceOrientationService implements SensorEventListener {
private Double mAlpha;
private Double mBeta;
private Double mGamma;
+ private boolean mHaveSentErrorEvent;
private static final double DELTA_DEGRESS = 1.0;
@@ -75,11 +76,16 @@ final class DeviceOrientationService implements SensorEventListener {
private void sendErrorEvent() {
assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
+ // The spec requires that each listener receives the error event only once.
+ if (mHaveSentErrorEvent)
+ return;
+ mHaveSentErrorEvent = true;
mHandler.post(new Runnable() {
@Override
public void run() {
assert WebViewCore.THREAD_NAME.equals(Thread.currentThread().getName());
if (mIsRunning) {
+ // The special case of all nulls is used to signify a failure to get data.
mManager.onOrientationChange(null, null, null);
}
}
@@ -169,6 +175,8 @@ final class DeviceOrientationService implements SensorEventListener {
mBeta = beta;
mGamma = gamma;
mManager.onOrientationChange(mAlpha, mBeta, mGamma);
+ // Now that we have successfully sent some data, reset whether we've sent an error.
+ mHaveSentErrorEvent = false;
}
}