From d0f4896c1129de682014889c8e4b02906cbbd356 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 12 Sep 2022 23:23:14 -0700 Subject: [PATCH] Fix subsequent tabbing in recents from alt tab not working Fix: 242114350 Test: Alt+tab to go to overview, and then keep tabbing to switch to the previous tasks Change-Id: I03db23aa5424e46c0eb783379b0c5e959f75507f --- .../quickstep/OverviewCommandHelper.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index e84eb56759..57a26ee8ba 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -193,7 +193,20 @@ public class OverviewCommandHelper { } } - if (activityInterface.switchToRecentsIfVisible(() -> scheduleNextTask(cmd))) { + final Runnable completeCallback = () -> { + if (cmd.type == TYPE_SHOW_NEXT_FOCUS) { + RecentsView rv = activityInterface.getVisibleRecentsView(); + // When the overview is launched via alt tab (cmd type is TYPE_SHOW_NEXT_FOCUS), + // the touch mode somehow is not change to false by the Android framework. + // The subsequent tab to go through tasks in overview can only be dispatched to + // focuses views, while focus can only be requested in + // {@link View#requestFocusNoSearch(int, Rect)} when touch mode is false. To note, + // here we launch overview from home. + rv.getViewRootImpl().touchModeChanged(false); + } + scheduleNextTask(cmd); + }; + if (activityInterface.switchToRecentsIfVisible(completeCallback)) { // If successfully switched, wait until animation finishes return false; } @@ -268,6 +281,13 @@ public class OverviewCommandHelper { RecentsView rv = mOverviewComponentObserver.getActivityInterface().getVisibleRecentsView(); if (rv != null) { + // When the overview is launched via alt tab (cmd type is TYPE_SHOW_NEXT_FOCUS), + // the touch mode somehow is not change to false by the Android framework. + // The subsequent tab to go through tasks in overview can only be dispatched to + // focuses views, while focus can only be requested in + // {@link View#requestFocusNoSearch(int, Rect)} when touch mode is false. To note, + // here we launch overview with live tile. + rv.getViewRootImpl().touchModeChanged(false); // Ensure that recents view has focus so that it receives the followup key inputs TaskView taskView = rv.getNextTaskView(); if (taskView == null) {