From 690d897c8845297a466a943a2fa388460182a8cb Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Fri, 5 May 2023 10:56:00 -0700 Subject: [PATCH] [Reland] Fix touch focus not updated correctly after launching overview with live tile. - Set touch mode to false at the first dpad left or right key event, since the framework doesn't do so in the live tile case - Clear focus at any motion event Similar to ag/19938037 Fixes: 277625965 Test: Meta+Tab to launch overview from app, or swipe from app, then use DPAD_LEFT and DPAD_RIGHT to go through overview. Make sure the selected task is highlighted. Also make sure swipe up to overview and go home doesn't highlight any icons on the home screen Change-Id: I7afa46af7eb1cd826d2dc893583685936721868a --- .../inputconsumers/OverviewInputConsumer.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java index 64165b66e4..338864264a 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java @@ -51,6 +51,7 @@ public class OverviewInputConsumer, T extends StatefulAct private final boolean mStartingInActivityBounds; private boolean mTargetHandledTouch; + private boolean mHasSetTouchModeForFirstDPadEvent; public OverviewInputConsumer(GestureState gestureState, T activity, @Nullable InputMonitorCompat inputMonitor, boolean startingInActivityBounds) { @@ -95,6 +96,9 @@ public class OverviewInputConsumer, T extends StatefulAct mInputMonitor.pilferPointers(); } } + if (mHasSetTouchModeForFirstDPadEvent) { + mActivity.getRootView().clearFocus(); + } } @Override @@ -112,6 +116,19 @@ public class OverviewInputConsumer, T extends StatefulAct mgr.dispatchVolumeKeyEventAsSystemService(ev, AudioManager.USE_DEFAULT_STREAM_TYPE); break; + case KeyEvent.KEYCODE_DPAD_LEFT: + case KeyEvent.KEYCODE_DPAD_RIGHT: + if (!mHasSetTouchModeForFirstDPadEvent) { + // When Overview is launched via meta+tab or swipe up from an app, the touch + // mode somehow is not changed to false by the Android framework. The subsequent + // key events (e.g. DPAD_LEFT, DPAD_RIGHT) can only be dispatched to focused + // 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. + mHasSetTouchModeForFirstDPadEvent = true; + mActivity.getRootView().getViewRootImpl().touchModeChanged(false); + } + break; default: break; }