Merge change 6805

* changes:
  Changes 203 and 225 from partner repo.
This commit is contained in:
Android (Google) Code Review
2009-07-10 13:53:17 -07:00
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;