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

Commit 75e28d8a authored by Meng Wang's avatar Meng Wang
Browse files

Do no use hidden API TextUtils.isPrintableAsciiOnly

Make a local copy instead.

Bug: 137202333
Test: make
Change-Id: I5f23495e30f3f2a04f7502e0a73810be6aa53234
parent a0cdeceb
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() {