Fix shade flicker & touch absorption

Intercept MOVE events for closed shade (with no HUNs)
and call startExpandMotion when appropriate.
----------------------------------------------------
Fixes: 188249360 (shade flicker to full height on swipe open)

This bug happened because ag/13733252 introduced
a new behavior (reverted here) where
PVC intercepts only if PanelView is hidden. This means:
=> PanelView initially shows onIntercept(down),
so we do NOT intercept and onTouch(down) does NOT run.
=> PanelView is then hidden onIntercept(move),
so we intercept and onTouch(move) runs.

When onTouch(down) does NOT run and onTouch(move) runs,
we are MISSING the following:
=> onTouch(down): mGestureWaitForTouchSlop = true for closed shade
=> onTouch(move) calls startExpandMotion
=> startExpandMotion: mInitialOffsetOnTouch = 0
=> onTouch(move): newHeight = mInitialOffsetOnTouch = 0

Instead, newHeight = full shade height from previous shade open.
This causes the shade to jump to full height on swipe start.
----------------------------------------------------
Bug: 178277858 (touch absorption / shade not opening on swipe)

This bug happened because onIntercept(move) did not intercept and call
startExpandMotion when we swipe open from closed shade, resulting in
the shade staying closed while child views silently eat the event.
------------------------------------------------
Test: open/close shade with varying drag speeds and flings
  => shade consistently opens with no flicker to full height
Test: swipe-to-dismiss hun, expand hun, swipe down for hun-to-shade
  => no regressions

Change-Id: I26ada34ed173393ee08a96aefd37b1935702bb90
(cherry picked from commit c5b0f4ebf2a4c0acd36992f012847e94d37e5adb)
Merged-In:I26ada34ed173393ee08a96aefd37b1935702bb90
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
index 323a112..de0f31d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
@@ -1211,10 +1211,14 @@
                 case MotionEvent.ACTION_MOVE:
                     final float h = y - mInitialTouchY;
                     addMovement(event);
-                    if (canCollapsePanel || mTouchStartedInEmptyArea || mAnimatingOnDown) {
+                    final boolean openShadeWithoutHun =
+                            mPanelClosedOnDown && !mCollapsedAndHeadsUpOnDown;
+                    if (canCollapsePanel || mTouchStartedInEmptyArea || mAnimatingOnDown
+                            || openShadeWithoutHun) {
                         float hAbs = Math.abs(h);
                         float touchSlop = getTouchSlop(event);
-                        if ((h < -touchSlop || (mAnimatingOnDown && hAbs > touchSlop))
+                        if ((h < -touchSlop
+                                || ((openShadeWithoutHun || mAnimatingOnDown) && hAbs > touchSlop))
                                 && hAbs > Math.abs(x - mInitialTouchX)) {
                             cancelHeightAnimator();
                             startExpandMotion(x, y, true /* startTracking */, mExpandedHeight);
@@ -1227,10 +1231,7 @@
                     mVelocityTracker.clear();
                     break;
             }
-
-            // Finally, if none of the above cases applies, ensure that touches do not get handled
-            // by the contents of a panel that is not showing (a bit of a hack to avoid b/178277858)
-            return (mView.getVisibility() != View.VISIBLE);
+            return false;
         }
 
         @Override