1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package com.android.systemui.statusbar.phone;
18 
19 import android.annotation.Nullable;
20 import android.service.notification.StatusBarNotification;
21 import android.util.ArraySet;
22 import android.util.Log;
23 
24 import com.android.systemui.Dependency;
25 import com.android.systemui.bubbles.BubbleController;
26 import com.android.systemui.plugins.statusbar.StatusBarStateController;
27 import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
28 import com.android.systemui.statusbar.StatusBarState;
29 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
30 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
31 import com.android.systemui.statusbar.policy.HeadsUpManager;
32 import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
33 
34 import java.io.FileDescriptor;
35 import java.io.PrintWriter;
36 import java.util.ArrayList;
37 import java.util.HashMap;
38 import java.util.Map;
39 import java.util.Objects;
40 
41 import javax.inject.Inject;
42 import javax.inject.Singleton;
43 
44 /**
45  * A class to handle notifications and their corresponding groups.
46  */
47 @Singleton
48 public class NotificationGroupManager implements OnHeadsUpChangedListener, StateListener {
49 
50     private static final String TAG = "NotificationGroupManager";
51     private final HashMap<String, NotificationGroup> mGroupMap = new HashMap<>();
52     private final ArraySet<OnGroupChangeListener> mListeners = new ArraySet<>();
53     private int mBarState = -1;
54     private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
55     private HeadsUpManager mHeadsUpManager;
56     private boolean mIsUpdatingUnchangedGroup;
57     @Nullable private BubbleController mBubbleController = null;
58 
59     @Inject
NotificationGroupManager(StatusBarStateController statusBarStateController)60     public NotificationGroupManager(StatusBarStateController statusBarStateController) {
61         statusBarStateController.addCallback(this);
62     }
63 
getBubbleController()64     private BubbleController getBubbleController() {
65         if (mBubbleController == null) {
66             mBubbleController = Dependency.get(BubbleController.class);
67         }
68         return mBubbleController;
69     }
70 
71     /**
72      * Add a listener for changes to groups.
73      *
74      * @param listener listener to add
75      */
addOnGroupChangeListener(OnGroupChangeListener listener)76     public void addOnGroupChangeListener(OnGroupChangeListener listener) {
77         mListeners.add(listener);
78     }
79 
isGroupExpanded(StatusBarNotification sbn)80     public boolean isGroupExpanded(StatusBarNotification sbn) {
81         NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
82         if (group == null) {
83             return false;
84         }
85         return group.expanded;
86     }
87 
setGroupExpanded(StatusBarNotification sbn, boolean expanded)88     public void setGroupExpanded(StatusBarNotification sbn, boolean expanded) {
89         NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
90         if (group == null) {
91             return;
92         }
93         setGroupExpanded(group, expanded);
94     }
95 
setGroupExpanded(NotificationGroup group, boolean expanded)96     private void setGroupExpanded(NotificationGroup group, boolean expanded) {
97         group.expanded = expanded;
98         if (group.summary != null) {
99             for (OnGroupChangeListener listener : mListeners) {
100                 listener.onGroupExpansionChanged(group.summary.getRow(), expanded);
101             }
102         }
103     }
104 
onEntryRemoved(NotificationEntry removed)105     public void onEntryRemoved(NotificationEntry removed) {
106         onEntryRemovedInternal(removed, removed.notification);
107         mIsolatedEntries.remove(removed.key);
108     }
109 
110     /**
111      * An entry was removed.
112      *
113      * @param removed the removed entry
114      * @param sbn the notification the entry has, which doesn't need to be the same as it's internal
115      *            notification
116      */
onEntryRemovedInternal(NotificationEntry removed, final StatusBarNotification sbn)117     private void onEntryRemovedInternal(NotificationEntry removed,
118             final StatusBarNotification sbn) {
119         String groupKey = getGroupKey(sbn);
120         final NotificationGroup group = mGroupMap.get(groupKey);
121         if (group == null) {
122             // When an app posts 2 different notifications as summary of the same group, then a
123             // cancellation of the first notification removes this group.
124             // This situation is not supported and we will not allow such notifications anymore in
125             // the close future. See b/23676310 for reference.
126             return;
127         }
128         if (isGroupChild(sbn)) {
129             group.children.remove(removed.key);
130         } else {
131             group.summary = null;
132         }
133         updateSuppression(group);
134         if (group.children.isEmpty()) {
135             if (group.summary == null) {
136                 mGroupMap.remove(groupKey);
137                 for (OnGroupChangeListener listener : mListeners) {
138                     listener.onGroupRemoved(group, groupKey);
139                 }
140             }
141         }
142     }
143 
onEntryAdded(final NotificationEntry added)144     public void onEntryAdded(final NotificationEntry added) {
145         if (added.isRowRemoved()) {
146             added.setDebugThrowable(new Throwable());
147         }
148         final StatusBarNotification sbn = added.notification;
149         boolean isGroupChild = isGroupChild(sbn);
150         String groupKey = getGroupKey(sbn);
151         NotificationGroup group = mGroupMap.get(groupKey);
152         if (group == null) {
153             group = new NotificationGroup();
154             mGroupMap.put(groupKey, group);
155             for (OnGroupChangeListener listener : mListeners) {
156                 listener.onGroupCreated(group, groupKey);
157             }
158         }
159         if (isGroupChild) {
160             NotificationEntry existing = group.children.get(added.key);
161             if (existing != null && existing != added) {
162                 Throwable existingThrowable = existing.getDebugThrowable();
163                 Log.wtf(TAG, "Inconsistent entries found with the same key " + added.key
164                         + "existing removed: " + existing.isRowRemoved()
165                         + (existingThrowable != null
166                                 ? Log.getStackTraceString(existingThrowable) + "\n": "")
167                         + " added removed" + added.isRowRemoved()
168                         , new Throwable());
169             }
170             group.children.put(added.key, added);
171             updateSuppression(group);
172         } else {
173             group.summary = added;
174             group.expanded = added.areChildrenExpanded();
175             updateSuppression(group);
176             if (!group.children.isEmpty()) {
177                 ArrayList<NotificationEntry> childrenCopy
178                         = new ArrayList<>(group.children.values());
179                 for (NotificationEntry child : childrenCopy) {
180                     onEntryBecomingChild(child);
181                 }
182                 for (OnGroupChangeListener listener : mListeners) {
183                     listener.onGroupCreatedFromChildren(group);
184                 }
185             }
186         }
187     }
188 
onEntryBecomingChild(NotificationEntry entry)189     private void onEntryBecomingChild(NotificationEntry entry) {
190         if (shouldIsolate(entry)) {
191             isolateNotification(entry);
192         }
193     }
194 
updateSuppression(NotificationGroup group)195     private void updateSuppression(NotificationGroup group) {
196         if (group == null) {
197             return;
198         }
199         int childCount = 0;
200         boolean hasBubbles = false;
201         for (String key : group.children.keySet()) {
202             if (!getBubbleController().isBubbleNotificationSuppressedFromShade(key)) {
203                 childCount++;
204             } else {
205                 hasBubbles = true;
206             }
207         }
208 
209         boolean prevSuppressed = group.suppressed;
210         group.suppressed = group.summary != null && !group.expanded
211                 && (childCount == 1
212                 || (childCount == 0
213                         && group.summary.notification.getNotification().isGroupSummary()
214                         && (hasIsolatedChildren(group) || hasBubbles)));
215         if (prevSuppressed != group.suppressed) {
216             for (OnGroupChangeListener listener : mListeners) {
217                 if (!mIsUpdatingUnchangedGroup) {
218                     listener.onGroupSuppressionChanged(group, group.suppressed);
219                     listener.onGroupsChanged();
220                 }
221             }
222         }
223     }
224 
hasIsolatedChildren(NotificationGroup group)225     private boolean hasIsolatedChildren(NotificationGroup group) {
226         return getNumberOfIsolatedChildren(group.summary.notification.getGroupKey()) != 0;
227     }
228 
getNumberOfIsolatedChildren(String groupKey)229     private int getNumberOfIsolatedChildren(String groupKey) {
230         int count = 0;
231         for (StatusBarNotification sbn : mIsolatedEntries.values()) {
232             if (sbn.getGroupKey().equals(groupKey) && isIsolated(sbn)) {
233                 count++;
234             }
235         }
236         return count;
237     }
238 
getIsolatedChild(String groupKey)239     private NotificationEntry getIsolatedChild(String groupKey) {
240         for (StatusBarNotification sbn : mIsolatedEntries.values()) {
241             if (sbn.getGroupKey().equals(groupKey) && isIsolated(sbn)) {
242                 return mGroupMap.get(sbn.getKey()).summary;
243             }
244         }
245         return null;
246     }
247 
onEntryUpdated(NotificationEntry entry, StatusBarNotification oldNotification)248     public void onEntryUpdated(NotificationEntry entry,
249             StatusBarNotification oldNotification) {
250         String oldKey = oldNotification.getGroupKey();
251         String newKey = entry.notification.getGroupKey();
252         boolean groupKeysChanged = !oldKey.equals(newKey);
253         boolean wasGroupChild = isGroupChild(oldNotification);
254         boolean isGroupChild = isGroupChild(entry.notification);
255         mIsUpdatingUnchangedGroup = !groupKeysChanged && wasGroupChild == isGroupChild;
256         if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
257             onEntryRemovedInternal(entry, oldNotification);
258         }
259         onEntryAdded(entry);
260         mIsUpdatingUnchangedGroup = false;
261         if (isIsolated(entry.notification)) {
262             mIsolatedEntries.put(entry.key, entry.notification);
263             if (groupKeysChanged) {
264                 updateSuppression(mGroupMap.get(oldKey));
265                 updateSuppression(mGroupMap.get(newKey));
266             }
267         } else if (!wasGroupChild && isGroupChild) {
268             onEntryBecomingChild(entry);
269         }
270     }
271 
isSummaryOfSuppressedGroup(StatusBarNotification sbn)272     public boolean isSummaryOfSuppressedGroup(StatusBarNotification sbn) {
273         return isGroupSuppressed(getGroupKey(sbn)) && sbn.getNotification().isGroupSummary();
274     }
275 
isOnlyChild(StatusBarNotification sbn)276     private boolean isOnlyChild(StatusBarNotification sbn) {
277         return !sbn.getNotification().isGroupSummary()
278                 && getTotalNumberOfChildren(sbn) == 1;
279     }
280 
isOnlyChildInGroup(StatusBarNotification sbn)281     public boolean isOnlyChildInGroup(StatusBarNotification sbn) {
282         if (!isOnlyChild(sbn)) {
283             return false;
284         }
285         NotificationEntry logicalGroupSummary = getLogicalGroupSummary(sbn);
286         return logicalGroupSummary != null
287                 && !logicalGroupSummary.notification.equals(sbn);
288     }
289 
getTotalNumberOfChildren(StatusBarNotification sbn)290     private int getTotalNumberOfChildren(StatusBarNotification sbn) {
291         int isolatedChildren = getNumberOfIsolatedChildren(sbn.getGroupKey());
292         NotificationGroup group = mGroupMap.get(sbn.getGroupKey());
293         int realChildren = group != null ? group.children.size() : 0;
294         return isolatedChildren + realChildren;
295     }
296 
isGroupSuppressed(String groupKey)297     private boolean isGroupSuppressed(String groupKey) {
298         NotificationGroup group = mGroupMap.get(groupKey);
299         return group != null && group.suppressed;
300     }
301 
setStatusBarState(int newState)302     private void setStatusBarState(int newState) {
303         mBarState = newState;
304         if (mBarState == StatusBarState.KEYGUARD) {
305             collapseAllGroups();
306         }
307     }
308 
collapseAllGroups()309     public void collapseAllGroups() {
310         // Because notifications can become isolated when the group becomes suppressed it can
311         // lead to concurrent modifications while looping. We need to make a copy.
312         ArrayList<NotificationGroup> groupCopy = new ArrayList<>(mGroupMap.values());
313         int size = groupCopy.size();
314         for (int i = 0; i < size; i++) {
315             NotificationGroup group =  groupCopy.get(i);
316             if (group.expanded) {
317                 setGroupExpanded(group, false);
318             }
319             updateSuppression(group);
320         }
321     }
322 
323     /**
324      * @return whether a given notification is a child in a group which has a summary
325      */
isChildInGroupWithSummary(StatusBarNotification sbn)326     public boolean isChildInGroupWithSummary(StatusBarNotification sbn) {
327         if (!isGroupChild(sbn)) {
328             return false;
329         }
330         NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
331         if (group == null || group.summary == null || group.suppressed) {
332             return false;
333         }
334         if (group.children.isEmpty()) {
335             // If the suppression of a group changes because the last child was removed, this can
336             // still be called temporarily because the child hasn't been fully removed yet. Let's
337             // make sure we still return false in that case.
338             return false;
339         }
340         return true;
341     }
342 
343     /**
344      * @return whether a given notification is a summary in a group which has children
345      */
isSummaryOfGroup(StatusBarNotification sbn)346     public boolean isSummaryOfGroup(StatusBarNotification sbn) {
347         if (!isGroupSummary(sbn)) {
348             return false;
349         }
350         NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
351         if (group == null || group.summary == null) {
352             return false;
353         }
354         return !group.children.isEmpty() && Objects.equals(group.summary.notification, sbn);
355     }
356 
357     /**
358      * Get the summary of a specified status bar notification. For isolated notification this return
359      * itself.
360      */
getGroupSummary(StatusBarNotification sbn)361     public NotificationEntry getGroupSummary(StatusBarNotification sbn) {
362         return getGroupSummary(getGroupKey(sbn));
363     }
364 
365     /**
366      * Similar to {@link #getGroupSummary(StatusBarNotification)} but doesn't get the visual summary
367      * but the logical summary, i.e when a child is isolated, it still returns the summary as if
368      * it wasn't isolated.
369      */
getLogicalGroupSummary(StatusBarNotification sbn)370     public NotificationEntry getLogicalGroupSummary(StatusBarNotification sbn) {
371         return getGroupSummary(sbn.getGroupKey());
372     }
373 
374     @Nullable
getGroupSummary(String groupKey)375     private NotificationEntry getGroupSummary(String groupKey) {
376         NotificationGroup group = mGroupMap.get(groupKey);
377         //TODO: see if this can become an Entry
378         return group == null ? null
379                 : group.summary == null ? null
380                         : group.summary;
381     }
382 
383     /**
384      * Get the children that are logically in the summary's group, whether or not they are isolated.
385      *
386      * @param summary summary of a group
387      * @return list of the children
388      */
getLogicalChildren(StatusBarNotification summary)389     public ArrayList<NotificationEntry> getLogicalChildren(StatusBarNotification summary) {
390         NotificationGroup group = mGroupMap.get(summary.getGroupKey());
391         if (group == null) {
392             return null;
393         }
394         ArrayList<NotificationEntry> children = new ArrayList<>(group.children.values());
395         NotificationEntry isolatedChild = getIsolatedChild(summary.getGroupKey());
396         if (isolatedChild != null) {
397             children.add(isolatedChild);
398         }
399         return children;
400     }
401 
402     /**
403      * If there is a {@link NotificationGroup} associated with the provided entry, this method
404      * will update the suppression of that group.
405      */
updateSuppression(NotificationEntry entry)406     public void updateSuppression(NotificationEntry entry) {
407         NotificationGroup group = mGroupMap.get(getGroupKey(entry.notification));
408         if (group != null) {
409             updateSuppression(group);
410         }
411     }
412 
413     /**
414      * Get the group key. May differ from the one in the notification due to the notification
415      * being temporarily isolated.
416      *
417      * @param sbn notification to check
418      * @return the key of the notification
419      */
getGroupKey(StatusBarNotification sbn)420     public String getGroupKey(StatusBarNotification sbn) {
421         if (isIsolated(sbn)) {
422             return sbn.getKey();
423         }
424         return sbn.getGroupKey();
425     }
426 
427     /** @return group expansion state after toggling. */
toggleGroupExpansion(StatusBarNotification sbn)428     public boolean toggleGroupExpansion(StatusBarNotification sbn) {
429         NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
430         if (group == null) {
431             return false;
432         }
433         setGroupExpanded(group, !group.expanded);
434         return group.expanded;
435     }
436 
isIsolated(StatusBarNotification sbn)437     private boolean isIsolated(StatusBarNotification sbn) {
438         return mIsolatedEntries.containsKey(sbn.getKey());
439     }
440 
441     /**
442      * Whether a notification is visually a group summary.
443      *
444      * @param sbn notification to check
445      * @return true if it is visually a group summary
446      */
isGroupSummary(StatusBarNotification sbn)447     public boolean isGroupSummary(StatusBarNotification sbn) {
448         if (isIsolated(sbn)) {
449             return true;
450         }
451         return sbn.getNotification().isGroupSummary();
452     }
453 
454     /**
455      * Whether a notification is visually a group child.
456      *
457      * @param sbn notification to check
458      * @return true if it is visually a group child
459      */
isGroupChild(StatusBarNotification sbn)460     public boolean isGroupChild(StatusBarNotification sbn) {
461         if (isIsolated(sbn)) {
462             return false;
463         }
464         return sbn.isGroup() && !sbn.getNotification().isGroupSummary();
465     }
466 
467     @Override
onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp)468     public void onHeadsUpStateChanged(NotificationEntry entry, boolean isHeadsUp) {
469         onAlertStateChanged(entry, isHeadsUp);
470     }
471 
onAlertStateChanged(NotificationEntry entry, boolean isAlerting)472     private void onAlertStateChanged(NotificationEntry entry, boolean isAlerting) {
473         if (isAlerting) {
474             if (shouldIsolate(entry)) {
475                 isolateNotification(entry);
476             }
477         } else {
478             stopIsolatingNotification(entry);
479         }
480     }
481 
482     /**
483      * Whether a notification that is normally part of a group should be temporarily isolated from
484      * the group and put in their own group visually.  This generally happens when the notification
485      * is alerting.
486      *
487      * @param entry the notification to check
488      * @return true if the entry should be isolated
489      */
490 
shouldIsolate(NotificationEntry entry)491     private boolean shouldIsolate(NotificationEntry entry) {
492         StatusBarNotification sbn = entry.notification;
493         NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
494         if (!sbn.isGroup() || sbn.getNotification().isGroupSummary()) {
495             return false;
496         }
497         if (!mHeadsUpManager.isAlerting(entry.key)) {
498             return false;
499         }
500         return (sbn.getNotification().fullScreenIntent != null
501                     || notificationGroup == null
502                     || !notificationGroup.expanded
503                     || isGroupNotFullyVisible(notificationGroup));
504     }
505 
506     /**
507      * Isolate a notification from its group so that it visually shows as its own group.
508      *
509      * @param entry the notification to isolate
510      */
isolateNotification(NotificationEntry entry)511     private void isolateNotification(NotificationEntry entry) {
512         StatusBarNotification sbn = entry.notification;
513 
514         // We will be isolated now, so lets update the groups
515         onEntryRemovedInternal(entry, entry.notification);
516 
517         mIsolatedEntries.put(sbn.getKey(), sbn);
518 
519         onEntryAdded(entry);
520         // We also need to update the suppression of the old group, because this call comes
521         // even before the groupManager knows about the notification at all.
522         // When the notification gets added afterwards it is already isolated and therefore
523         // it doesn't lead to an update.
524         updateSuppression(mGroupMap.get(entry.notification.getGroupKey()));
525         for (OnGroupChangeListener listener : mListeners) {
526             listener.onGroupsChanged();
527         }
528     }
529 
530     /**
531      * Stop isolating a notification and re-group it with its original logical group.
532      *
533      * @param entry the notification to un-isolate
534      */
stopIsolatingNotification(NotificationEntry entry)535     private void stopIsolatingNotification(NotificationEntry entry) {
536         StatusBarNotification sbn = entry.notification;
537         if (mIsolatedEntries.containsKey(sbn.getKey())) {
538             // not isolated anymore, we need to update the groups
539             onEntryRemovedInternal(entry, entry.notification);
540             mIsolatedEntries.remove(sbn.getKey());
541             onEntryAdded(entry);
542             for (OnGroupChangeListener listener : mListeners) {
543                 listener.onGroupsChanged();
544             }
545         }
546     }
547 
isGroupNotFullyVisible(NotificationGroup notificationGroup)548     private boolean isGroupNotFullyVisible(NotificationGroup notificationGroup) {
549         return notificationGroup.summary == null
550                 || notificationGroup.summary.isGroupNotFullyVisible();
551     }
552 
setHeadsUpManager(HeadsUpManager headsUpManager)553     public void setHeadsUpManager(HeadsUpManager headsUpManager) {
554         mHeadsUpManager = headsUpManager;
555     }
556 
dump(FileDescriptor fd, PrintWriter pw, String[] args)557     public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
558         pw.println("GroupManager state:");
559         pw.println("  number of groups: " +  mGroupMap.size());
560         for (Map.Entry<String, NotificationGroup>  entry : mGroupMap.entrySet()) {
561             pw.println("\n    key: " + entry.getKey()); pw.println(entry.getValue());
562         }
563         pw.println("\n    isolated entries: " +  mIsolatedEntries.size());
564         for (Map.Entry<String, StatusBarNotification> entry : mIsolatedEntries.entrySet()) {
565             pw.print("      "); pw.print(entry.getKey());
566             pw.print(", "); pw.println(entry.getValue());
567         }
568     }
569 
570     @Override
onStateChanged(int newState)571     public void onStateChanged(int newState) {
572         setStatusBarState(newState);
573     }
574 
575     public static class NotificationGroup {
576         public final HashMap<String, NotificationEntry> children = new HashMap<>();
577         public NotificationEntry summary;
578         public boolean expanded;
579         /**
580          * Is this notification group suppressed, i.e its summary is hidden
581          */
582         public boolean suppressed;
583 
584         @Override
toString()585         public String toString() {
586             String result = "    summary:\n      "
587                     + (summary != null ? summary.notification : "null")
588                     + (summary != null && summary.getDebugThrowable() != null
589                             ? Log.getStackTraceString(summary.getDebugThrowable())
590                             : "");
591             result += "\n    children size: " + children.size();
592             for (NotificationEntry child : children.values()) {
593                 result += "\n      " + child.notification
594                 + (child.getDebugThrowable() != null
595                         ? Log.getStackTraceString(child.getDebugThrowable())
596                         : "");
597             }
598             result += "\n    summary suppressed: " + suppressed;
599             return result;
600         }
601     }
602 
603     public interface OnGroupChangeListener {
604 
605         /**
606          * A new group has been created.
607          *
608          * @param group the group that was created
609          * @param groupKey the group's key
610          */
onGroupCreated(NotificationGroup group, String groupKey)611         default void onGroupCreated(NotificationGroup group, String groupKey) {}
612 
613         /**
614          * A group has been removed.
615          *
616          * @param group the group that was removed
617          * @param groupKey the group's key
618          */
onGroupRemoved(NotificationGroup group, String groupKey)619         default void onGroupRemoved(NotificationGroup group, String groupKey) {}
620 
621         /**
622          * The suppression of a group has changed.
623          *
624          * @param group the group that has changed
625          * @param suppressed true if the group is now suppressed, false o/w
626          */
onGroupSuppressionChanged(NotificationGroup group, boolean suppressed)627         default void onGroupSuppressionChanged(NotificationGroup group, boolean suppressed) {}
628 
629         /**
630          * The expansion of a group has changed.
631          *
632          * @param changedRow the row for which the expansion has changed, which is also the summary
633          * @param expanded a boolean indicating the new expanded state
634          */
onGroupExpansionChanged(ExpandableNotificationRow changedRow, boolean expanded)635         default void onGroupExpansionChanged(ExpandableNotificationRow changedRow,
636                 boolean expanded) {}
637 
638         /**
639          * A group of children just received a summary notification and should therefore become
640          * children of it.
641          *
642          * @param group the group created
643          */
onGroupCreatedFromChildren(NotificationGroup group)644         default void onGroupCreatedFromChildren(NotificationGroup group) {}
645 
646         /**
647          * The groups have changed. This can happen if the isolation of a child has changes or if a
648          * group became suppressed / unsuppressed
649          */
onGroupsChanged()650         default void onGroupsChanged() {}
651     }
652 }
653