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

Commit 9bd3b87d authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Crash fix: Log instead of crashing when moving child notif within group.

Fixes: 213038631
Test: manual dismissing; adding to groups; getting groups to reorder
Depends-On: Iedad4a54fc44e9ff900357b3486cc62516701c45
Change-Id: Ic018d949e09ff41f8d7644fda2d6d4321c64199e
parent 0eebf348
Loading
Loading
Loading
Loading
+15 −24
Original line number Diff line number Diff line
@@ -550,41 +550,32 @@ public abstract class ExpandableView extends FrameLayout implements Dumpable {
    public void removeFromTransientContainerForAdditionTo(ViewGroup newParent) {
        final ViewParent parent = getParent();
        final ViewGroup transientContainer = getTransientContainer();
        if (parent == null) {
            // If this view has no parent, the add will succeed, so just make sure the tracked
            // transient container is in sync with the lack of a parent.
            if (transientContainer != null) {
        if (parent == null || parent == newParent) {
            // If this view's current parent is null or the same as the new parent, the add will
            // succeed, so just make sure the tracked transient container is in sync with the
            // current parent.
            if (transientContainer != null && transientContainer != parent) {
                Log.w(TAG, "Expandable view " + this
                        + " has transient container " + transientContainer
                        + " but no parent");
                        + " but different parent" + parent);
                setTransientContainer(null);
            }
            return;
        }
        if (transientContainer == null) {
            throw new IllegalStateException(
                    "Can't add view " + this + " to container " + newParent + "; current parent "
                            + parent + " is not a transient container");
            throw new IllegalStateException("Can't add view " + this + " to container " + newParent
                    + "; current parent " + parent + " is not a transient container");
        }
        if (transientContainer != parent) {
            String transientContainerOutOfSyncError = "Expandable view " + this
                    + " has transient container " + transientContainer
                    + " but different parent " + parent;
            if (parent != newParent) {
            // Crash with details before addView() crashes without any; the view is being added
            // to a different parent, and the transient container isn't the parent, so we can't
            // even (safely) clean that up.
                throw new IllegalStateException(transientContainerOutOfSyncError);
            } else {
                Log.w(TAG, transientContainerOutOfSyncError);
                setTransientContainer(null);
                return;
            }
        }
        if (parent != newParent) {
            Log.w(TAG, "Moving view " + this + " from transient container "
                    + transientContainer + " to parent " + newParent);
            throw new IllegalStateException("Expandable view " + this
                    + " has transient container " + transientContainer
                    + " but different parent " + parent);
        }
        Log.w(TAG, "Removing view " + this + " from transient container "
                + transientContainer + " in preparation for moving to parent " + newParent);
        transientContainer.removeTransientView(this);
        setTransientContainer(null);
    }