Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java +7 −0 Original line number Diff line number Diff line Loading @@ -110,4 +110,11 @@ public abstract class ListEntry { mPreviousAttachState.clone(mAttachState); mAttachState.reset(); } /** * True if this entry was attached in the last pass, else false. */ public boolean wasAttachedInPreviousPass() { return getPreviousAttachState().getParent() != null; } } packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +68 −13 Original line number Diff line number Diff line Loading @@ -513,26 +513,64 @@ public class ShadeListBuilder implements Dumpable { } } private void stabilizeGroupingNotifs(List<ListEntry> list) { private void stabilizeGroupingNotifs(List<ListEntry> topLevelList) { if (mNotifStabilityManager == null) { return; } for (int i = 0; i < list.size(); i++) { final ListEntry tle = list.get(i); if (tle.getPreviousAttachState().getParent() == null) { continue; // new entries are allowed for (int i = 0; i < topLevelList.size(); i++) { final ListEntry tle = topLevelList.get(i); if (tle instanceof GroupEntry) { // maybe put children back into their old group (including moving back to top-level) GroupEntry groupEntry = (GroupEntry) tle; List<NotificationEntry> children = groupEntry.getRawChildren(); for (int j = 0; j < groupEntry.getChildren().size(); j++) { if (maybeSuppressGroupChange(children.get(j), topLevelList)) { // child was put back into its previous group, so we remove it from this // group children.remove(j); j--; } } } else { // maybe put top-level-entries back into their previous groups if (maybeSuppressGroupChange(tle.getRepresentativeEntry(), topLevelList)) { // entry was put back into its previous group, so we remove it from the list of // top-level-entries topLevelList.remove(i); i--; } } } } final GroupEntry prevParent = tle.getPreviousAttachState().getParent(); final GroupEntry assignedParent = tle.getParent(); if (prevParent != assignedParent) { if (!mNotifStabilityManager.isGroupChangeAllowed(tle.getRepresentativeEntry())) { tle.getAttachState().getSuppressedChanges().setParent(assignedParent); tle.setParent(prevParent); /** * Returns true if the group change was suppressed, else false */ private boolean maybeSuppressGroupChange(NotificationEntry entry, List<ListEntry> out) { if (!entry.wasAttachedInPreviousPass()) { return false; // new entries are allowed } final GroupEntry prevParent = entry.getPreviousAttachState().getParent(); final GroupEntry assignedParent = entry.getParent(); if (prevParent != assignedParent && !mNotifStabilityManager.isGroupChangeAllowed(entry.getRepresentativeEntry())) { entry.getAttachState().getSuppressedChanges().setParent(assignedParent); entry.setParent(prevParent); if (prevParent == ROOT_ENTRY) { out.add(entry); } else if (prevParent != null) { prevParent.addChild(entry); if (!mGroups.containsKey(prevParent.getKey())) { mGroups.put(prevParent.getKey(), prevParent); } } return true; } return false; } private void promoteNotifs(List<ListEntry> list) { Loading Loading @@ -577,6 +615,17 @@ public class ShadeListBuilder implements Dumpable { } else if (group.getSummary() == null || children.size() < MIN_CHILDREN_FOR_GROUP) { if (group.getSummary() != null && group.wasAttachedInPreviousPass() && mNotifStabilityManager != null && !mNotifStabilityManager.isGroupChangeAllowed(group.getSummary())) { // if this group was previously attached and group changes aren't // allowed, keep it around until group changes are allowed again group.getAttachState().getSuppressedChanges().setWasPruneSuppressed(true); continue; } // If the group doesn't provide a summary or is too small, ignore it and add // its children (if any) directly to top-level. Loading Loading @@ -718,6 +767,12 @@ public class ShadeListBuilder implements Dumpable { curr.getParent()); } if (curr.getSuppressedChanges().getWasPruneSuppressed()) { mLogger.logGroupPruningSuppressed( mIterationCount, curr.getParent()); } if (curr.getExcludingFilter() != prev.getExcludingFilter()) { mLogger.logFilterChanged( mIterationCount, Loading Loading @@ -867,9 +922,9 @@ public class ShadeListBuilder implements Dumpable { NotifSection finalSection = newSection; // are we changing sections of this entry? // have we seen this entry before and are we changing its section? if (mNotifStabilityManager != null && prevAttachState.getParent() != null && entry.wasAttachedInPreviousPass() && newSection != prevAttachState.getSection()) { // are section changes allowed? Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/SuppressedAttachState.kt +16 −6 Original line number Diff line number Diff line Loading @@ -24,28 +24,37 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.NotifS */ data class SuppressedAttachState private constructor( /** * Null if not attached to the current shade list. If top-level, then the shade list root. If * part of a group, then that group's GroupEntry. * The suppressed section assignment for this ListEntry. * Null if no section change was suppressed. */ var section: NotifSection?, /** * The suppressed parent assignment for this ListEntry. * - Null if no parent change was suppressed. * - Root if suppressing group change to top-level * - GroupEntry if suppressing group change to a different group */ var parent: GroupEntry?, /** * The assigned section for this ListEntry. If the child of the group, this will be the * parent's section. Null if not attached to the list. * Whether the ListEntry would have been pruned had its group change not been suppressed. */ var section: NotifSection? var wasPruneSuppressed: Boolean ) { /** Copies the state of another instance. */ fun clone(other: SuppressedAttachState) { parent = other.parent section = other.section wasPruneSuppressed = other.wasPruneSuppressed } /** Resets back to a "clean" state (the same as created by the factory method) */ fun reset() { parent = null section = null wasPruneSuppressed = false } companion object { Loading @@ -53,7 +62,8 @@ data class SuppressedAttachState private constructor( fun create(): SuppressedAttachState { return SuppressedAttachState( null, null) null, false) } } } packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java +1 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ public class VisualStabilityCoordinator implements Coordinator { public boolean isGroupChangeAllowed(NotificationEntry entry) { final boolean isGroupChangeAllowedForEntry = mReorderingAllowed || mHeadsUpManager.isAlerting(entry.getKey()); mIsSuppressingGroupChange |= isGroupChangeAllowedForEntry; mIsSuppressingGroupChange |= !isGroupChangeAllowedForEntry; return isGroupChangeAllowedForEntry; } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt +13 −2 Original line number Diff line number Diff line Loading @@ -174,8 +174,19 @@ class ShadeListBuilderLogger @Inject constructor( str1 = suppressedParent?.key str2 = keepingParent?.key }, { "(Build $long1) Change of parent to '$str1' suppressed; " + "keeping parent '$str2'" "(Build $long1) Change of parent to '$str1' suppressed; keeping parent '$str2'" }) } fun logGroupPruningSuppressed( buildId: Int, keepingParent: GroupEntry? ) { buffer.log(TAG, INFO, { int1 = buildId str1 = keepingParent?.key }, { "(Build $long1) Group pruning suppressed; keeping parent '$str1'" }) } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ListEntry.java +7 −0 Original line number Diff line number Diff line Loading @@ -110,4 +110,11 @@ public abstract class ListEntry { mPreviousAttachState.clone(mAttachState); mAttachState.reset(); } /** * True if this entry was attached in the last pass, else false. */ public boolean wasAttachedInPreviousPass() { return getPreviousAttachState().getParent() != null; } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/ShadeListBuilder.java +68 −13 Original line number Diff line number Diff line Loading @@ -513,26 +513,64 @@ public class ShadeListBuilder implements Dumpable { } } private void stabilizeGroupingNotifs(List<ListEntry> list) { private void stabilizeGroupingNotifs(List<ListEntry> topLevelList) { if (mNotifStabilityManager == null) { return; } for (int i = 0; i < list.size(); i++) { final ListEntry tle = list.get(i); if (tle.getPreviousAttachState().getParent() == null) { continue; // new entries are allowed for (int i = 0; i < topLevelList.size(); i++) { final ListEntry tle = topLevelList.get(i); if (tle instanceof GroupEntry) { // maybe put children back into their old group (including moving back to top-level) GroupEntry groupEntry = (GroupEntry) tle; List<NotificationEntry> children = groupEntry.getRawChildren(); for (int j = 0; j < groupEntry.getChildren().size(); j++) { if (maybeSuppressGroupChange(children.get(j), topLevelList)) { // child was put back into its previous group, so we remove it from this // group children.remove(j); j--; } } } else { // maybe put top-level-entries back into their previous groups if (maybeSuppressGroupChange(tle.getRepresentativeEntry(), topLevelList)) { // entry was put back into its previous group, so we remove it from the list of // top-level-entries topLevelList.remove(i); i--; } } } } final GroupEntry prevParent = tle.getPreviousAttachState().getParent(); final GroupEntry assignedParent = tle.getParent(); if (prevParent != assignedParent) { if (!mNotifStabilityManager.isGroupChangeAllowed(tle.getRepresentativeEntry())) { tle.getAttachState().getSuppressedChanges().setParent(assignedParent); tle.setParent(prevParent); /** * Returns true if the group change was suppressed, else false */ private boolean maybeSuppressGroupChange(NotificationEntry entry, List<ListEntry> out) { if (!entry.wasAttachedInPreviousPass()) { return false; // new entries are allowed } final GroupEntry prevParent = entry.getPreviousAttachState().getParent(); final GroupEntry assignedParent = entry.getParent(); if (prevParent != assignedParent && !mNotifStabilityManager.isGroupChangeAllowed(entry.getRepresentativeEntry())) { entry.getAttachState().getSuppressedChanges().setParent(assignedParent); entry.setParent(prevParent); if (prevParent == ROOT_ENTRY) { out.add(entry); } else if (prevParent != null) { prevParent.addChild(entry); if (!mGroups.containsKey(prevParent.getKey())) { mGroups.put(prevParent.getKey(), prevParent); } } return true; } return false; } private void promoteNotifs(List<ListEntry> list) { Loading Loading @@ -577,6 +615,17 @@ public class ShadeListBuilder implements Dumpable { } else if (group.getSummary() == null || children.size() < MIN_CHILDREN_FOR_GROUP) { if (group.getSummary() != null && group.wasAttachedInPreviousPass() && mNotifStabilityManager != null && !mNotifStabilityManager.isGroupChangeAllowed(group.getSummary())) { // if this group was previously attached and group changes aren't // allowed, keep it around until group changes are allowed again group.getAttachState().getSuppressedChanges().setWasPruneSuppressed(true); continue; } // If the group doesn't provide a summary or is too small, ignore it and add // its children (if any) directly to top-level. Loading Loading @@ -718,6 +767,12 @@ public class ShadeListBuilder implements Dumpable { curr.getParent()); } if (curr.getSuppressedChanges().getWasPruneSuppressed()) { mLogger.logGroupPruningSuppressed( mIterationCount, curr.getParent()); } if (curr.getExcludingFilter() != prev.getExcludingFilter()) { mLogger.logFilterChanged( mIterationCount, Loading Loading @@ -867,9 +922,9 @@ public class ShadeListBuilder implements Dumpable { NotifSection finalSection = newSection; // are we changing sections of this entry? // have we seen this entry before and are we changing its section? if (mNotifStabilityManager != null && prevAttachState.getParent() != null && entry.wasAttachedInPreviousPass() && newSection != prevAttachState.getSection()) { // are section changes allowed? Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/SuppressedAttachState.kt +16 −6 Original line number Diff line number Diff line Loading @@ -24,28 +24,37 @@ import com.android.systemui.statusbar.notification.collection.listbuilder.NotifS */ data class SuppressedAttachState private constructor( /** * Null if not attached to the current shade list. If top-level, then the shade list root. If * part of a group, then that group's GroupEntry. * The suppressed section assignment for this ListEntry. * Null if no section change was suppressed. */ var section: NotifSection?, /** * The suppressed parent assignment for this ListEntry. * - Null if no parent change was suppressed. * - Root if suppressing group change to top-level * - GroupEntry if suppressing group change to a different group */ var parent: GroupEntry?, /** * The assigned section for this ListEntry. If the child of the group, this will be the * parent's section. Null if not attached to the list. * Whether the ListEntry would have been pruned had its group change not been suppressed. */ var section: NotifSection? var wasPruneSuppressed: Boolean ) { /** Copies the state of another instance. */ fun clone(other: SuppressedAttachState) { parent = other.parent section = other.section wasPruneSuppressed = other.wasPruneSuppressed } /** Resets back to a "clean" state (the same as created by the factory method) */ fun reset() { parent = null section = null wasPruneSuppressed = false } companion object { Loading @@ -53,7 +62,8 @@ data class SuppressedAttachState private constructor( fun create(): SuppressedAttachState { return SuppressedAttachState( null, null) null, false) } } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java +1 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ public class VisualStabilityCoordinator implements Coordinator { public boolean isGroupChangeAllowed(NotificationEntry entry) { final boolean isGroupChangeAllowedForEntry = mReorderingAllowed || mHeadsUpManager.isAlerting(entry.getKey()); mIsSuppressingGroupChange |= isGroupChangeAllowedForEntry; mIsSuppressingGroupChange |= !isGroupChangeAllowedForEntry; return isGroupChangeAllowedForEntry; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/listbuilder/ShadeListBuilderLogger.kt +13 −2 Original line number Diff line number Diff line Loading @@ -174,8 +174,19 @@ class ShadeListBuilderLogger @Inject constructor( str1 = suppressedParent?.key str2 = keepingParent?.key }, { "(Build $long1) Change of parent to '$str1' suppressed; " + "keeping parent '$str2'" "(Build $long1) Change of parent to '$str1' suppressed; keeping parent '$str2'" }) } fun logGroupPruningSuppressed( buildId: Int, keepingParent: GroupEntry? ) { buffer.log(TAG, INFO, { int1 = buildId str1 = keepingParent?.key }, { "(Build $long1) Group pruning suppressed; keeping parent '$str1'" }) } Loading