Show bouncer immediately when MOTION_UP is received

Bug: 15163546
Change-Id: Ie50905b78352e54298cb7e0e3f13152e6c2becd0
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index 7c1f2cf..7500c10 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -67,6 +67,7 @@
     private float mInitialTouchX;
 
     protected void onExpandingFinished() {
+        mBar.onExpandingFinished();
     }
 
     protected void onExpandingStarted() {
@@ -184,9 +185,9 @@
             case MotionEvent.ACTION_CANCEL:
                 mTracking = false;
                 mTrackingPointer = -1;
-                onTrackingStopped();
                 trackMovement(event);
-                flingWithCurrentVelocity();
+                boolean expand = flingWithCurrentVelocity();
+                onTrackingStopped(expand);
                 if (mVelocityTracker != null) {
                     mVelocityTracker.recycle();
                     mVelocityTracker = null;
@@ -196,8 +197,8 @@
         return true;
     }
 
-    protected void onTrackingStopped() {
-        mBar.onTrackingStopped(PanelView.this);
+    protected void onTrackingStopped(boolean expand) {
+        mBar.onTrackingStopped(PanelView.this, expand);
     }
 
     protected void onTrackingStarted() {
@@ -303,7 +304,10 @@
         mMaxPanelHeight = -1;
     }
 
-    private void flingWithCurrentVelocity() {
+    /**
+     * @return whether the panel will be expanded after the animation
+     */
+    private boolean flingWithCurrentVelocity() {
         float vel = getCurrentVelocity();
         boolean expand;
         if (Math.abs(vel) < mFlingAnimationUtils.getMinVelocityPxPerSecond()) {
@@ -312,11 +316,16 @@
             expand = vel > 0;
         }
         fling(vel, expand);
+        return expand;
     }
 
     protected void fling(float vel, boolean expand) {
         cancelPeek();
         float target = expand ? getMaxPanelHeight() : 0.0f;
+        if (target == mExpandedHeight) {
+            onExpandingFinished();
+            return;
+        }
         ValueAnimator animator = ValueAnimator.ofFloat(mExpandedHeight, target);
         if (expand) {
             mFlingAnimationUtils.apply(animator, mExpandedHeight, target, vel, getHeight());