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

Commit 8e05aab5 authored by Joshua Tsuji's avatar Joshua Tsuji
Browse files

Protect against NaN in flyout collapses.

This can happen if getWidth() returns 0, likely the result of a race condition. Since
setFlyoutCollapsed is called continuously as a flyout is dragged, we can just wait
until getWidth() > 0.

Bug: 139816141
Test: atest SystemUITests
Change-Id: I2e7b8521a2930564f71919f4f4708c791a9b3545
parent d528e6e5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -276,6 +276,13 @@ public class BubbleFlyoutView extends FrameLayout {

    /** Sets the percentage that the flyout should be collapsed into dot form. */
    void setCollapsePercent(float percentCollapsed) {
        // This is unlikely, but can happen in a race condition where the flyout view hasn't been
        // laid out and returns 0 for getWidth(). We check for this condition at the sites where
        // this method is called, but better safe than sorry.
        if (Float.isNaN(percentCollapsed)) {
            return;
        }

        mPercentTransitionedToDot = Math.max(0f, Math.min(percentCollapsed, 1f));
        mPercentStillFlyout = (1f - mPercentTransitionedToDot);

+6 −1
Original line number Diff line number Diff line
@@ -1078,6 +1078,12 @@ public class BubbleStackView extends FrameLayout {
    }

    void onFlyoutDragged(float deltaX) {
        // This shouldn't happen, but if it does, just wait until the flyout lays out. This method
        // is continually called.
        if (mFlyout.getWidth() <= 0) {
            return;
        }

        final boolean onLeft = mStackAnimationController.isStackOnLeftSide();
        mFlyoutDragDeltaX = deltaX;

@@ -1096,7 +1102,6 @@ public class BubbleStackView extends FrameLayout {
            // after it has already become the dot.
            final boolean overscrollingLeft =
                    (onLeft && collapsePercent > 1f) || (!onLeft && collapsePercent < 0f);

            overscrollTranslation =
                    (overscrollingPastDot ? collapsePercent - 1f : collapsePercent * -1)
                            * (overscrollingLeft ? -1 : 1)