diff options
| author | Dake Gu <dake@google.com> | 2013-02-06 22:56:58 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-02-06 22:57:26 +0000 |
| commit | 96111ddff7af61ce37fa8d9020d8e1eeba9095e8 (patch) | |
| tree | 3f1b5ee915d41bd45ba6e3fb87431b61b2efe68a /core/java | |
| parent | b3a57191e62e0c394ba4a3448770853a1fb7ac3b (diff) | |
| parent | 9f811fd447206ed964fb576f55c1b38b76b45a4c (diff) | |
Merge "SimulatdDpad: fix NPE for event without device" into jb-mr1-aah-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/SimulatedDpad.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/java/android/view/SimulatedDpad.java b/core/java/android/view/SimulatedDpad.java index 0a37fddfa805..b03e4c71ec06 100644 --- a/core/java/android/view/SimulatedDpad.java +++ b/core/java/android/view/SimulatedDpad.java @@ -145,6 +145,10 @@ class SimulatedDpad { if (!synthesizeNewKeys) { mHandler.removeMessages(MSG_FLICK); } + InputDevice device = event.getDevice(); + if (device == null) { + return; + } // Store what time the touchpad event occurred final long time = SystemClock.uptimeMillis(); switch (event.getAction()) { @@ -157,7 +161,7 @@ class SimulatedDpad { mAccumulatedY = 0; mLastMoveX = 0; mLastMoveY = 0; - if (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax() + if (device.getMotionRange(MotionEvent.AXIS_Y).getMax() * EDGE_SWIPE_THRESHOLD < event.getY()) { // Did the swipe begin in a valid region mEdgeSwipePossible = true; @@ -176,7 +180,7 @@ class SimulatedDpad { } // Checks if the swipe has crossed the midpoint // and if our swipe gesture is complete - if (event.getY() < (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax() + if (event.getY() < (device.getMotionRange(MotionEvent.AXIS_Y).getMax() * .5) && mEdgeSwipePossible) { mEdgeSwipePossible = false; |
