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

Commit 2adb4229 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android (Google) Code Review
Browse files

Merge "media: don't rely on Java 6 parseInt error on leading '+' sign"

parents a46ceb58 72bbe6cc
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
@@ -558,7 +558,11 @@ class TextTrackCue extends SubtitleTrack.Cue {
    }
}

/** @hide */
/**
 *  Supporting July 10 2013 draft version
 *
 *  @hide
 */
class WebVttParser {
    private static final String TAG = "WebVttParser";
    private Phase mPhase;
@@ -726,16 +730,16 @@ class WebVttParser {
                                "has invalid value", e.getMessage(), value);
                    }
                } else if (name.equals("lines")) {
                    try {
                        int lines = Integer.parseInt(value);
                        if (lines >= 0) {
                            region.mLines = lines;
                    if (value.matches(".*[^0-9].*")) {
                        log_warning("lines", name, "contains an invalid character", value);
                    } else {
                            log_warning("region setting", name, "is negative", value);
                        }
                        try {
                            region.mLines = Integer.parseInt(value);
                            assert(region.mLines >= 0); // lines contains only digits
                        } catch (NumberFormatException e) {
                            log_warning("region setting", name, "is not numeric", value);
                        }
                    }
                } else if (name.equals("regionanchor") ||
                           name.equals("viewportanchor")) {
                    int commaAt = value.indexOf(",");
@@ -872,18 +876,14 @@ class WebVttParser {
                    }
                } else if (name.equals("line")) {
                    try {
                        int linePosition;
                        /* TRICKY: we know that there are no spaces in value */
                        assert(value.indexOf(' ') < 0);
                        if (value.endsWith("%")) {
                            linePosition = Integer.parseInt(
                                    value.substring(0, value.length() - 1));
                            if (linePosition < 0 || linePosition > 100) {
                                log_warning("cue setting", name, "is out of range", value);
                                continue;
                            }
                            mCue.mSnapToLines = false;
                            mCue.mLinePosition = linePosition;
                            mCue.mLinePosition = parseIntPercentage(value);
                        } else if (value.matches(".*[^0-9].*")) {
                            log_warning("cue setting", name,
                                    "contains an invalid character", value);
                        } else {
                            mCue.mSnapToLines = true;
                            mCue.mLinePosition = Integer.parseInt(value);
@@ -892,6 +892,7 @@ class WebVttParser {
                        log_warning("cue setting", name,
                                "is not numeric or percentage", value);
                    }
                    // TODO: add support for optional alignment value [,start|middle|end]
                } else if (name.equals("position")) {
                    try {
                        mCue.mTextPosition = parseIntPercentage(value);