diff options
author | Soojung Shin <sj46.shin@samsung.com> | 2011-03-02 09:39:35 +0900 |
---|---|---|
committer | Simon Wilson <simonwilson@google.com> | 2011-03-04 14:32:31 -0800 |
commit | ff5a09904fb05f2776f1bbf1dd3915f38031190c (patch) | |
tree | 3ad61df4686f2f90092247a91d1f51853f8828b3 /telephony/java | |
parent | b028ce55cac88f1778cdad59c63c52a5b66afb69 (diff) | |
download | frameworks_base-ff5a09904fb05f2776f1bbf1dd3915f38031190c.zip frameworks_base-ff5a09904fb05f2776f1bbf1dd3915f38031190c.tar.gz frameworks_base-ff5a09904fb05f2776f1bbf1dd3915f38031190c.tar.bz2 |
Added to check for supporting mms content-disposition, utf8 decoding.
Change-Id: Ieae1bb2ac36675f569fb21285ca6ef289c367bf7
Signed-off-by: Soojung Shin <sj46.shin@samsung.com>
Diffstat (limited to 'telephony/java')
-rwxr-xr-x[-rw-r--r--] | telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java index ab79fe9..e95ec44 100644..100755 --- a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java +++ b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java @@ -37,6 +37,9 @@ import com.android.internal.util.HexDump; import com.android.internal.util.BitwiseInputStream; import com.android.internal.util.BitwiseOutputStream; +import android.content.res.Resources; + + /** * An object to encode and decode CDMA SMS bearer data. @@ -912,6 +915,16 @@ public final class BearerData { return true; } + private static String decodeUtf8(byte[] data, int offset, int numFields) + throws CodingException + { + try { + return new String(data, offset, numFields, "UTF-8"); + } catch (java.io.UnsupportedEncodingException ex) { + throw new CodingException("UTF-8 decode failed: " + ex); + } + } + private static String decodeUtf16(byte[] data, int offset, int numFields) throws CodingException { @@ -996,19 +1009,29 @@ 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); + /* + * Octet decoding depends on the carrier service. + */ + boolean decodingtypeUTF8 = Resources.getSystem() + .getBoolean(com.android.internal.R.bool.config_sms_utf8_support); + + if (!decodingtypeUTF8) { + // 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); + } else { + userData.payloadStr = decodeUtf8(userData.payload, offset, userData.numFields); + } break; case UserData.ENCODING_IA5: case UserData.ENCODING_7BIT_ASCII: |