Commit db6f8c7d authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

[Home] Check motion events before processing them

If the user is scrolling on the bottom toolbar before the browser is
ready and continues through the ready state, the gesture event filter
starts processing the stream without a down event, causing a crash.
This change adds null checks for the initial event in the gesture
detector to defend against this.

BUG=786889

Change-Id: I68a10c64653957f659e642f089a9037fddcbee5d
Reviewed-on: https://chromium-review.googlesource.com/779866Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518323}
parent dd36316a
...@@ -366,11 +366,14 @@ public class BottomSheet ...@@ -366,11 +366,14 @@ public class BottomSheet
private class BottomSheetSwipeDetector extends GestureDetector.SimpleOnGestureListener { private class BottomSheetSwipeDetector extends GestureDetector.SimpleOnGestureListener {
@Override @Override
public boolean onDown(MotionEvent e) { public boolean onDown(MotionEvent e) {
if (e == null) return false;
return shouldGestureMoveSheet(e, e); return shouldGestureMoveSheet(e, e);
} }
@Override @Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (e1 == null) return false;
if (!canMoveSheet()) { if (!canMoveSheet()) {
// Currently it's possible to enter the tab switcher after an onScroll() event has // Currently it's possible to enter the tab switcher after an onScroll() event has
// began. If that happens, reset the sheet offset and return false to end the scroll // began. If that happens, reset the sheet offset and return false to end the scroll
...@@ -426,7 +429,7 @@ public class BottomSheet ...@@ -426,7 +429,7 @@ public class BottomSheet
@Override @Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (!shouldGestureMoveSheet(e1, e2) || !mIsScrolling) return false; if (e1 == null || !shouldGestureMoveSheet(e1, e2) || !mIsScrolling) return false;
cancelAnimation(); cancelAnimation();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment