Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java +3 −2 Original line number Diff line number Diff line Loading @@ -97,10 +97,11 @@ public class NearestTouchFrame extends FrameLayout { } return mClickableChildren .stream() .filter(v -> v.isAttachedToWindow()) .filter(View::isAttachedToWindow) .map(v -> new Pair<>(distance(v, event), v)) .min(Comparator.comparingInt(f -> f.first)) .get().second; .map(data -> data.second) .orElse(null); } private int distance(View v, MotionEvent event) { Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java +13 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.systemui.statusbar.phone; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; Loading Loading @@ -171,6 +170,19 @@ public class NearestTouchFrameTest extends SysuiTestCase { ev.recycle(); } @Test public void testViewNotAttachedNoCrash() { View view = mockViewAt(0, 20, 10, 10); when(view.isAttachedToWindow()).thenReturn(false); mNearestTouchFrame.addView(view); mNearestTouchFrame.onMeasure(0, 0); MotionEvent ev = MotionEvent.obtain(0, 0, 0, 5 /* x */, 18 /* y */, 0); mNearestTouchFrame.onTouchEvent(ev); verify(view, never()).onTouchEvent(eq(ev)); ev.recycle(); } private View mockViewAt(int x, int y, int width, int height) { View v = spy(new View(mContext)); doAnswer(invocation -> { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NearestTouchFrame.java +3 −2 Original line number Diff line number Diff line Loading @@ -97,10 +97,11 @@ public class NearestTouchFrame extends FrameLayout { } return mClickableChildren .stream() .filter(v -> v.isAttachedToWindow()) .filter(View::isAttachedToWindow) .map(v -> new Pair<>(distance(v, event), v)) .min(Comparator.comparingInt(f -> f.first)) .get().second; .map(data -> data.second) .orElse(null); } private int distance(View v, MotionEvent event) { Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NearestTouchFrameTest.java +13 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.systemui.statusbar.phone; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; Loading Loading @@ -171,6 +170,19 @@ public class NearestTouchFrameTest extends SysuiTestCase { ev.recycle(); } @Test public void testViewNotAttachedNoCrash() { View view = mockViewAt(0, 20, 10, 10); when(view.isAttachedToWindow()).thenReturn(false); mNearestTouchFrame.addView(view); mNearestTouchFrame.onMeasure(0, 0); MotionEvent ev = MotionEvent.obtain(0, 0, 0, 5 /* x */, 18 /* y */, 0); mNearestTouchFrame.onTouchEvent(ev); verify(view, never()).onTouchEvent(eq(ev)); ev.recycle(); } private View mockViewAt(int x, int y, int width, int height) { View v = spy(new View(mContext)); doAnswer(invocation -> { Loading