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

Commit d9b7514a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Don't suppress group change after summary removed" into tm-dev am: c5b61d93

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17325452

Change-Id: If5082938a14d7eab8193c9fded209e710c29850d
parents 412104ef c5b61d93
Loading
Loading
Loading
Loading
+18 −9
Original line number Original line Diff line number Diff line
@@ -641,28 +641,37 @@ public class ShadeListBuilder implements Dumpable {
     * Returns true if the group change was suppressed, else false
     * Returns true if the group change was suppressed, else false
     */
     */
    private boolean maybeSuppressGroupChange(NotificationEntry entry, List<ListEntry> out) {
    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 prevParent = entry.getPreviousAttachState().getParent();
        if (prevParent == null) {
            // New entries are always allowed.
            return false;
        }
        final GroupEntry assignedParent = entry.getParent();
        final GroupEntry assignedParent = entry.getParent();
        if (prevParent != assignedParent
        if (prevParent == assignedParent) {
                && !getStabilityManager().isGroupChangeAllowed(entry.getRepresentativeEntry())) {
            // Nothing to change.
            return false;
        }
        if (prevParent != ROOT_ENTRY && prevParent.getParent() == null) {
            // Previous parent was a group, which has been removed (hence, its parent is null).
            // Always allow this group change, otherwise the child will remain attached to the
            // removed group and be removed from the shade until visual stability ends.
            return false;
        }
        // TODO: Rather than perform "half" of the move here and require the caller remove the child
        //  from the assignedParent, ideally we would have an atomic "move" operation.
        if (!getStabilityManager().isGroupChangeAllowed(entry.getRepresentativeEntry())) {
            entry.getAttachState().getSuppressedChanges().setParent(assignedParent);
            entry.getAttachState().getSuppressedChanges().setParent(assignedParent);
            entry.setParent(prevParent);
            entry.setParent(prevParent);
            if (prevParent == ROOT_ENTRY) {
            if (prevParent == ROOT_ENTRY) {
                out.add(entry);
                out.add(entry);
            } else if (prevParent != null) {
            } else {
                prevParent.addChild(entry);
                prevParent.addChild(entry);
                if (!mGroups.containsKey(prevParent.getKey())) {
                if (!mGroups.containsKey(prevParent.getKey())) {
                    mGroups.put(prevParent.getKey(), prevParent);
                    mGroups.put(prevParent.getKey(), prevParent);
                }
                }
            }
            }

            return true;
            return true;
        }
        }

        return false;
        return false;
    }
    }


+23 −0
Original line number Original line Diff line number Diff line
@@ -1172,6 +1172,29 @@ public class ShadeListBuilderTest extends SysuiTestCase {
        ).inOrder(); // Order is a bonus because this listener is before sort
        ).inOrder(); // Order is a bonus because this listener is before sort
    }
    }


    @Test
    public void testStabilizeGroupsAlwaysAllowsGroupChangeFromDeletedGroupToRoot() {
        // GIVEN a group w/ summary and two children
        addGroupSummary(0, PACKAGE_1, GROUP_1);
        addGroupChild(1, PACKAGE_1, GROUP_1);
        addGroupChild(2, PACKAGE_1, GROUP_1);
        dispatchBuild();

        // GIVEN visual stability manager doesn't allow any group changes
        mStabilityManager.setAllowGroupChanges(false);

        // WHEN we run the pipeline with the summary and one child removed
        mEntrySet.remove(2);
        mEntrySet.remove(0);
        dispatchBuild();

        // THEN all that remains is the one child at top-level, despite no group change allowed by
        // visual stability manager.
        verifyBuiltList(
                notif(0)
        );
    }

    @Test
    @Test
    public void testStabilizeGroupsDoesNotAllowGroupingExistingNotifications() {
    public void testStabilizeGroupsDoesNotAllowGroupingExistingNotifications() {
        // GIVEN one group child without a summary yet
        // GIVEN one group child without a summary yet