Fix listening states for two-finger and fast-double swipe

Bug: 16655660
Change-Id: I46d826edc901e08eb1513fe87de2f63228581617
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index bac46be..55b147a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -602,6 +602,10 @@
                 && event.getY(event.getActionIndex()) < mStatusBarMinHeight) {
             mTwoFingerQsExpand = true;
             requestPanelHeightUpdate();
+
+            // Normally, we start listening when the panel is expanded, but here we need to start
+            // earlier so the state is already up to date when dragging down.
+            setListening(true);
         }
         super.onTouchEvent(event);
         return true;
@@ -621,6 +625,11 @@
             mInitialHeightOnTouch = mQsExpansionHeight;
             mInitialTouchY = event.getX();
             mInitialTouchX = event.getY();
+
+            // If we interrupt an expansion gesture here, make sure to update the state correctly.
+            if (mIsExpanding) {
+                onExpandingFinished();
+            }
         }
     }