diff options
author | Steve Block <steveblock@google.com> | 2010-08-25 11:56:09 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-10-06 16:12:06 +0100 |
commit | 8980343b13137aba5bd11d0d961360c03689d434 (patch) | |
tree | 6b7f0d49e7de0676e034eb17f0c680832ffaa1e3 /core/java/android/webkit/DeviceOrientationService.java | |
parent | e224fabb2c59e9f1274c3569c04b91787824add0 (diff) | |
download | frameworks_base-8980343b13137aba5bd11d0d961360c03689d434.zip frameworks_base-8980343b13137aba5bd11d0d961360c03689d434.tar.gz frameworks_base-8980343b13137aba5bd11d0d961360c03689d434.tar.bz2 |
Make sure that we send the DeviceOrientation error event only once
Change-Id: Iff095ad4d282635c567b0c85a286056e23ca38e3
Diffstat (limited to 'core/java/android/webkit/DeviceOrientationService.java')
-rwxr-xr-x | core/java/android/webkit/DeviceOrientationService.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/core/java/android/webkit/DeviceOrientationService.java b/core/java/android/webkit/DeviceOrientationService.java index 4ff849e..9b866d3 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; } } |