From 38397e46cfa38f47c43b2977e95420ce227a1685 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Thu, 17 Mar 2022 16:26:56 -0700 Subject: [PATCH] Limit the number of commands in OverviewCommandHelper * Rapidly tapping recents button in 3 button nav puts launcher in a strange state. Reproing and understanding that state is complex since so many state transitions are rapidly happening. * Easier to limit the number of commands a user will perform for valid use-cases. Fixes: 207680265 Test: Rapidly pressing recents when unfolded doesn't show live tile task on workspace. Change-Id: I7db849e83c2cafc37a419e189479283f2057bde6 --- .../android/quickstep/OverviewCommandHelper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index 17baa3ad91..a7bdcc62fd 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -54,6 +54,12 @@ public class OverviewCommandHelper { public static final int TYPE_TOGGLE = 4; public static final int TYPE_HOME = 5; + /** + * Use case for needing a queue is double tapping recents button in 3 button nav. + * Size of 2 should be enough. We'll toss in one more because we're kind hearted. + */ + private final static int MAX_QUEUE_SIZE = 3; + private static final String TRANSITION_NAME = "Transition:toOverview"; private final TouchInteractionService mService; @@ -105,10 +111,15 @@ public class OverviewCommandHelper { } /** - * Adds a command to be executed next, after all pending tasks are completed + * Adds a command to be executed next, after all pending tasks are completed. + * Max commands that can be queued is {@link #MAX_QUEUE_SIZE}. + * Requests after reaching that limit will be silently dropped. */ @BinderThread public void addCommand(int type) { + if (mPendingCommands.size() > MAX_QUEUE_SIZE) { + return; + } CommandInfo cmd = new CommandInfo(type); MAIN_EXECUTOR.execute(() -> addCommand(cmd)); }