diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-10-21 17:36:54 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-10-21 17:36:54 -0700 |
commit | 840db1f678ed15f0f3e9c58310b1e80ebb1f331a (patch) | |
tree | bb6da952b68872acdb2042885d4ae178414292ad /core/java/android/service | |
parent | ddf8fe505636d3b4435cb9952266765aab20b86d (diff) | |
download | frameworks_base-840db1f678ed15f0f3e9c58310b1e80ebb1f331a.zip frameworks_base-840db1f678ed15f0f3e9c58310b1e80ebb1f331a.tar.gz frameworks_base-840db1f678ed15f0f3e9c58310b1e80ebb1f331a.tar.bz2 |
Fix a race condition in wallpaper move throttling.
Bug: 3099316
Change-Id: Ia3221975b5be7fae8359d6ab531bbecd0e29aee9
Diffstat (limited to 'core/java/android/service')
-rw-r--r-- | core/java/android/service/wallpaper/WallpaperService.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java index 2b083dc..9645a17 100644 --- a/core/java/android/service/wallpaper/WallpaperService.java +++ b/core/java/android/service/wallpaper/WallpaperService.java @@ -452,17 +452,14 @@ public abstract class WallpaperService extends Service { private void dispatchPointer(MotionEvent event) { synchronized (mLock) { if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (mPendingMove != null) { - mCaller.removeMessages(MSG_TOUCH_EVENT, mPendingMove); - mPendingMove.recycle(); - } mPendingMove = event; } else { mPendingMove = null; } - Message msg = mCaller.obtainMessageO(MSG_TOUCH_EVENT, event); - mCaller.sendMessage(msg); } + + Message msg = mCaller.obtainMessageO(MSG_TOUCH_EVENT, event); + mCaller.sendMessage(msg); } void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) { @@ -905,14 +902,22 @@ public abstract class WallpaperService extends Service { mEngine.doOffsetsChanged(); } break; case MSG_TOUCH_EVENT: { + boolean skip = false; MotionEvent ev = (MotionEvent)message.obj; - synchronized (mEngine.mLock) { - if (mEngine.mPendingMove == ev) { - mEngine.mPendingMove = null; + if (ev.getAction() == MotionEvent.ACTION_MOVE) { + synchronized (mEngine.mLock) { + if (mEngine.mPendingMove == ev) { + mEngine.mPendingMove = null; + } else { + // this is not the motion event we are looking for.... + skip = true; + } } } - if (DEBUG) Log.v(TAG, "Delivering touch event: " + ev); - mEngine.onTouchEvent(ev); + if (!skip) { + if (DEBUG) Log.v(TAG, "Delivering touch event: " + ev); + mEngine.onTouchEvent(ev); + } ev.recycle(); } break; default : |