Prevent NPE on ExpandableNotificationRow.

An NPE could happen, related to falsing, if the very
first gesture to happen is a tap on an ExpandableNotificationRow.

Fixes: 187196123
Test: atest SystemUITests
Change-Id: I8a82fc4d85ba5676a6c198a0b6ddb67009c8ad8e
This commit is contained in:
Dave Mankoff
2021-05-04 17:06:05 -04:00
parent 9693ec26d9
commit fc1ea085d5
2 changed files with 8 additions and 1 deletions

View File

@@ -49,7 +49,7 @@ public class FalsingDataProvider {
private TimeLimitedMotionEventBuffer mRecentMotionEvents =
new TimeLimitedMotionEventBuffer(MOTION_EVENT_AGE_MS);
private List<MotionEvent> mPriorMotionEvents;
private List<MotionEvent> mPriorMotionEvents = new ArrayList<>();
private boolean mDirty = true;

View File

@@ -290,4 +290,11 @@ public class FalsingDataProviderTest extends ClassifierTest {
mDataProvider.onMotionEvent(appendDownEvent(0, 200));
verify(listener).onGestureFinalized(100);
}
@Test
public void test_GetPriorEventsEarly() {
// Ensure that if we ask for prior events before any events were added, we at least get
// an empty array.
assertThat(mDataProvider.getPriorMotionEvents()).isNotNull();
}
}