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

Commit 9de4ef41 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: I0783ac8da2eaf4439b3aab7f0853cc444080d538
parents f34d0ec7 c5b61d93
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -641,28 +641,37 @@ public class ShadeListBuilder implements Dumpable {
     * 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();
        if (prevParent == null) {
            // New entries are always allowed.
            return false;
        }
        final GroupEntry assignedParent = entry.getParent();
        if (prevParent != assignedParent
                && !getStabilityManager().isGroupChangeAllowed(entry.getRepresentativeEntry())) {
        if (prevParent == assignedParent) {
            // 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.setParent(prevParent);
            if (prevParent == ROOT_ENTRY) {
                out.add(entry);
            } else if (prevParent != null) {
            } else {
                prevParent.addChild(entry);
                if (!mGroups.containsKey(prevParent.getKey())) {
                    mGroups.put(prevParent.getKey(), prevParent);
                }
            }

            return true;
        }

        return false;
    }

+23 −0
Original line number 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
    }

    @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
    public void testStabilizeGroupsDoesNotAllowGroupingExistingNotifications() {
        // GIVEN one group child without a summary yet