Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c1ffcc1 authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge "Don't promote summaries in bundles due to vis stability" into main

parents fd4c1498 b3673ee6
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
@@ -1152,9 +1152,9 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
     * Collect the keys of any groups which have already lost a child to stability this run.
     *
     * If stability is being enforced, then {@link #stabilizeGroupingNotifs(List)} might have
     * detached some children from their groups and left them at the top level because the child was
     * previously attached at the top level.  Doing so would set the
     * {@link SuppressedAttachState#getParent() suppressed parent} for the current attach state.
     * detached some children from their groups and left them with their previous parent. Doing so
     * would set the {@link SuppressedAttachState#getParent() suppressed parent} for the current
     * attach state.
     *
     * If we've already removed a child from this group, we don't want to remove any more children
     * from the group (even if that would leave only a single notification in the group) because
@@ -1169,16 +1169,32 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
        ArraySet<String> groupsWithChildrenLostToStability = new ArraySet<>();
        for (int i = 0; i < shadeList.size(); i++) {
            final PipelineEntry tle = shadeList.get(i);
            addGroupsWithChildrenLostToStability(tle, groupsWithChildrenLostToStability);
        }
        return groupsWithChildrenLostToStability;
    }

    private void addGroupsWithChildrenLostToStability(PipelineEntry entry, Set<String> out) {
        if (entry instanceof BundleEntry be) {
            final List<ListEntry> children = be.getChildren();
            for (int i = 0; i < children.size(); i++) {
                final ListEntry child = children.get(i);
                addGroupsWithChildrenLostToStability(child, out);
            }
        } else if (entry instanceof ListEntry le) {
            addGroupsWithChildrenLostToStability(le, out);
        }
    }

    private void addGroupsWithChildrenLostToStability(ListEntry entry, Set<String> out) {
        final PipelineEntry suppressedParent =
                    tle.getAttachState().getSuppressedChanges().getParent();
                entry.getAttachState().getSuppressedChanges().getParent();
        if (suppressedParent != null) {
                // This top-level-entry was supposed to be attached to this group,
                //  so mark the group as having lost a child to stability.
                groupsWithChildrenLostToStability.add(suppressedParent.getKey());
            // This ListEntry was supposed to be attached to this group, so mark the group as
            // having lost a child to stability.
            out.add(suppressedParent.getKey());
        }
    }
        return groupsWithChildrenLostToStability;
    }

    /**
     * Collect the keys of any groups which have already lost a child to a {@link NotifPromoter}