Merge "Don't change geometry in relayout if preserve geometry is requested" into nyc-dev
diff --git a/core/java/android/provider/UserDictionary.java b/core/java/android/provider/UserDictionary.java
index a9b106a..c6e58cb 100644
--- a/core/java/android/provider/UserDictionary.java
+++ b/core/java/android/provider/UserDictionary.java
@@ -28,6 +28,9 @@
  * A provider of user defined words for input methods to use for predictive text input.
  * Applications and input methods may add words into the dictionary. Words can have associated
  * frequency information and locale information.
+ *
+ * <p><strong>NOTE: </strong>Starting on API 23, the user dictionary is only accessible through
+ * IME and spellchecker.
  */
 public class UserDictionary {
 
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index ba9bcaa..74ce753 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3368,8 +3368,8 @@
          tapping/clicking the whole thing is going to do. -->
     <string name="action_bar_home_subtitle_description_format">%1$s, %2$s, %3$s</string>
 
-    <!-- Storage description for internal storage. [CHAR LIMIT=NONE] -->
-    <string name="storage_internal">Internal storage</string>
+    <!-- Storage description for internal shared storage. [CHAR LIMIT=NONE] -->
+    <string name="storage_internal">Internal shared storage</string>
 
     <!-- Storage description for a generic SD card. [CHAR LIMIT=NONE] -->
     <string name="storage_sd_card">SD card</string>
diff --git a/packages/DocumentsUI/res/drawable-hdpi/ic_launcher_download.png b/packages/DocumentsUI/res/drawable-hdpi/ic_launcher_download.png
new file mode 100644
index 0000000..f958bbd
--- /dev/null
+++ b/packages/DocumentsUI/res/drawable-hdpi/ic_launcher_download.png
Binary files differ
diff --git a/packages/DocumentsUI/res/drawable-mdpi/ic_launcher_download.png b/packages/DocumentsUI/res/drawable-mdpi/ic_launcher_download.png
new file mode 100644
index 0000000..f2e9376
--- /dev/null
+++ b/packages/DocumentsUI/res/drawable-mdpi/ic_launcher_download.png
Binary files differ
diff --git a/packages/DocumentsUI/res/drawable-xhdpi/ic_launcher_download.png b/packages/DocumentsUI/res/drawable-xhdpi/ic_launcher_download.png
new file mode 100644
index 0000000..4dc5336
--- /dev/null
+++ b/packages/DocumentsUI/res/drawable-xhdpi/ic_launcher_download.png
Binary files differ
diff --git a/packages/DocumentsUI/res/drawable-xxhdpi/ic_launcher_download.png b/packages/DocumentsUI/res/drawable-xxhdpi/ic_launcher_download.png
new file mode 100644
index 0000000..8716290
--- /dev/null
+++ b/packages/DocumentsUI/res/drawable-xxhdpi/ic_launcher_download.png
Binary files differ
diff --git a/packages/DocumentsUI/res/drawable-xxxhdpi/ic_launcher_download.png b/packages/DocumentsUI/res/drawable-xxxhdpi/ic_launcher_download.png
new file mode 100644
index 0000000..f5be219
--- /dev/null
+++ b/packages/DocumentsUI/res/drawable-xxxhdpi/ic_launcher_download.png
Binary files differ
diff --git a/packages/DocumentsUI/res/drawable/ic_files_app.xml b/packages/DocumentsUI/res/drawable/ic_files_app.xml
index ff7189e..76e3ba6 100644
--- a/packages/DocumentsUI/res/drawable/ic_files_app.xml
+++ b/packages/DocumentsUI/res/drawable/ic_files_app.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <bitmap xmlns:android="http://schemas.android.com/apk/res/android"
-    android:src="@drawable/icon256"
+    android:src="@drawable/ic_launcher_download"
     android:tint="?android:attr/colorControlNormal"
     android:autoMirrored="true" />
diff --git a/packages/DocumentsUI/res/drawable/icon256.png b/packages/DocumentsUI/res/drawable/icon256.png
deleted file mode 100644
index 631c951..0000000
--- a/packages/DocumentsUI/res/drawable/icon256.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 8b433f9..8cd2167 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -397,9 +397,6 @@
     <!-- The padding on top of the first notification to the children container -->
     <dimen name="notification_children_container_top_padding">8dp</dimen>
 
-    <!-- The vertical distance from which the notification appear when children are expanded -->
-    <dimen name="notification_appear_distance">140dp</dimen>
-
     <!-- end margin for multi user switch in expanded quick settings -->
     <dimen name="multi_user_switch_expanded_margin">8dp</dimen>
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index bb4a771..7119559c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -2056,24 +2056,24 @@
         }
         for (int i = 0; i < N; i++) {
             NotificationData.Entry entry = activeNotifications.get(i);
+            boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
             if (onKeyguard) {
                 entry.row.setOnKeyguard(true);
             } else {
                 entry.row.setOnKeyguard(false);
-                boolean top = (i == 0);
-                entry.row.setSystemExpanded(top);
+                entry.row.setSystemExpanded(visibleNotifications == 0 && !childNotification);
             }
-            boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
+            boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup(entry.notification);
             boolean childWithVisibleSummary = childNotification
                     && mGroupManager.getGroupSummary(entry.notification).getVisibility()
                     == View.VISIBLE;
             boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
-            if ((isLockscreenPublicMode() && !mShowLockscreenNotifications) ||
+            if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) ||
                     (onKeyguard && (visibleNotifications >= maxNotifications
                             && !childWithVisibleSummary
                             || !showOnKeyguard))) {
                 entry.row.setVisibility(View.GONE);
-                if (onKeyguard && showOnKeyguard && !childNotification) {
+                if (onKeyguard && showOnKeyguard && !childNotification && !suppressedSummary) {
                     mKeyguardIconOverflowContainer.getIconsView().addNotification(entry);
                 }
             } else {
@@ -2082,7 +2082,8 @@
                 if (!childNotification) {
                     if (wasGone) {
                         // notify the scroller of a child addition
-                        mStackScroller.generateAddAnimation(entry.row, true /* fromMoreCard */);
+                        mStackScroller.generateAddAnimation(entry.row,
+                                !showOnKeyguard /* fromMoreCard */);
                     }
                     visibleNotifications++;
                 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 22bb8eb..a3af0a4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -858,7 +858,6 @@
             showing.setDark(dark, fade, delay);
         }
         if (mIsSummaryWithChildren) {
-            mChildrenContainer.setDark(dark, fade, delay);
             mNotificationHeaderWrapper.setDark(dark, fade, delay);
         }
     }
@@ -955,9 +954,6 @@
             mIsSystemExpanded = expand;
             notifyHeightChanged(false /* needsAnimation */);
             logExpansionEvent(false, wasExpanded);
-            if (mChildrenContainer != null) {
-                mChildrenContainer.updateGroupOverflow();
-            }
         }
     }
 
