diff options
author | Jake Hamby <jhamby@google.com> | 2011-03-15 20:09:46 -0700 |
---|---|---|
committer | Jake Hamby <jhamby@google.com> | 2011-04-06 14:20:04 -0700 |
commit | b49a73dfc4c9817bba1f227e9330555acdf9b56f (patch) | |
tree | 6a896e163c52be242c20b72be02fc5d2bc17a500 /telephony/java/android | |
parent | 43707a83ec12957fb84a406276a38fbaf4e23fd3 (diff) | |
download | frameworks_base-b49a73dfc4c9817bba1f227e9330555acdf9b56f.zip frameworks_base-b49a73dfc4c9817bba1f227e9330555acdf9b56f.tar.gz frameworks_base-b49a73dfc4c9817bba1f227e9330555acdf9b56f.tar.bz2 |
Enable support for SMS national language shift tables.
Add support for encoding and decoding SMS 7 bit user data using the
national language shift tables defined in 3GPP TS 23.038 (GSM/UMTS only),
including the new tables added in Release 9 for Indic languages.
Decoding is always supported, but encoding is only enabled for the
specific language tables added to the new integer array resources
"config_sms_enabled_single_shift_tables" and
"config_sms_enabled_locking_shift_tables" defined in
frameworks/base/core/res/res/values/config.xml. The default empty arrays
should be overridden in an OEM overlay for the specific nationalities where
SMS national language shift table encoding is allowed/mandated (e.g. Turkey).
GsmAlphabet.countGsmSeptets() will try to find the most efficient encoding
among all combinations of enabled locking shift and single shift tables.
If no 7 bit encoding is possible, 16 bit UCS-2 encoding will be used.
This change also fixes a bug in the decoder: when an escape septet
is followed by a septet with no entry in the extension (single shift)
table, TS 23.038 Table 6.2.1.1 states that the MS shall display
the character in the main GSM 7 bit default alphabet table, or the
active national language locking shift table. Previously, we were
decoding this sequence as a space character. Two consecutive escape
septets will continue to decode as a space character, according to
Note 1 of table 6.2.1.1.
Change-Id: I4dab3f0ffe39f3df2064ed93c9c05f26e274d18b
Diffstat (limited to 'telephony/java/android')
-rw-r--r-- | telephony/java/android/telephony/SmsMessage.java | 12 | ||||
-rw-r--r-- | telephony/java/android/telephony/gsm/SmsMessage.java | 37 |
2 files changed, 15 insertions, 34 deletions
diff --git a/telephony/java/android/telephony/SmsMessage.java b/telephony/java/android/telephony/SmsMessage.java index a284ea5..34ca902 100644 --- a/telephony/java/android/telephony/SmsMessage.java +++ b/telephony/java/android/telephony/SmsMessage.java @@ -314,7 +314,8 @@ public class SmsMessage { nextPos = pos + Math.min(limit, textLen - pos); } else { // For multi-segment messages, CDMA 7bit equals GSM 7bit encoding (EMS mode). - nextPos = GsmAlphabet.findGsmSeptetLimitIndex(text, pos, limit); + nextPos = GsmAlphabet.findGsmSeptetLimitIndex(text, pos, limit, + ted.languageTable, ted.languageShiftTable); } } else { // Assume unicode. nextPos = pos + Math.min(limit / 2, textLen - pos); @@ -370,7 +371,8 @@ public class SmsMessage { */ /** - * Get an SMS-SUBMIT PDU for a destination address and a message + * Get an SMS-SUBMIT PDU for a destination address and a message. + * This method will not attempt to use any GSM national language 7 bit encodings. * * @param scAddress Service Centre address. Null means use default. * @return a <code>SubmitPdu</code> containing the encoded SC @@ -397,7 +399,8 @@ public class SmsMessage { } /** - * Get an SMS-SUBMIT PDU for a destination address and a message + * Get an SMS-SUBMIT PDU for a destination address and a message. + * This method will not attempt to use any GSM national language 7 bit encodings. * * @param scAddress Service Centre address. Null means use default. * @return a <code>SubmitPdu</code> containing the encoded SC @@ -421,7 +424,8 @@ public class SmsMessage { } /** - * Get an SMS-SUBMIT PDU for a data message to a destination address & port + * Get an SMS-SUBMIT PDU for a data message to a destination address & port. + * This method will not attempt to use any GSM national language 7 bit encodings. * * @param scAddress Service Centre address. null == use default * @param destinationAddress the address of the destination for the message diff --git a/telephony/java/android/telephony/gsm/SmsMessage.java b/telephony/java/android/telephony/gsm/SmsMessage.java index 0c63c37..1b95cd4 100644 --- a/telephony/java/android/telephony/gsm/SmsMessage.java +++ b/telephony/java/android/telephony/gsm/SmsMessage.java @@ -297,37 +297,14 @@ public class SmsMessage { */ @Deprecated public static int[] calculateLength(CharSequence messageBody, boolean use7bitOnly) { + SmsMessageBase.TextEncodingDetails ted = + com.android.internal.telephony.gsm.SmsMessage + .calculateLength(messageBody, use7bitOnly); int ret[] = new int[4]; - - try { - // Try GSM alphabet - int septets = GsmAlphabet.countGsmSeptets(messageBody, !use7bitOnly); - ret[1] = septets; - if (septets > MAX_USER_DATA_SEPTETS) { - ret[0] = (septets + (MAX_USER_DATA_SEPTETS_WITH_HEADER - 1)) / - MAX_USER_DATA_SEPTETS_WITH_HEADER; - ret[2] = (ret[0] * MAX_USER_DATA_SEPTETS_WITH_HEADER) - septets; - } else { - ret[0] = 1; - ret[2] = MAX_USER_DATA_SEPTETS - septets; - } - ret[3] = ENCODING_7BIT; - } catch (EncodeException ex) { - // fall back to UCS-2 - int octets = messageBody.length() * 2; - ret[1] = messageBody.length(); - if (octets > MAX_USER_DATA_BYTES) { - // 6 is the size of the user data header - ret[0] = (octets + (MAX_USER_DATA_BYTES_WITH_HEADER - 1)) / - MAX_USER_DATA_BYTES_WITH_HEADER; - ret[2] = ((ret[0] * MAX_USER_DATA_BYTES_WITH_HEADER) - octets) / 2; - } else { - ret[0] = 1; - ret[2] = (MAX_USER_DATA_BYTES - octets)/2; - } - ret[3] = ENCODING_16BIT; - } - + ret[0] = ted.msgCount; + ret[1] = ted.codeUnitCount; + ret[2] = ted.codeUnitsRemaining; + ret[3] = ted.codeUnitSize; return ret; } |