From 52941c5618d79c0fb7af655f47f558d956af28c8 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Sat, 7 May 2016 18:29:32 -0400 Subject: [PATCH] Fixed a bug where notifications could become orphaned When a child got set not be a heads up after it was already removed (When for example it was clicked on shortly after it got posted) then it got orphaned leading to bad bugs like the next notification not being visible. This could happen often with WhatsApp who set the head up flags on the summary instead of the children. Change-Id: I52c8f5d9bc50080e4ece530255236d36f998372e Fixes: 28565942 --- .../phone/NotificationGroupManager.java | 27 +++++++++++++++++++ .../statusbar/phone/PhoneStatusBar.java | 5 ++++ 2 files changed, 32 insertions(+) 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 9778a3a55c7ce..48fec7dd5968a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java @@ -24,9 +24,12 @@ import com.android.systemui.statusbar.NotificationData; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.policy.HeadsUpManager; +import java.io.FileDescriptor; +import java.io.PrintWriter; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.Map; import java.util.Objects; /** @@ -69,6 +72,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged public void onEntryRemoved(NotificationData.Entry removed) { onEntryRemovedInternal(removed, removed.notification); + mIsolatedEntries.remove(removed.key); } /** @@ -425,6 +429,19 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged mHeadsUpManager = headsUpManager; } + public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { + pw.println("GroupManager state:"); + pw.println(" number of groups: " + mGroupMap.size()); + for (Map.Entry entry : mGroupMap.entrySet()) { + pw.println("\n key: " + entry.getKey()); pw.println(entry.getValue()); + } + pw.println("\n isolated entries: " + mIsolatedEntries.size()); + for (Map.Entry entry : mIsolatedEntries.entrySet()) { + pw.print(" "); pw.print(entry.getKey()); + pw.print(", "); pw.println(entry.getValue()); + } + } + public static class NotificationGroup { public final HashSet children = new HashSet<>(); public NotificationData.Entry summary; @@ -433,6 +450,16 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged * Is this notification group suppressed, i.e its summary is hidden */ public boolean suppressed; + + @Override + public String toString() { + String result = " summary:\n " + summary.notification; + result += "\n children size: " + children.size(); + for (NotificationData.Entry child : children) { + result += "\n " + child.notification; + } + return result; + } } public interface OnGroupChangeListener { 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 21a0f9d98fdcc..1ec5e7f49afc1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3128,6 +3128,11 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } else { pw.println(" mHeadsUpManager: null"); } + if (mGroupManager != null) { + mGroupManager.dump(fd, pw, args); + } else { + pw.println(" mGroupManager: null"); + } if (KeyguardUpdateMonitor.getInstance(mContext) != null) { KeyguardUpdateMonitor.getInstance(mContext).dump(fd, pw, args); }