@@ -970,9 +966,6 @@
             mOnKeyguard = onKeyguard;
             logExpansionEvent(false, wasExpanded);
             if (wasExpanded != isExpanded()) {
-                if (mIsSummaryWithChildren) {
-                    mChildrenContainer.updateGroupOverflow();
-                }
                 notifyHeightChanged(false /* needsAnimation */);
             }
         }
@@ -1026,11 +1019,8 @@
 
     private void onChildrenCountChanged() {
         mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
-                && mGroupManager.hasGroupChildren(mStatusBarNotification);
+                && mChildrenContainer != null && mChildrenContainer.getChildCount() > 0;
         if (mIsSummaryWithChildren) {
-            if (mChildrenContainer == null) {
-                mChildrenContainerStub.inflate();
-            }
             if (mNotificationHeader == null) {
                 recreateNotificationHeader();
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java
index 28bb66f..a17501d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HybridNotificationViewManager.java
@@ -18,19 +18,10 @@
 
 import android.app.Notification;
 import android.content.Context;
-import android.text.BidiFormatter;
-import android.text.Spannable;
-import android.text.SpannableStringBuilder;
-import android.text.TextUtils;
-import android.text.style.TextAppearanceSpan;
 import android.view.LayoutInflater;
-import android.view.View;
 import android.view.ViewGroup;
 
 import com.android.systemui.R;
-import com.android.systemui.statusbar.ExpandableNotificationRow;
-
-import java.util.List;
 
 /**
  * A class managing {@link HybridNotificationView} views
@@ -81,34 +72,4 @@
         }
         return titleText;
     }
-
-    public HybridNotificationView bindFromNotificationGroup(
-            HybridNotificationView reusableView,
-            List<ExpandableNotificationRow> group, int startIndex) {
-        if (reusableView == null) {
-            reusableView = inflateHybridView();
-        }
-        SpannableStringBuilder summary = new SpannableStringBuilder();
-        int childCount = group.size();
-        for (int i = startIndex; i < childCount; i++) {
-            ExpandableNotificationRow child = group.get(i);
-            CharSequence titleText = resolveTitle(
-                    child.getStatusBarNotification().getNotification());
-            if (titleText == null) {
-                continue;
-            }
-            if (!TextUtils.isEmpty(summary)) {
-                summary.append(mDivider,
-                        new TextAppearanceSpan(mContext, R.style.
-                                TextAppearance_Material_Notification_HybridNotificationDivider),
-                        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
-            }
-            summary.append(BidiFormatter.getInstance().unicodeWrap(titleText));
-        }
-        // We want to force the same orientation as the layout RTL mode
-        BidiFormatter formater = BidiFormatter.getInstance(
-                reusableView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
-        reusableView.bind(formater.unicodeWrap(summary));
-        return reusableView;
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index d3681b7..54959d9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -17,7 +17,7 @@
 package com.android.systemui.statusbar.phone;
 
 import android.service.notification.StatusBarNotification;
-import android.util.ArraySet;
+import android.support.annotation.Nullable;
 
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.NotificationData;
@@ -35,7 +35,7 @@
     private final HashMap<String, NotificationGroup> mGroupMap = new HashMap<>();
     private OnGroupChangeListener mListener;
     private int mBarState = -1;
-    private ArraySet<String> mHeadsUpedEntries = new ArraySet<>();
+    private HashMap<String, StatusBarNotification> mHeadsUpedEntries = new HashMap<>();
 
     public void setOnGroupChangeListener(OnGroupChangeListener listener) {
         mListener = listener;
@@ -91,6 +91,7 @@
         } else {
             group.summary = null;
         }
+        updateSuppression(group);
         if (group.children.isEmpty()) {
             if (group.summary == null) {
                 mGroupMap.remove(groupKey);
@@ -109,43 +110,81 @@
         }
         if (isGroupChild) {
             group.children.add(added);
+            updateSuppression(group);
         } else {
             group.summary = added;
             group.expanded = added.row.areChildrenExpanded();
+            updateSuppression(group);
             if (!group.children.isEmpty()) {
                 mListener.onGroupCreatedFromChildren(group);
             }
         }
     }
 
+    private void updateSuppression(NotificationGroup group) {
+        if (group == null) {
+            return;
+        }
+        boolean prevSuppressed = group.suppressed;
+        group.suppressed = group.summary != null && !group.expanded
+                && (group.children.size() == 1
+                || (group.children.size() == 0
+                        && !group.summary.notification.getNotification().isGroupChild()
+                        && hasIsolatedChildren(group)));
+        if (prevSuppressed != group.suppressed) {
+            mListener.onGroupsChanged();
+        }
+    }
+
+    private boolean hasIsolatedChildren(NotificationGroup group) {
+        return getNumberOfIsolatedChildren(group.summary.notification.getGroupKey()) != 0;
+    }
+
+    private int getNumberOfIsolatedChildren(String groupKey) {
+        int count = 0;
+        for (StatusBarNotification sbn : mHeadsUpedEntries.values()) {
+            if (sbn.getGroupKey().equals(groupKey) && isIsolated(sbn)) {
+                count++;
+            }
+        }
+        return count;
+    }
+
     public void onEntryUpdated(NotificationData.Entry entry,
             StatusBarNotification oldNotification) {
         if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
             onEntryRemovedInternal(entry, oldNotification);
         }
         onEntryAdded(entry);
+        if (mHeadsUpedEntries.containsKey(entry.key)) {
+            mHeadsUpedEntries.put(entry.key, entry.notification);
+            String oldKey = oldNotification.getGroupKey();
+            String newKey = entry.notification.getGroupKey();
+            if (!oldKey.equals(newKey)) {
+                updateSuppression(mGroupMap.get(oldKey));
+                updateSuppression(mGroupMap.get(newKey));
+            }
+        }
     }
 
-    public boolean isVisible(StatusBarNotification sbn) {
-        if (!isGroupChild(sbn)) {
-            return true;
-        }
-        NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
-        if (group != null && (group.expanded || group.summary == null)) {
-            return true;
-        }
-        return false;
+    public boolean isSummaryOfSuppressedGroup(StatusBarNotification sbn) {
+        return isGroupSuppressed(getGroupKey(sbn)) && sbn.getNotification().isGroupSummary();
     }
 
-    public boolean hasGroupChildren(StatusBarNotification sbn) {
-        if (!isGroupSummary(sbn)) {
-            return false;
-        }
-        NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
-        if (group == null) {
-            return false;
-        }
-        return !group.children.isEmpty();
+    public boolean isOnlyChildInSuppressedGroup(StatusBarNotification sbn) {
+        return isGroupSuppressed(sbn.getGroupKey())
+                && sbn.getNotification().isGroupChild()
+                && getTotalNumberOfChildren(sbn) == 1;
+    }
+
+    private int getTotalNumberOfChildren(StatusBarNotification sbn) {
+        return getNumberOfIsolatedChildren(sbn.getGroupKey())
+                + mGroupMap.get(sbn.getGroupKey()).children.size();
+    }
+
+    private boolean isGroupSuppressed(String groupKey) {
+        NotificationGroup group = mGroupMap.get(groupKey);
+        return group != null && group.suppressed;
     }
 
     public void setStatusBarState(int newState) {
@@ -163,6 +202,7 @@
             if (group.expanded) {
                 setGroupExpanded(group, false);
             }
+            updateSuppression(group);
         }
     }
 
@@ -174,7 +214,7 @@
             return false;
         }
         NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
-        if (group == null || group.summary == null) {
+        if (group == null || group.summary == null || group.suppressed) {
             return false;
         }
         return true;
@@ -194,11 +234,30 @@
         return !group.children.isEmpty();
     }
 
+    /**
+     * Get the summary of a specified status bar notification. For isolated notification this return
+     * itself.
+     */
     public ExpandableNotificationRow getGroupSummary(StatusBarNotification sbn) {
-        NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
+        return getGroupSummary(getGroupKey(sbn));
+    }
+
+    /**
+     * Similar to {@link #getGroupSummary(StatusBarNotification)} but doesn't get the visual summary
+     * but the logical summary, i.e when a child is isolated, it still returns the summary as if
+     * it wasn't isolated.
+     */
+    public ExpandableNotificationRow getLogicalGroupSummary(
+            StatusBarNotification sbn) {
+        return getGroupSummary(sbn.getGroupKey());
+    }
+
+    @Nullable
+    private ExpandableNotificationRow getGroupSummary(String groupKey) {
+        NotificationGroup group = mGroupMap.get(groupKey);
         return group == null ? null
                 : group.summary == null ? null
-                : group.summary.row;
+                        : group.summary.row;
     }
 
     public void toggleGroupExpansion(StatusBarNotification sbn) {
@@ -210,7 +269,8 @@
     }
 
     private boolean isIsolated(StatusBarNotification sbn) {
-        return mHeadsUpedEntries.contains(sbn.getKey()) && sbn.getNotification().isGroupChild();
+        return mHeadsUpedEntries.containsKey(sbn.getKey())
+                && sbn.getNotification().isGroupChild();
     }
 
     private boolean isGroupSummary(StatusBarNotification sbn) {
@@ -249,20 +309,23 @@
     public void onHeadsUpStateChanged(NotificationData.Entry entry, boolean isHeadsUp) {
         final StatusBarNotification sbn = entry.notification;
         if (entry.row.isHeadsUp()) {
-            if (!mHeadsUpedEntries.contains(sbn.getKey())) {
-                final boolean groupChild = sbn.getNotification().isGroupChild();
-                if (groupChild) {
-                    // We will be isolated now, so lets update the groups
-                    onEntryRemovedInternal(entry, entry.notification);
-                }
-                mHeadsUpedEntries.add(sbn.getKey());
-                if (groupChild) {
-                    onEntryAdded(entry);
-                    mListener.onChildIsolationChanged();
-                }
+            final boolean groupChild = sbn.getNotification().isGroupChild();
+            if (groupChild) {
+                // We will be isolated now, so lets update the groups
+                onEntryRemovedInternal(entry, entry.notification);
+            }
+            mHeadsUpedEntries.put(sbn.getKey(), sbn);
+            if (groupChild) {
+                onEntryAdded(entry);
+                // We also need to update the suppression of the old group, because this call comes
+                // even before the groupManager knows about the notification at all.
+                // When the notification gets added afterwards it is already isolated and therefore
+                // it doesn't lead to an update.
+                updateSuppression(mGroupMap.get(entry.notification.getGroupKey()));
+                mListener.onGroupsChanged();
             }
         } else {
-            if (mHeadsUpedEntries.contains(sbn.getKey())) {
+            if (mHeadsUpedEntries.containsKey(sbn.getKey())) {
                 boolean isolatedBefore = isIsolated(sbn);
                 if (isolatedBefore) {
                     // not isolated anymore, we need to update the groups
@@ -271,7 +334,7 @@
                 mHeadsUpedEntries.remove(sbn.getKey());
                 if (isolatedBefore) {
                     onEntryAdded(entry);
-                    mListener.onChildIsolationChanged();
+                    mListener.onGroupsChanged();
                 }
             }
         }
@@ -281,6 +344,10 @@
         public final HashSet<NotificationData.Entry> children = new HashSet<>();
         public NotificationData.Entry summary;
         public boolean expanded;
+        /**
+         * Is this notification group suppressed, i.e its summary is hidden
+         */
+        public boolean suppressed;
     }
 
     public interface OnGroupChangeListener {
@@ -301,8 +368,9 @@
         void onGroupCreatedFromChildren(NotificationGroup group);
 
         /**
-         * The isolation of a child has changed i.e it's group changes.
+         * The groups have changed. This can happen if the isolation of a child has changes or if a
+         * group became suppressed / unsuppressed
          */
-        void onChildIsolationChanged();
+        void onGroupsChanged();
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index 6e345f0..a605a81 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -114,6 +114,9 @@
             if (!PhoneStatusBar.isTopLevelChild(ent)) {
                 continue;
             }
+            if (ent.row.getVisibility() == View.GONE) {
+                continue;
+            }
             toShow.add(ent.icon);
         }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index bf58611..e84d8fc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -132,6 +132,7 @@
 import com.android.systemui.statusbar.DragDownHelper;
 import com.android.systemui.statusbar.EmptyShadeView;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
+import com.android.systemui.statusbar.ExpandableView;
 import com.android.systemui.statusbar.GestureRecorder;
 import com.android.systemui.statusbar.KeyguardIndicationController;
 import com.android.systemui.statusbar.NotificationData;
@@ -1632,16 +1633,14 @@
     private void updateSpeedbump() {
         int speedbumpIndex = -1;
         int currentIndex = 0;
-        ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
-        final int N = activeNotifications.size();
+        final int N = mStackScroller.getChildCount();
         for (int i = 0; i < N; i++) {
-            Entry entry = activeNotifications.get(i);
-            boolean isChild = !isTopLevelChild(entry);
-            if (isChild) {
+            View view = mStackScroller.getChildAt(i);
+            if (view.getVisibility() == View.GONE || !(view instanceof ExpandableNotificationRow)) {
                 continue;
             }
-            if (entry.row.getVisibility() != View.GONE &&
-                    mNotificationData.isAmbient(entry.key)) {
+            ExpandableNotificationRow row = (ExpandableNotificationRow) view;
+            if (mNotificationData.isAmbient(row.getStatusBarNotification().getKey())) {
                 speedbumpIndex = currentIndex;
                 break;
             }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index 676ff2e..176788b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -46,19 +46,14 @@
 
     private final List<View> mDividers = new ArrayList<>();
     private final List<ExpandableNotificationRow> mChildren = new ArrayList<>();
-    private final HybridNotificationViewManager mHybridViewManager;
     private int mChildPadding;
     private int mDividerHeight;
     private int mMaxNotificationHeight;
     private int mNotificationHeaderHeight;
-    private int mNotificationAppearDistance;
     private int mNotificatonTopPadding;
     private float mCollapsedBottompadding;
-    private ViewInvertHelper mOverflowInvertHelper;
     private boolean mChildrenExpanded;
     private ExpandableNotificationRow mNotificationParent;
-    private HybridNotificationView mGroupOverflowContainer;
-    private ViewState mGroupOverFlowState;
     private int mRealHeight;
     private int mLayoutDirection = LAYOUT_DIRECTION_UNDEFINED;
     private boolean mUserLocked;
@@ -80,7 +75,6 @@
             int defStyleRes) {
         super(context, attrs, defStyleAttr, defStyleRes);
         initDimens();
-        mHybridViewManager = new HybridNotificationViewManager(getContext(), this);
     }
 
     private void initDimens() {
@@ -90,8 +84,6 @@
                 R.dimen.notification_divider_height));
         mMaxNotificationHeight = getResources().getDimensionPixelSize(
                 R.dimen.notification_max_height);
-        mNotificationAppearDistance = getResources().getDimensionPixelSize(
-                R.dimen.notification_appear_distance);
         mNotificationHeaderHeight = getResources().getDimensionPixelSize(
                 com.android.internal.R.dimen.notification_content_margin_top);
         mNotificatonTopPadding = getResources().getDimensionPixelSize(
@@ -111,10 +103,6 @@
             child.layout(0, 0, getWidth(), child.getMeasuredHeight());
             mDividers.get(i).layout(0, 0, getWidth(), mDividerHeight);
         }
-        if (mGroupOverflowContainer != null) {
-            mGroupOverflowContainer.layout(0, 0, getWidth(),
-                    mGroupOverflowContainer.getMeasuredHeight());
-        }
     }
 
     @Override
@@ -142,9 +130,6 @@
             height += mDividerHeight;
         }
         int width = MeasureSpec.getSize(widthMeasureSpec);
-        if (mGroupOverflowContainer != null) {
-            mGroupOverflowContainer.measure(widthMeasureSpec, newHeightSpec);
-        }
         mRealHeight = height;
         if (heightMode != MeasureSpec.UNSPECIFIED) {
             height = Math.min(height, size);
@@ -173,8 +158,6 @@
         View divider = inflateDivider();
         addView(divider);
         mDividers.add(newIndex, divider);
-
-        updateGroupOverflow();
     }
 
     public void removeNotification(ExpandableNotificationRow row) {
@@ -194,31 +177,6 @@
 
         row.setSystemChildExpanded(false);
         row.setUserLocked(false);
-        updateGroupOverflow();
-    }
-
-    public void updateGroupOverflow() {
-        int childCount = mChildren.size();
-        int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren(true /* likeCollapsed */);
-        boolean hasOverflow = childCount > maxAllowedVisibleChildren;
-        int lastVisibleIndex = hasOverflow ? maxAllowedVisibleChildren - 2
-                : maxAllowedVisibleChildren - 1;
-        if (hasOverflow) {
-            mGroupOverflowContainer = mHybridViewManager.bindFromNotificationGroup(
-                    mGroupOverflowContainer, mChildren, lastVisibleIndex + 1);
-            if (mOverflowInvertHelper == null) {
-                mOverflowInvertHelper= new ViewInvertHelper(mGroupOverflowContainer,
-                        NotificationPanelView.DOZE_ANIMATION_DURATION);
-            }
-            if (mGroupOverFlowState == null) {
-                mGroupOverFlowState = new ViewState();
-            }
-        } else if (mGroupOverflowContainer != null) {
-            removeView(mGroupOverflowContainer);
-            mGroupOverflowContainer = null;
-            mOverflowInvertHelper = null;
-            mGroupOverFlowState = null;
-        }
     }
 
     @Override
@@ -226,7 +184,6 @@
         super.onConfigurationChanged(newConfig);
         int layoutDirection = getLayoutDirection();
         if (layoutDirection != mLayoutDirection) {
-            updateGroupOverflow();
             mLayoutDirection = layoutDirection;
         }
     }
@@ -346,11 +303,7 @@
         int yPosition = mNotificationHeaderHeight;
         boolean firstChild = true;
         int maxAllowedVisibleChildren = getMaxAllowedVisibleChildren();
-        boolean hasOverflow = !mChildrenExpanded && childCount > maxAllowedVisibleChildren
-                && maxAllowedVisibleChildren != NUMBER_OF_CHILDREN_WHEN_CHILDREN_EXPANDED;
-        int lastVisibleIndex = hasOverflow
-                ? maxAllowedVisibleChildren - 2
-                : maxAllowedVisibleChildren - 1;
+        int lastVisibleIndex = maxAllowedVisibleChildren - 1;
         float expandFactor = 0;
         if (mUserLocked) {
             expandFactor = getChildExpandFraction();
@@ -391,15 +344,6 @@
             childState.location = parentState.location;
             yPosition += intrinsicHeight;
         }
-        if (mGroupOverflowContainer != null) {
-            mGroupOverFlowState.initFrom(mGroupOverflowContainer);
-            if (hasOverflow) {
-                StackViewState firstOverflowState =
-                        resultState.getViewStateForView(mChildren.get(lastVisibleIndex + 1));
-                mGroupOverFlowState.yTranslation = firstOverflowState.yTranslation;
-            }
-            mGroupOverFlowState.alpha = mChildrenExpanded || !hasOverflow ? 0.0f : 1.0f;
-        }
     }
 
     private int getMaxAllowedVisibleChildren() {
@@ -435,9 +379,8 @@
             }
             tmpState.alpha = alpha;
             state.applyViewState(divider, tmpState);
-        }
-        if (mGroupOverflowContainer != null) {
-            state.applyViewState(mGroupOverflowContainer, mGroupOverFlowState);
+            // There is no fake shadow to be drawn on the children
+            child.setFakeShadowIntensity(0.0f, 0.0f, 0, 0);
         }
     }
 
@@ -472,10 +415,8 @@
             }
             tmpState.alpha = alpha;
             stateAnimator.startViewAnimations(divider, tmpState, baseDelay, duration);
-        }
-        if (mGroupOverflowContainer != null) {
-            stateAnimator.startViewAnimations(mGroupOverflowContainer, mGroupOverFlowState,
-                    baseDelay, duration);
+            // There is no fake shadow to be drawn on the children
+            child.setFakeShadowIntensity(0.0f, 0.0f, 0, 0);
         }
     }
 
