Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96111ddf authored by Dake Gu's avatar Dake Gu Committed by Android (Google) Code Review
Browse files

Merge "SimulatdDpad: fix NPE for event without device" into jb-mr1-aah-dev

parents b3a57191 9f811fd4
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -145,6 +145,10 @@ class SimulatedDpad {
        if (!synthesizeNewKeys) {
        if (!synthesizeNewKeys) {
            mHandler.removeMessages(MSG_FLICK);
            mHandler.removeMessages(MSG_FLICK);
        }
        }
        InputDevice device = event.getDevice();
        if (device == null) {
            return;
        }
        // Store what time the touchpad event occurred
        // Store what time the touchpad event occurred
        final long time = SystemClock.uptimeMillis();
        final long time = SystemClock.uptimeMillis();
        switch (event.getAction()) {
        switch (event.getAction()) {
@@ -157,7 +161,7 @@ class SimulatedDpad {
                mAccumulatedY = 0;
                mAccumulatedY = 0;
                mLastMoveX = 0;
                mLastMoveX = 0;
                mLastMoveY = 0;
                mLastMoveY = 0;
                if (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax()
                if (device.getMotionRange(MotionEvent.AXIS_Y).getMax()
                        * EDGE_SWIPE_THRESHOLD < event.getY()) {
                        * EDGE_SWIPE_THRESHOLD < event.getY()) {
                    // Did the swipe begin in a valid region
                    // Did the swipe begin in a valid region
                    mEdgeSwipePossible = true;
                    mEdgeSwipePossible = true;
@@ -176,7 +180,7 @@ class SimulatedDpad {
                }
                }
                // Checks if the swipe has crossed the midpoint
                // Checks if the swipe has crossed the midpoint
                // and if our swipe gesture is complete
                // 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) {
                        * .5) && mEdgeSwipePossible) {
                    mEdgeSwipePossible = false;
                    mEdgeSwipePossible = false;