Fix the seesaw behavior on the status panels.

The code in onMeasure that attempts to accommodate changing
child boundaries (i.e. an expanding/collapsing notification)
was locking the window size to the child measurement, even
though another window was trying to seesaw it closed. We now
only activate the rubberband behavior when the size of the
children changes, not on each onMeasure().

Lots of other small fixes to the panel expansion logic, too,
including ensuring that the expanded fraction doesn't jump
to 1.0f when the panel content hasn't been laid out yet
(causing the entire screen to become dim for a second thanks
to PhoneStatusBarView.panelExpansionChanged).

This change also restores the ability of Binder clients
(such as accessibility systems) to expand and collapse the
status bar.

Bug: 7008196
Bug: 6995518
Bug: 6628429
Change-Id: Ib0244a27aef2b4dbe19be98f7e039a9d38f1b80e
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index e0b7fe6..f83517b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -17,6 +17,8 @@
 package com.android.systemui.statusbar.phone;
 
 import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -28,12 +30,14 @@
 
 import com.android.systemui.ExpandHelper;
 import com.android.systemui.R;
+import com.android.systemui.statusbar.BaseStatusBar;
 import com.android.systemui.statusbar.policy.NotificationRowLayout;
 
 
 public class StatusBarWindowView extends FrameLayout
 {
-    private static final String TAG = "StatusBarWindowView";
+    public static final String TAG = "StatusBarWindowView";
+    public static final boolean DEBUG = BaseStatusBar.DEBUG;
 
     private ExpandHelper mExpandHelper;
     private NotificationRowLayout latestItems;
@@ -44,6 +48,7 @@
     public StatusBarWindowView(Context context, AttributeSet attrs) {
         super(context, attrs);
         setMotionEventSplittingEnabled(false);
+        setWillNotDraw(!DEBUG);
     }
 
     @Override
@@ -101,5 +106,17 @@
         }
         return handled;
     }
+
+    @Override
+    public void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        if (DEBUG) {
+            Paint pt = new Paint();
+            pt.setColor(0x80FFFF00);
+            pt.setStrokeWidth(12.0f);
+            pt.setStyle(Paint.Style.STROKE);
+            canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), pt);
+        }
+    }
 }