From 388df60393ac0daafa5778c4df60034d2d0064a4 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Wed, 8 Apr 2020 14:07:06 -0700 Subject: [PATCH] PIP: Disable hover show/hide menu if accessibility service is on. With accessibility services on (e.g. Talkback), some MotionEvents get transformed into HoverEvents. Notably in the case of TalkBack, tapping on PIP will generate a pair of Hover enter/exit event, which then causes the menu to immediately show/hide, and the user is unable to do anything. We will disable the hover behavior for Accessibility services, and allow TalkBack users and such to open the menu via other menus (just tapping it twice so it shows menu similiar to a regular user flow). Bug: 152588263 Test: Enable talkback, enter PIP, tap once and then again - menu shows Change-Id: I28c8faa0032bc2c7b8fa1ef5a9efde94a590293e --- .../systemui/pip/phone/PipTouchHandler.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java index 7cc2759ad59a9..c95c0f8ab415d 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java @@ -413,8 +413,14 @@ public class PipTouchHandler { break; } case MotionEvent.ACTION_HOVER_ENTER: - mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(), - mMovementBounds, false /* allowMenuTimeout */, false /* willResizeMenu */); + // If Touch Exploration is enabled, some a11y services (e.g. Talkback) is probably + // on and changing MotionEvents into HoverEvents. + // Let's not enable menu show/hide for a11y services. + if (!mAccessibilityManager.isTouchExplorationEnabled()) { + mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(), + mMovementBounds, false /* allowMenuTimeout */, + false /* willResizeMenu */); + } case MotionEvent.ACTION_HOVER_MOVE: { if (!shouldDeliverToMenu && !mSendingHoverAccessibilityEvents) { sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); @@ -423,7 +429,12 @@ public class PipTouchHandler { break; } case MotionEvent.ACTION_HOVER_EXIT: { - mMenuController.hideMenu(); + // If Touch Exploration is enabled, some a11y services (e.g. Talkback) is probably + // on and changing MotionEvents into HoverEvents. + // Let's not enable menu show/hide for a11y services. + if (!mAccessibilityManager.isTouchExplorationEnabled()) { + mMenuController.hideMenu(); + } if (!shouldDeliverToMenu && mSendingHoverAccessibilityEvents) { sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); mSendingHoverAccessibilityEvents = false;