Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b3178a6 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Fix a race condition in wallpaper move throttling." into gingerbread

parents e9dbf208 840db1f6
Loading
Loading
Loading
Loading
+16 −11
Original line number Diff line number Diff line
@@ -452,18 +452,15 @@ 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);
        }
        }

        void updateSurface(boolean forceRelayout, boolean forceReport, boolean redrawNeeded) {
            if (mDestroyed) {
@@ -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;
                    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 (!skip) {
                        if (DEBUG) Log.v(TAG, "Delivering touch event: " + ev);
                        mEngine.onTouchEvent(ev);
                    }
                    ev.recycle();
                } break;
                default :