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

Commit c266156a authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 6805

* changes:
  Changes 203 and 225 from partner repo.
parents b88993f0 05b301b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -122,8 +122,8 @@ public abstract class IccCard {
                    return State.UNKNOWN;
                case SIM_READY:
                case RUIM_READY:
                    return State.READY;
                case NV_READY:
                    return State.READY;
                case NV_NOT_READY:
                    return State.ABSENT;
            }
+26 −0
Original line number Diff line number Diff line
@@ -901,6 +901,16 @@ public final class BearerData {
        return result;
    }

    private static String decodeLatin(byte[] data, int offset, int numFields)
        throws CodingException
    {
        try {
            return new String(data, offset, numFields - offset, "ISO-8859-1");
        } catch (java.io.UnsupportedEncodingException ex) {
            throw new CodingException("ISO-8859-1 decode failed: " + ex);
        }
    }

    private static void decodeUserDataPayload(UserData userData, boolean hasUserDataHeader)
        throws CodingException
    {
@@ -914,6 +924,19 @@ public final class BearerData {
        }
        switch (userData.msgEncoding) {
        case UserData.ENCODING_OCTET:
            // Strip off any padding bytes, meaning any differences between the length of the
            // array and the target length specified by numFields.  This is to avoid any confusion
            // by code elsewhere that only considers the payload array length.
            byte[] payload = new byte[userData.numFields];
            int copyLen = userData.numFields < userData.payload.length
                    ? userData.numFields : userData.payload.length;

            System.arraycopy(userData.payload, 0, payload, 0, copyLen);
            userData.payload = payload;

            // There are many devices in the market that send 8bit text sms (latin encoded) as
            // octet encoded.
            userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
            break;
        case UserData.ENCODING_7BIT_ASCII:
            userData.payloadStr = decode7bitAscii(userData.payload, offset, userData.numFields);
@@ -927,6 +950,9 @@ public final class BearerData {
        case UserData.ENCODING_GSM_7BIT_ALPHABET:
            userData.payloadStr = decode7bitGsm(userData.payload, offset, userData.numFields);
            break;
        case UserData.ENCODING_LATIN:
            userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
            break;
        default:
            throw new CodingException("unsupported user data encoding ("
                                      + userData.msgEncoding + ")");
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class UserData {
    //public static final int ENCODING_SHIFT_JIS                  = 0x05;
    //public static final int ENCODING_KOREAN                     = 0x06;
    //public static final int ENCODING_LATIN_HEBREW               = 0x07;
    //public static final int ENCODING_LATIN                      = 0x08;
    public static final int ENCODING_LATIN                      = 0x08;
    public static final int ENCODING_GSM_7BIT_ALPHABET          = 0x09;
    public static final int ENCODING_GSM_DCS                    = 0x0A;