@@ -598,12 +539,6 @@
         return minExpandHeight;
     }
 
-    public void setDark(boolean dark, boolean fade, long delay) {
-        if (mGroupOverflowContainer != null) {
-            mOverflowInvertHelper.setInverted(dark, fade, delay);
-        }
-    }
-
     public void reInflateViews() {
         initDimens();
         for (int i = 0; i < mDividers.size(); i++) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 686a712..bd5dcc6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -694,11 +694,7 @@
                 mHeadsUpManager.addSwipedOutNotification(row.getStatusBarNotification().getKey());
             }
         }
-        final View veto = v.findViewById(R.id.veto);
-        if (veto != null && veto.getVisibility() != View.GONE) {
-            veto.performClick();
-        }
-        if (DEBUG) Log.v(TAG, "onChildDismissed: " + v);
+        performDismiss(v);
 
         mFalsingManager.onNotificationDismissed();
         if (mFalsingManager.shouldEnforceBouncer()) {
@@ -707,6 +703,24 @@
         }
     }
 
+    private void performDismiss(View v) {
+        if (v instanceof ExpandableNotificationRow) {
+            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
+            if (mGroupManager.isOnlyChildInSuppressedGroup(row.getStatusBarNotification())) {
+                ExpandableNotificationRow groupSummary =
+                        mGroupManager.getLogicalGroupSummary(row.getStatusBarNotification());
+                if (groupSummary.isClearable()) {
+                    performDismiss(groupSummary);
+                }
+            }
+        }
+        final View veto = v.findViewById(R.id.veto);
+        if (veto != null && veto.getVisibility() != View.GONE) {
+            veto.performClick();
+        }
+        if (DEBUG) Log.v(TAG, "onChildDismissed: " + v);
+    }
+
     @Override
     public void onChildSnappedBack(View animView, float targetLeft) {
         mAmbientState.onDragFinished(animView);
@@ -3265,7 +3279,7 @@
     }
 
     @Override
