From d41d038515bfc6ea8e9772c4e2cf4d10cc689a72 Mon Sep 17 00:00:00 2001 From: Miranda Kephart Date: Wed, 31 Mar 2021 13:49:28 -0400 Subject: [PATCH] Don't send long-press event if KEYCODE_UNKNOWN Gates sending a long-press event on the keycode not being unknown. This brings the behavior into line with the other times events are sent from KeyButtonView and fixes a bug where long-pressing the recents button in 3-button mode broke screenshots. When this happens we send an ACTION_DOWN event, but no ACTION_UP event, which prevents the key combination manager from correctly recognizing keychords. Bug: 181178545 Test: manual; repro = long-press the recents button in 3-button mode, then attempt to take a screenshot with power+vol_down. Change-Id: I26d232067befc3aca04c74e4ef8f4ad4ac629934 --- .../systemui/navigationbar/buttons/KeyButtonView.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java index f0e4cce299eef..531ccb4eb1cbf 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/buttons/KeyButtonView.java @@ -127,8 +127,10 @@ public class KeyButtonView extends ImageView implements ButtonInterface { performLongClick(); mLongClicked = true; } else { - sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); + if (mCode != KEYCODE_UNKNOWN) { + sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS); + sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); + } mLongClicked = true; } }