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

Commit 9d09824a authored by Daniel Sandler's avatar Daniel Sandler
Browse files

Fix NPE if pulling down QS quickly on very first boot.

The cling interception code can interfere with the touch
stream to the point that PanelView might get an ACTION_UP or
_CANCEL without a corresponding ACTION_DOWN, causing
problems.

Bug: 7301742
Change-Id: Idd5074c2544b3238517655ab3c068966bae9f912
parent b3419595
Loading
Loading
Loading
Loading
+23 −16
Original line number Diff line number Diff line
@@ -281,12 +281,18 @@ public class PanelView extends FrameLayout {
                            mHandleView.setPressed(false);
                            mBar.onTrackingStopped(PanelView.this);
                            trackMovement(event);

                            float vel = 0, yVel = 0, xVel = 0;
                            boolean negative = false;

                            if (mVelocityTracker != null) {
                                // the velocitytracker might be null if we got a bad input stream
                                mVelocityTracker.computeCurrentVelocity(1000);

                            float yVel = mVelocityTracker.getYVelocity();
                            boolean negative = yVel < 0;
                                yVel = mVelocityTracker.getYVelocity();
                                negative = yVel < 0;

                            float xVel = mVelocityTracker.getXVelocity();
                                xVel = mVelocityTracker.getXVelocity();
                                if (xVel < 0) {
                                    xVel = -xVel;
                                }
@@ -294,11 +300,15 @@ public class PanelView extends FrameLayout {
                                    xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis
                                }

                            float vel = (float)Math.hypot(yVel, xVel);
                                vel = (float)Math.hypot(yVel, xVel);
                                if (vel > mFlingGestureMaxOutputVelocityPx) {
                                    vel = mFlingGestureMaxOutputVelocityPx;
                                }

                                mVelocityTracker.recycle();
                                mVelocityTracker = null;
                            }

                            // if you've barely moved your finger, we treat the velocity as 0
                            // preventing spurious flings due to touch screen jitter
                            final float deltaY = Math.abs(mFinalTouchY - mInitialTouchY);
@@ -321,9 +331,6 @@ public class PanelView extends FrameLayout {

                            fling(vel, true);

                            mVelocityTracker.recycle();
                            mVelocityTracker = null;

                            break;
                    }
                    return true;