-    public void onChildIsolationChanged() {
+    public void onGroupsChanged() {
         mPhoneStatusBar.requestNotificationUpdate();
     }
 
diff --git a/services/core/java/com/android/server/connectivity/ApfFilter.java b/services/core/java/com/android/server/connectivity/ApfFilter.java
index d62a0b3..0014665 100644
--- a/services/core/java/com/android/server/connectivity/ApfFilter.java
+++ b/services/core/java/com/android/server/connectivity/ApfFilter.java
@@ -90,6 +90,7 @@
     }
 
     private static final String TAG = "ApfFilter";
+    private static final boolean DBG = true;
     private static final boolean VDBG = false;
 
     private final ConnectivityService mConnectivityService;
@@ -205,6 +206,10 @@
         // For debugging only. How many times this RA was seen.
         int seenCount = 0;
 
+        // For debugging only. Returns the hex representation of the last matching packet.
+        String getLastMatchingPacket() {
+            return HexDump.toHexString(mPacket.array(), 0, mPacket.capacity(), false /* lowercase */);
+        }
 
         private String IPv6AddresstoString(int pos) {
             try {
@@ -454,7 +459,7 @@
     private long mLastInstalledProgramMinLifetime;
 
     // For debugging only. The length in bytes of the last program.
-    private long mLastInstalledProgramLength;
+    private byte[] mLastInstalledProgram;
 
     private void installNewProgram() {
         if (mRas.size() == 0) return;
@@ -495,7 +500,7 @@
         }
         mLastTimeInstalledProgram = curTime();
         mLastInstalledProgramMinLifetime = programMinLifetime;
-        mLastInstalledProgramLength = program.length;
+        mLastInstalledProgram = program;
         if (VDBG) {
             hexDump("Installing filter: ", program, program.length);
         } else {
@@ -515,7 +520,7 @@
     }
 
     private void hexDump(String msg, byte[] packet, int length) {
-        log(msg + HexDump.toHexString(packet, 0, length));
+        log(msg + HexDump.toHexString(packet, 0, length, false /* lowercase */));
     }
 
     private void processRa(byte[] packet, int length) {
@@ -608,7 +613,7 @@
 
         pw.println(String.format(
                 "Last program length %d, installed %ds ago, lifetime %d",
-                mLastInstalledProgramLength, curTime() - mLastTimeInstalledProgram,
+                mLastInstalledProgram.length, curTime() - mLastTimeInstalledProgram,
                 mLastInstalledProgramMinLifetime));
 
         pw.println("RA filters:");
@@ -618,8 +623,22 @@
             pw.increaseIndent();
             pw.println(String.format(
                     "Seen: %d, last %ds ago", ra.seenCount, curTime() - ra.mLastSeen));
+            if (DBG) {
+                pw.println("Last match:");
+                pw.increaseIndent();
+                pw.println(ra.getLastMatchingPacket());
+                pw.decreaseIndent();
+            }
             pw.decreaseIndent();
         }
+
+        if (DBG) {
+            pw.println("Last program:");
+            pw.increaseIndent();
+            pw.println(HexDump.toHexString(mLastInstalledProgram, false /* lowercase */));
+            pw.decreaseIndent();
+        }
+
         pw.decreaseIndent();
     }
 }
