From 4356311cfeb79b00e9f46147bdbcacf69693d929 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 29 Oct 2019 10:47:15 -0700 Subject: [PATCH] 17.5/ Remove synchronized calls, verify controller before finishing animation - The states that trigger the call are all on the UI thread, so we shouldn't need to synchronize before calling into it. But the second issue is that we set those states when the gesture ends and we calculate the end target. This can happen before the animation started or after the animation has been canceled, so we need to guard against the null controller as well. Bug: 143153963 Change-Id: I4649483a52c85c5662665d5e8905b49d5623b6dc --- .../android/quickstep/LauncherSwipeHandler.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java index a3db6ab9ce..3eb183eab4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java @@ -1188,20 +1188,21 @@ public class LauncherSwipeHandler private void finishCurrentTransitionToRecents() { if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); - } else if (!hasTargets()) { - // If there are no targets, then there is nothing to finish + } else if (!hasTargets() || mRecentsAnimationController == null) { + // If there are no targets or the animation not started, then there is nothing to finish mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); } else { - synchronized (mRecentsAnimationController) { - mRecentsAnimationController.finish(true /* toRecents */, - () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); - } + mRecentsAnimationController.finish(true /* toRecents */, + () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); } ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); } private void finishCurrentTransitionToHome() { - synchronized (mRecentsAnimationController) { + if (!hasTargets() || mRecentsAnimationController == null) { + // If there are no targets or the animation not started, then there is nothing to finish + mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED); + } else { mRecentsAnimationController.finish(true /* toRecents */, () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED), true /* sendUserLeaveHint */);