From c44caa9b841df604a66834df495710e354c7e018 Mon Sep 17 00:00:00 2001 From: Christoph Studer Date: Fri, 22 Aug 2014 19:16:00 +0200 Subject: [PATCH] NoMan: Cancel children when update removes summary When a notification update causes a group summary to be removed (e.g. because the group summary is updated to be a non-grouped notification), cancel group children. Bug: 17143007 Change-Id: Ic295a5fc6ee5fe7efb8e71fe8bd1b2c0159461aa --- .../notification/NotificationManagerService.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 45bd812af943b..85806ba225c36 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1626,6 +1626,16 @@ public class NotificationManagerService extends SystemService { } synchronized (mNotificationList) { + // Clear out group children of the old notification if the update causes the + // group summary to go away. This happens when the old notification was a + // summary and the new one isn't, or when the old notification was a summary + // and its group key changed. + if (old != null && old.getNotification().isGroupSummary() && + (!notification.isGroupSummary() || + !old.getGroupKey().equals(r.getGroupKey()))) { + cancelGroupChildrenLocked(old, callingUid, callingPid, null); + } + int index = indexOfNotificationLocked(n.getKey()); if (index < 0) { mNotificationList.add(r); @@ -2376,10 +2386,9 @@ public class NotificationManagerService extends SystemService { final int N = mNotificationList.size(); for (int i = N - 1; i >= 0; i--) { NotificationRecord childR = mNotificationList.get(i); - Notification childN = childR.getNotification(); StatusBarNotification childSbn = childR.sbn; - if (childR.getUserId() == userId && pkg.equals(childSbn.getPackageName()) && - n.getGroup().equals(childN.getGroup())) { + if (childR.getNotification().isGroupChild() && + childR.getGroupKey().equals(r.getGroupKey())) { EventLogTags.writeNotificationCancel(callingUid, callingPid, pkg, childSbn.getId(), childSbn.getTag(), userId, 0, 0, REASON_GROUP_SUMMARY_CANCELED, listenerName);