From 6b193434ee040c8216d686d2ab47b6e77d5204c7 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 20 Nov 2020 19:48:45 -0800 Subject: [PATCH] Jank: not blocking UI thread when starting a task This created jank at the end of quick switch. Test: Manual Bug: 173640772, 173072373 Change-Id: I86088255fa0cd8b369d9efec53fdac81210e71db Change-Id: I96f821013d900ef57d61c462f897cba17f106bb8 --- .../com/android/quickstep/views/TaskView.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 323034898d..1b55496cac 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -36,6 +36,7 @@ import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLAT import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_ICON_TAP_OR_LONGPRESS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_TAP; +import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -418,15 +419,21 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { if (freezeTaskList) { ActivityOptionsCompat.setFreezeRecentTasksList(opts); } - ActivityManagerWrapper.getInstance().startActivityFromRecentsAsync(mTask.key, - opts, (success) -> { - if (resultCallback != null && !success) { - // If the call to start activity failed, then post the result - // immediately, otherwise, wait for the animation start callback - // from the activity options above - resultCallbackHandler.post(() -> resultCallback.accept(false)); - } - }, resultCallbackHandler); + UI_HELPER_EXECUTOR.execute( + () -> ActivityManagerWrapper.getInstance().startActivityFromRecentsAsync( + mTask.key, + opts, + (success) -> { + if (resultCallback != null && !success) { + // If the call to start activity failed, then post the + // result + // immediately, otherwise, wait for the animation start + // callback + // from the activity options above + resultCallbackHandler.post( + () -> resultCallback.accept(false)); + } + }, resultCallbackHandler)); } } }