Changes 203 and 225 from partner repo.

These are combined to save testing time.


Change 225:
    make NV_READY return State.READY.

Change 203:

    CDMA SMS decoding support for Latin and fix for WAP concatenation

    1.  Enabled support for 8bit Latin decoding.
    2.  Change octet decoding to remove an extra pad byte from the payload.
        This caused problems with the concatenation of WAP PUSH messages.
    3.  Decode octet encoded data as if it was Latin. There are devices out
        there that will use 0 instead of 8.
This commit is contained in:
Wink Saville
2009-07-10 11:34:33 -07:00
parent 89fe27366b
commit 05b301b9df
3 changed files with 28 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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 + ")");

View File

@@ -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;