Fixed several bugs with the notification shade

Cleaned up the code around mMaxPanelHeight of the
PanelView which could lead to flickering during
peeking.
Changed the panel opening logic to account for lag
when we need to wait for a layout, which could lead
to inconsistent animations.
Fixed a bug where holes could appear in the shade
when notifications were updating.
This also improved the general updating behaviour
which is now done in a nicer animation.

Bug: 15942322
Bug: 15861506
Bug: 15168335
Change-Id: Ifd7ce51bea6b5e39c9b76fd0d766a7d2c42bf7a4
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 43b7707..9ac20a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -88,9 +88,14 @@
         mExpansionDisabled = false;
         mPublicLayout.reset();
         mPrivateLayout.reset();
+        resetHeight();
+        logExpansionEvent(false, wasExpanded);
+    }
+
+    public void resetHeight() {
         mMaxExpandHeight = 0;
         mWasReset = true;
-        logExpansionEvent(false, wasExpanded);
+        onHeightReset();
     }
 
     @Override
@@ -178,20 +183,26 @@
      * @param expand whether the system wants this notification to be expanded.
      */
     public void setSystemExpanded(boolean expand) {
-        final boolean wasExpanded = isExpanded();
-        mIsSystemExpanded = expand;
-        notifyHeightChanged();
-        logExpansionEvent(false, wasExpanded);
+        if (expand != mIsSystemExpanded) {
+            final boolean wasExpanded = isExpanded();
+            mIsSystemExpanded = expand;
+            notifyHeightChanged();
+            logExpansionEvent(false, wasExpanded);
+        }
     }
 
     /**
      * @param expansionDisabled whether to prevent notification expansion
      */
     public void setExpansionDisabled(boolean expansionDisabled) {
-        final boolean wasExpanded = isExpanded();
-        mExpansionDisabled = expansionDisabled;
-        logExpansionEvent(false, wasExpanded);
-        notifyHeightChanged();
+        if (expansionDisabled != mExpansionDisabled) {
+            final boolean wasExpanded = isExpanded();
+            mExpansionDisabled = expansionDisabled;
+            logExpansionEvent(false, wasExpanded);
+            if (wasExpanded != isExpanded()) {
+                notifyHeightChanged();
+            }
+        }
     }
 
     /**
@@ -368,9 +379,8 @@
         mPrivateLayout.notifyContentUpdated();
     }
 
-    public boolean isShowingLayoutLayouted() {
-        NotificationContentView showingLayout = getShowingLayout();
-        return showingLayout.getWidth() != 0;
+    public boolean isMaxExpandHeightInitialized() {
+        return mMaxExpandHeight != 0;
     }
 
     private NotificationContentView getShowingLayout() {