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

Commit 322ec7e2 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixed a crash with notification children

When moving children between parents, Sysui could crash
because it wasn't removed yet properly from the old parent.
We are now doing this sequencially, i.e first removing the
children and then adding the new ones.

Bug: 27137301
Change-Id: I1925662a9d7f224f133827d524d080994753ba25
parent d3107e88
Loading
Loading
Loading
Loading
+15 −3
Original line number Original line Diff line number Diff line
@@ -1500,8 +1500,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    }
    }


    private void updateNotificationShadeForChildren() {
    private void updateNotificationShadeForChildren() {
        // First let's remove all children which don't belong in the parents
        ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>();
        ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>();
        boolean orderChanged = false;
        for (int i = 0; i < mStackScroller.getChildCount(); i++) {
        for (int i = 0; i < mStackScroller.getChildCount(); i++) {
            View view = mStackScroller.getChildAt(i);
            View view = mStackScroller.getChildAt(i);
            if (!(view instanceof ExpandableNotificationRow)) {
            if (!(view instanceof ExpandableNotificationRow)) {
@@ -1513,7 +1513,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            List<ExpandableNotificationRow> children = parent.getNotificationChildren();
            List<ExpandableNotificationRow> children = parent.getNotificationChildren();
            List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent);
            List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent);


            // lets first remove all undesired children
            if (children != null) {
            if (children != null) {
                toRemove.clear();
                toRemove.clear();
                for (ExpandableNotificationRow childRow : children) {
                for (ExpandableNotificationRow childRow : children) {
@@ -1526,8 +1525,21 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                    mStackScroller.notifyGroupChildRemoved(remove);
                    mStackScroller.notifyGroupChildRemoved(remove);
                }
                }
            }
            }
        }

        // Let's now add all notification children which are missing
        boolean orderChanged = false;
        for (int i = 0; i < mStackScroller.getChildCount(); i++) {
            View view = mStackScroller.getChildAt(i);
            if (!(view instanceof ExpandableNotificationRow)) {
                // We don't care about non-notification views.
                continue;
            }

            ExpandableNotificationRow parent = (ExpandableNotificationRow) view;
            List<ExpandableNotificationRow> children = parent.getNotificationChildren();
            List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(parent);


            // We now add all the children which are not in there already
            for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size();
            for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size();
                    childIndex++) {
                    childIndex++) {
                ExpandableNotificationRow childView = orderedChildren.get(childIndex);
                ExpandableNotificationRow childView = orderedChildren.get(childIndex);