Skip to content

Commit ff5a099

Browse files
Soojung ShinSimon Wilson
authored andcommitted
Added to check for supporting mms content-disposition, utf8 decoding.
Change-Id: Ieae1bb2ac36675f569fb21285ca6ef289c367bf7 Signed-off-by: Soojung Shin <sj46.shin@samsung.com>
1 parent b028ce5 commit ff5a099

File tree

3 files changed

+103
-43
lines changed

3 files changed

+103
-43
lines changed

core/java/com/google/android/mms/pdu/PduParser.java

100644100755
Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import java.util.Arrays;
3030
import java.util.HashMap;
3131

32+
import android.content.res.Resources;
33+
3234
public class PduParser {
3335
/**
3436
* The next are WAP values defined in WSP specification.
@@ -1550,43 +1552,55 @@ protected static boolean parsePartHeaders(ByteArrayInputStream pduDataStream,
15501552
* Attachment = <Octet 129>
15511553
* Inline = <Octet 130>
15521554
*/
1553-
int len = parseValueLength(pduDataStream);
1554-
pduDataStream.mark(1);
1555-
int thisStartPos = pduDataStream.available();
1556-
int thisEndPos = 0;
1557-
int value = pduDataStream.read();
1558-
1559-
if (value == PduPart.P_DISPOSITION_FROM_DATA ) {
1560-
part.setContentDisposition(PduPart.DISPOSITION_FROM_DATA);
1561-
} else if (value == PduPart.P_DISPOSITION_ATTACHMENT) {
1562-
part.setContentDisposition(PduPart.DISPOSITION_ATTACHMENT);
1563-
} else if (value == PduPart.P_DISPOSITION_INLINE) {
1564-
part.setContentDisposition(PduPart.DISPOSITION_INLINE);
1565-
} else {
1566-
pduDataStream.reset();
1567-
/* Token-text */
1568-
part.setContentDisposition(parseWapString(pduDataStream, TYPE_TEXT_STRING));
1569-
}
15701555

1571-
/* get filename parameter and skip other parameters */
1572-
thisEndPos = pduDataStream.available();
1573-
if (thisStartPos - thisEndPos < len) {
1574-
value = pduDataStream.read();
1575-
if (value == PduPart.P_FILENAME) { //filename is text-string
1576-
part.setFilename(parseWapString(pduDataStream, TYPE_TEXT_STRING));
1556+
/*
1557+
* some carrier mmsc servers do not support content_disposition
1558+
* field correctly
1559+
*/
1560+
boolean contentDisposition = Resources.getSystem().getBoolean(com
1561+
.android.internal.R.bool.config_mms_content_disposition_support);
1562+
1563+
if (contentDisposition) {
1564+
int len = parseValueLength(pduDataStream);
1565+
pduDataStream.mark(1);
1566+
int thisStartPos = pduDataStream.available();
1567+
int thisEndPos = 0;
1568+
int value = pduDataStream.read();
1569+
1570+
if (value == PduPart.P_DISPOSITION_FROM_DATA ) {
1571+
part.setContentDisposition(PduPart.DISPOSITION_FROM_DATA);
1572+
} else if (value == PduPart.P_DISPOSITION_ATTACHMENT) {
1573+
part.setContentDisposition(PduPart.DISPOSITION_ATTACHMENT);
1574+
} else if (value == PduPart.P_DISPOSITION_INLINE) {
1575+
part.setContentDisposition(PduPart.DISPOSITION_INLINE);
1576+
} else {
1577+
pduDataStream.reset();
1578+
/* Token-text */
1579+
part.setContentDisposition(parseWapString(pduDataStream
1580+
, TYPE_TEXT_STRING));
15771581
}
15781582

1579-
/* skip other parameters */
1583+
/* get filename parameter and skip other parameters */
15801584
thisEndPos = pduDataStream.available();
15811585
if (thisStartPos - thisEndPos < len) {
1582-
int last = len - (thisStartPos - thisEndPos);
1583-
byte[] temp = new byte[last];
1584-
pduDataStream.read(temp, 0, last);
1586+
value = pduDataStream.read();
1587+
if (value == PduPart.P_FILENAME) { //filename is text-string
1588+
part.setFilename(parseWapString(pduDataStream
1589+
, TYPE_TEXT_STRING));
1590+
}
1591+
1592+
/* skip other parameters */
1593+
thisEndPos = pduDataStream.available();
1594+
if (thisStartPos - thisEndPos < len) {
1595+
int last = len - (thisStartPos - thisEndPos);
1596+
byte[] temp = new byte[last];
1597+
pduDataStream.read(temp, 0, last);
1598+
}
15851599
}
1586-
}
15871600

1588-
tempPos = pduDataStream.available();
1589-
lastLen = length - (startPos - tempPos);
1601+
tempPos = pduDataStream.available();
1602+
lastLen = length - (startPos - tempPos);
1603+
}
15901604
break;
15911605
default:
15921606
if (LOCAL_LOGV) {

core/res/res/values/config.xml

100644100755
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,27 @@
380380

381381
<!-- The VoiceMail default value is displayed to my own number if it is true -->
382382
<bool name="config_telephony_use_own_number_for_voicemail">false</bool>
383+
384+
<!-- If this value is true, Sms encoded as octet is decoded by utf8 decoder.
385+
If false, decoded by Latin decoder. -->
386+
<bool name="config_sms_utf8_support">false</bool>
387+
388+
<!-- If this value is true, The mms content-disposition field is supported correctly.
389+
If false, Content-disposition fragments are ignored -->
390+
<bool name="config_mms_content_disposition_support">true</bool>
391+
392+
<!-- If this value is true, the carrier supports sms delivery reports.
393+
If false, sms delivery reports are not supported and the preference
394+
option to enable/disable delivery reports is removed in the Messaging app. -->
395+
<bool name="config_sms_delivery_reports_support">true</bool>
396+
397+
<!-- If this value is true, the carrier supports mms delivery reports.
398+
If false, mms delivery reports are not supported and the preference
399+
option to enable/disable delivery reports is removed in the Messaging app. -->
400+
<bool name="config_mms_delivery_reports_support">true</bool>
401+
402+
<!-- If this value is true, the carrier supports mms read reports.
403+
If false, mms read reports are not supported and the preference
404+
option to enable/disable read reports is removed in the Messaging app. -->
405+
<bool name="config_mms_read_reports_support">true</bool>
383406
</resources>

telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java

100644100755
Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
import com.android.internal.util.BitwiseInputStream;
3838
import com.android.internal.util.BitwiseOutputStream;
3939

40+
import android.content.res.Resources;
41+
42+
4043

4144
/**
4245
* An object to encode and decode CDMA SMS bearer data.
@@ -912,6 +915,16 @@ private static boolean decodeUserData(BearerData bData, BitwiseInputStream inStr
912915
return true;
913916
}
914917

918+
private static String decodeUtf8(byte[] data, int offset, int numFields)
919+
throws CodingException
920+
{
921+
try {
922+
return new String(data, offset, numFields, "UTF-8");
923+
} catch (java.io.UnsupportedEncodingException ex) {
924+
throw new CodingException("UTF-8 decode failed: " + ex);
925+
}
926+
}
927+
915928
private static String decodeUtf16(byte[] data, int offset, int numFields)
916929
throws CodingException
917930
{
@@ -996,19 +1009,29 @@ private static void decodeUserDataPayload(UserData userData, boolean hasUserData
9961009
}
9971010
switch (userData.msgEncoding) {
9981011
case UserData.ENCODING_OCTET:
999-
// Strip off any padding bytes, meaning any differences between the length of the
1000-
// array and the target length specified by numFields. This is to avoid any confusion
1001-
// by code elsewhere that only considers the payload array length.
1002-
byte[] payload = new byte[userData.numFields];
1003-
int copyLen = userData.numFields < userData.payload.length
1004-
? userData.numFields : userData.payload.length;
1005-
1006-
System.arraycopy(userData.payload, 0, payload, 0, copyLen);
1007-
userData.payload = payload;
1008-
1009-
// There are many devices in the market that send 8bit text sms (latin encoded) as
1010-
// octet encoded.
1011-
userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
1012+
/*
1013+
* Octet decoding depends on the carrier service.
1014+
*/
1015+
boolean decodingtypeUTF8 = Resources.getSystem()
1016+
.getBoolean(com.android.internal.R.bool.config_sms_utf8_support);
1017+
1018+
if (!decodingtypeUTF8) {
1019+
// Strip off any padding bytes, meaning any differences between the length of the
1020+
// array and the target length specified by numFields. This is to avoid any
1021+
// confusion by code elsewhere that only considers the payload array length.
1022+
byte[] payload = new byte[userData.numFields];
1023+
int copyLen = userData.numFields < userData.payload.length
1024+
? userData.numFields : userData.payload.length;
1025+
1026+
System.arraycopy(userData.payload, 0, payload, 0, copyLen);
1027+
userData.payload = payload;
1028+
1029+
// There are many devices in the market that send 8bit text sms (latin encoded) as
1030+
// octet encoded.
1031+
userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
1032+
} else {
1033+
userData.payloadStr = decodeUtf8(userData.payload, offset, userData.numFields);
1034+
}
10121035
break;
10131036
case UserData.ENCODING_IA5:
10141037
case UserData.ENCODING_7BIT_ASCII:

0 commit comments

Comments
 (0)