diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java | 3 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java index 004a6043ff94..1452e0c7a0b8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java @@ -87,7 +87,8 @@ public class NearestTouchFrame extends FrameLayout { if (mTouchingChild != null) { event.offsetLocation(mTouchingChild.getWidth() / 2 - event.getX(), mTouchingChild.getHeight() / 2 - event.getY()); - return mTouchingChild.dispatchTouchEvent(event); + return mTouchingChild.getVisibility() == VISIBLE + && mTouchingChild.dispatchTouchEvent(event); } } return super.onTouchEvent(event); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java index ed1491d31294..500d62012803 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java @@ -71,6 +71,24 @@ public class NearestTouchFrameTest extends SysuiTestCase { } @Test + public void testInvisibleViews() { + View left = mockViewAt(0, 0, 10, 10); + View right = mockViewAt(20, 0, 10, 10); + when(left.getVisibility()).thenReturn(View.INVISIBLE); + + mNearestTouchFrame.addView(left); + mNearestTouchFrame.addView(right); + mNearestTouchFrame.onMeasure(0, 0); + + MotionEvent ev = MotionEvent.obtain(0, 0, 0, + 12 /* x */, 5 /* y */, 0); + mNearestTouchFrame.onTouchEvent(ev); + verify(left, never()).onTouchEvent(eq(ev)); + verify(right, never()).onTouchEvent(eq(ev)); + ev.recycle(); + } + + @Test public void testHorizontalSelection_Left() { View left = mockViewAt(0, 0, 10, 10); View right = mockViewAt(20, 0, 10, 10); |