diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-02-22 11:14:18 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-02-22 13:42:55 -0800 |
commit | 5c86b5d9cd4543e6d04f8ef7fb1ba8f1c881c7ff (patch) | |
tree | eef5eaa9104e3af41c4695d0b9844ae5c8e6b619 /quickstep | |
parent | d70e75a514f62628ee59d4eb53160bbf2d1743fe (diff) | |
download | android_packages_apps_Trebuchet-5c86b5d9cd4543e6d04f8ef7fb1ba8f1c881c7ff.tar.gz android_packages_apps_Trebuchet-5c86b5d9cd4543e6d04f8ef7fb1ba8f1c881c7ff.tar.bz2 android_packages_apps_Trebuchet-5c86b5d9cd4543e6d04f8ef7fb1ba8f1c881c7ff.zip |
Synchronizing invalidating interaction handler with the eventQueue.
In some cases, eventQueue could be running on the background thread where as
the invalidate happens on the UI thread, which could cause race conditions in
touch consumer
Change-Id: Iebd84238eb2b5d6774beaa3bc21afdeb09e62561
Diffstat (limited to 'quickstep')
4 files changed, 10 insertions, 15 deletions
diff --git a/quickstep/src/com/android/quickstep/BaseSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/BaseSwipeInteractionHandler.java index 5bf7e4ec9..b3ebd772c 100644 --- a/quickstep/src/com/android/quickstep/BaseSwipeInteractionHandler.java +++ b/quickstep/src/com/android/quickstep/BaseSwipeInteractionHandler.java @@ -20,13 +20,11 @@ import android.support.annotation.WorkerThread; import com.android.launcher3.states.InternalStateHandler; import com.android.quickstep.TouchConsumer.InteractionType; -import java.util.function.Consumer; - public abstract class BaseSwipeInteractionHandler extends InternalStateHandler { - protected Consumer<BaseSwipeInteractionHandler> mGestureEndCallback; + protected Runnable mGestureEndCallback; - public void setGestureEndCallback(Consumer<BaseSwipeInteractionHandler> gestureEndCallback) { + public void setGestureEndCallback(Runnable gestureEndCallback) { mGestureEndCallback = gestureEndCallback; } diff --git a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java index ae70474c0..ff7d434e7 100644 --- a/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java +++ b/quickstep/src/com/android/quickstep/NavBarSwipeInteractionHandler.java @@ -347,7 +347,7 @@ public class NavBarSwipeInteractionHandler extends BaseSwipeInteractionHandler i public void reset() { mCurrentShift.cancelAnimation(); if (mGestureEndCallback != null) { - mGestureEndCallback.accept(this); + mGestureEndCallback.run(); } } diff --git a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java index 604b60b90..786ade38b 100644 --- a/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java +++ b/quickstep/src/com/android/quickstep/OtherActivityTouchConsumer.java @@ -230,6 +230,9 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC } private void notifyGestureStarted() { + if (mInteractionHandler == null) { + return; + } // Notify the handler that the gesture has actually started mInteractionHandler.onGestureStarted(); @@ -275,7 +278,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC // Preload the plan mRecentsModel.loadTasks(mRunningTask.id, null); mInteractionHandler = handler; - mInteractionHandler.setGestureEndCallback(this::onFinish); + mInteractionHandler.setGestureEndCallback(mEventQueue::reset); } private Bitmap getCurrentTaskSnapshot() { @@ -314,7 +317,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC // Preload the plan mRecentsModel.loadTasks(mRunningTask.id, null); mInteractionHandler = handler; - handler.setGestureEndCallback(this::onFinish); + handler.setGestureEndCallback(mEventQueue::reset); CountDownLatch drawWaitLock = new CountDownLatch(1); handler.setLauncherOnDrawCallback(() -> { @@ -408,8 +411,8 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC // Clean up the old interaction handler if (mInteractionHandler != null) { final BaseSwipeInteractionHandler handler = mInteractionHandler; - mMainThreadExecutor.execute(handler::reset); mInteractionHandler = null; + mMainThreadExecutor.execute(handler::reset); } } @@ -450,12 +453,6 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC } } - private void onFinish(BaseSwipeInteractionHandler handler) { - if (mInteractionHandler == handler) { - mInteractionHandler = null; - } - } - public void switchToMainChoreographer() { mEventQueue.setInterimChoreographer(null); } diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java index ac253c70d..a6192c2f5 100644 --- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -688,7 +688,7 @@ public class WindowTransformSwipeHandler extends BaseSwipeInteractionHandler { mCurrentShift.cancelAnimation(); if (mGestureEndCallback != null) { - mGestureEndCallback.accept(this); + mGestureEndCallback.run(); } clearReference(); |