diff --git a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
index 1ca94dc..ff3f19f 100644
--- a/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/PorterDuffColorFilter_Delegate.java
@@ -48,7 +48,7 @@
 
     // ---- delegate data ----
 
-    private final int mSrcColor;
+    private final java.awt.Color mSrcColor;
     private final Mode mMode;
 
 
@@ -66,9 +66,9 @@
 
     @Override
     public void applyFilter(Graphics2D g, int width, int height) {
-        BufferedImage image = createFilterImage(width, height);
         g.setComposite(getComposite(mMode, 0xFF));
-        g.drawImage(image, 0, 0, null);
+        g.setColor(mSrcColor);
+        g.fillRect(0, 0, width, height);
     }
 
     // ---- native methods ----
@@ -84,22 +84,10 @@
     // ---- Private delegate/helper methods ----
 
     private PorterDuffColorFilter_Delegate(int srcColor, int mode) {
-        mSrcColor = srcColor;
+        mSrcColor = new java.awt.Color(srcColor, true /* hasAlpha */);
         mMode = getCompatibleMode(getPorterDuffMode(mode));
     }
 
-    private BufferedImage createFilterImage(int width, int height) {
-        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
-        Graphics2D graphics = image.createGraphics();
-        try {
-            graphics.setColor(new java.awt.Color(mSrcColor, true /* hasAlpha */));
-            graphics.fillRect(0, 0, width, height);
-        } finally {
-            graphics.dispose();
-        }
-        return image;
-    }
-
     // For filtering the colors, the src image should contain the "color" only for pixel values
     // which are not transparent in the target image. But, we are using a simple rectangular image
     // completely filled with color. Hence some Composite rules do not apply as intended. However,