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

Commit 4c307474 authored by Nathan Harold's avatar Nathan Harold
Browse files

Trim Empty PLMNs from the list of parsed PLMNs

aosp/428381/ changed the PLMN parsing in IccUtils
to trim all 'f' characters, which resulted in a few
functions returning empty instead of ffffff for SIM
records that were unfilled. To fix those methods,
we now trim all results that are returned as empty

Bug: 68218015
Test: cts - testGetForbiddenPlmns()
Change-Id: I07fa0f2ef3d0135f672bd50b5079d23e46cce636
parent 103e42f1
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2072,10 +2072,14 @@ public class SIMRecords extends IccRecords {
            return null;
        }
        int numPlmns = data.length / packedBcdPlmnLenBytes;
        String[] ret = new String[numPlmns];
        int numValidPlmns = 0;
        String[] parsed = new String[numPlmns];
        for (int i = 0; i < numPlmns; i++) {
            ret[i] = IccUtils.bcdPlmnToString(data, i * packedBcdPlmnLenBytes);
            parsed[numValidPlmns] = IccUtils.bcdPlmnToString(data, i * packedBcdPlmnLenBytes);
            // we count the valid (non empty) records and only increment if valid
            if (!TextUtils.isEmpty(parsed[numValidPlmns])) numValidPlmns++;
        }
        String[] ret = Arrays.copyOf(parsed, numValidPlmns);
        if (VDBG) logv(description + " PLMNs: " + Arrays.toString(ret));
        return ret;
    }