Commit 55f9a771 authored by jdduke's avatar jdduke Committed by Commit bot

[Android] Properly validate potentially null InputDevice

As InputDevice.getDevice() makes no guarantees that the returned device
will be non-null, always validate the return value before using in a
meaningful way as a Gamepad device.

BUG=421168

Review URL: https://codereview.chromium.org/644783003

Cr-Commit-Position: refs/heads/master@{#299016}
parent bed0a737
...@@ -247,6 +247,7 @@ public class GamepadList { ...@@ -247,6 +247,7 @@ public class GamepadList {
} }
private static boolean isGamepadDevice(InputDevice inputDevice) { private static boolean isGamepadDevice(InputDevice inputDevice) {
if (inputDevice == null) return false;
return ((inputDevice.getSources() & InputDevice.SOURCE_JOYSTICK) == return ((inputDevice.getSources() & InputDevice.SOURCE_JOYSTICK) ==
InputDevice.SOURCE_JOYSTICK); InputDevice.SOURCE_JOYSTICK);
} }
......
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