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

Commit 6f968fe7 authored by Calvin Huang's avatar Calvin Huang
Browse files

Check lineHeight without cast

checkArgumentNonNegative with cast doesn't work properly if
-1 < lineHeight < 0

Fix: 280028267
Test: atest android.widget.cts.TextViewTest
Change-Id: I5a1244eb0c5a0f91671a77f6203178cbee2b64e5
parent cf3cbe8a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6228,7 +6228,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }
    private void setLineHeightPx(@Px @FloatRange(from = 0) float lineHeight) {
        Preconditions.checkArgumentNonnegative((int) lineHeight);
        Preconditions.checkArgumentNonNegative(lineHeight,
                "Expecting non-negative lineHeight while the input is " + lineHeight);
        final int fontHeight = getPaint().getFontMetricsInt(null);
        // Make sure we don't setLineSpacing if it's not needed to avoid unnecessary redraw.