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 a27ec28b7a073..fffb20a7425c7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java @@ -26,6 +26,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.Objects; /** @@ -37,6 +38,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged private OnGroupChangeListener mListener; private int mBarState = -1; private HashMap mIsolatedEntries = new HashMap<>(); + private HeadsUpManager mHeadsUpManager; public void setOnGroupChangeListener(OnGroupChangeListener listener) { mListener = listener; @@ -142,6 +144,9 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged && group.summary.notification.getNotification().isGroupSummary() && hasIsolatedChildren(group))); if (prevSuppressed != group.suppressed) { + if (group.suppressed) { + handleSuppressedSummaryHeadsUpped(group.summary); + } mListener.onGroupsChanged(); } } @@ -160,6 +165,15 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged return count; } + private NotificationData.Entry getIsolatedChild(String groupKey) { + for (StatusBarNotification sbn : mIsolatedEntries.values()) { + if (sbn.getGroupKey().equals(groupKey) && isIsolated(sbn)) { + return mGroupMap.get(sbn.getKey()).summary; + } + } + return null; + } + public void onEntryUpdated(NotificationData.Entry entry, StatusBarNotification oldNotification) { if (mGroupMap.get(getGroupKey(oldNotification)) != null) { @@ -332,6 +346,9 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged // it doesn't lead to an update. updateSuppression(mGroupMap.get(entry.notification.getGroupKey())); mListener.onGroupsChanged(); + } else { + handleSuppressedSummaryHeadsUpped(entry); + } } else { if (mIsolatedEntries.containsKey(sbn.getKey())) { @@ -344,6 +361,32 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged } } + private void handleSuppressedSummaryHeadsUpped(NotificationData.Entry entry) { + StatusBarNotification sbn = entry.notification; + if (!isGroupSuppressed(sbn.getGroupKey()) + || !sbn.getNotification().isGroupSummary() + || !entry.row.isHeadsUp()) { + return; + } + // The parent of a suppressed group got huned, lets hun the child! + NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey()); + if (notificationGroup != null) { + Iterator iterator = notificationGroup.children.iterator(); + NotificationData.Entry child = iterator.hasNext() ? iterator.next() : null; + if (child == null) { + child = getIsolatedChild(sbn.getGroupKey()); + } + if (child != null) { + if (mHeadsUpManager.isHeadsUp(child.key)) { + mHeadsUpManager.updateNotification(child, true); + } else { + mHeadsUpManager.showNotification(child); + } + } + } + mHeadsUpManager.releaseImmediately(entry.key); + } + private boolean shouldIsolate(StatusBarNotification sbn) { NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey()); return (sbn.isGroup() && !sbn.getNotification().isGroupSummary()) @@ -360,6 +403,10 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged || notificationGroup.summary.row.getTranslationY() < 0; } + public void setHeadsUpManager(HeadsUpManager headsUpManager) { + mHeadsUpManager = headsUpManager; + } + public static class NotificationGroup { public final HashSet children = new HashSet<>(); public NotificationData.Entry summary; 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 ec1ad4664b8a0..e52a401937d31 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -729,6 +729,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mHeadsUpManager.addListener(mGroupManager); mNotificationPanel.setHeadsUpManager(mHeadsUpManager); mNotificationData.setHeadsUpManager(mHeadsUpManager); + mGroupManager.setHeadsUpManager(mHeadsUpManager); if (MULTIUSER_DEBUG) { mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index ab817127564c7..ebefdde0f9b55 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -185,6 +185,11 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL if (alert) { HeadsUpEntry headsUpEntry = mHeadsUpEntries.get(headsUp.key); + if (headsUpEntry == null) { + // the entry was released before this update (i.e by a listener) This can happen + // with the groupmanager + return; + } headsUpEntry.updateEntry(); setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUp)); }