From ff0db38caf8de02adc92c2d394c23a47fcf4fdb5 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Tue, 30 Jun 2020 15:10:38 -0400 Subject: Ignore additional pointers in dispatchTouchEvent. We have no need for them and they can cause bugs. Test: touch many things all at once, observe only the first touch works Bug: 160196743 Change-Id: I1ee6948d43ccd9053ff8c620ee793457b1fa872a --- .../com/android/systemui/bubbles/BubbleStackView.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index cd27fdf9c947..749b537ea364 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -290,6 +290,12 @@ public class BubbleStackView extends FrameLayout /** Whether we're in the middle of dragging the stack around by touch. */ private boolean mIsDraggingStack = false; + /** + * The pointer index of the ACTION_DOWN event we received prior to an ACTION_UP. We'll ignore + * touches from other pointer indices. + */ + private int mPointerIndexDown = -1; + /** Description of current animation controller state. */ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("Stack view state:"); @@ -2220,6 +2226,18 @@ public class BubbleStackView extends FrameLayout @Override public boolean dispatchTouchEvent(MotionEvent ev) { + if (ev.getAction() != MotionEvent.ACTION_DOWN && ev.getActionIndex() != mPointerIndexDown) { + // Ignore touches from additional pointer indices. + return false; + } + + if (ev.getAction() == MotionEvent.ACTION_DOWN) { + mPointerIndexDown = ev.getActionIndex(); + } else if (ev.getAction() == MotionEvent.ACTION_UP + || ev.getAction() == MotionEvent.ACTION_CANCEL) { + mPointerIndexDown = -1; + } + boolean dispatched = super.dispatchTouchEvent(ev); // If a new bubble arrives while the collapsed stack is being dragged, it will be positioned -- cgit v1.2.3-59-g8ed1b