Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: ui/android/java/src/org/chromium/ui/base/TouchDevice.java

Issue 1087263004: Added checks in TouchDevice.java to avoid NPEs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/base/TouchDevice.java
diff --git a/ui/android/java/src/org/chromium/ui/base/TouchDevice.java b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java
index 440e95c8c281fcec789b123113506f856f6fc367..a5fc9793c2752c2fed43b90ce10870519357c7b1 100644
--- a/ui/android/java/src/org/chromium/ui/base/TouchDevice.java
+++ b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java
@@ -57,7 +57,10 @@ public class TouchDevice {
int pointerTypesVal = 0;
for (int deviceId : InputDevice.getDeviceIds()) {
- int sources = InputDevice.getDevice(deviceId).getSources();
+ InputDevice inputDevice = InputDevice.getDevice(deviceId);
+ if (inputDevice == null) continue;
+
+ int sources = inputDevice.getSources();
if (hasSource(sources, InputDevice.SOURCE_MOUSE)
|| hasSource(sources, InputDevice.SOURCE_STYLUS)
@@ -84,7 +87,10 @@ public class TouchDevice {
int hoverTypesVal = 0;
for (int deviceId : InputDevice.getDeviceIds()) {
- int sources = InputDevice.getDevice(deviceId).getSources();
+ InputDevice inputDevice = InputDevice.getDevice(deviceId);
+ if (inputDevice == null) continue;
+
+ int sources = inputDevice.getSources();
if (hasSource(sources, InputDevice.SOURCE_MOUSE)
|| hasSource(sources, InputDevice.SOURCE_TOUCHPAD)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698