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

Commit 22f086f6 authored by Meng Wang's avatar Meng Wang Committed by Gerrit Code Review
Browse files

Merge "Do no use hidden API TextUtils.isPrintableAsciiOnly"

parents d3d8cd2f 75e28d8a
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ public class RuimRecords extends IccRecords {
                    // SPN is checked to have characters in printable ASCII
                    // range. If not, they are decoded with
                    // ENCODING_GSM_7BIT_ALPHABET scheme.
                    if (TextUtils.isPrintableAsciiOnly(spn)) {
                    if (isPrintableAsciiOnly(spn)) {
                        setServiceProviderName(spn);
                    } else {
                        if (DBG) log("Some corruption in SPN decoding = " + spn);
@@ -351,6 +351,22 @@ public class RuimRecords extends IccRecords {
        }
    }

    private static boolean isPrintableAsciiOnly(final CharSequence str) {
        final int len = str.length();
        for (int i = 0; i < len; i++) {
            if (!isPrintableAscii(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }

    private static boolean isPrintableAscii(final char c) {
        final int asciiFirst = 0x20;
        final int asciiLast = 0x7E;  // included
        return (asciiFirst <= c && c <= asciiLast) || c == '\r' || c == '\n';
    }

    private class EfCsimMdnLoaded implements IccRecordLoaded {
        @Override
        public String getEfName() {