am ff5a0990: Added to check for supporting mms content-disposition, utf8 decoding.
* commit 'ff5a09904fb05f2776f1bbf1dd3915f38031190c': Added to check for supporting mms content-disposition, utf8 decoding.
This commit is contained in:
74
core/java/com/google/android/mms/pdu/PduParser.java
Normal file → Executable file
74
core/java/com/google/android/mms/pdu/PduParser.java
Normal file → Executable file
@@ -29,6 +29,8 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
|
|
||||||
public class PduParser {
|
public class PduParser {
|
||||||
/**
|
/**
|
||||||
* The next are WAP values defined in WSP specification.
|
* The next are WAP values defined in WSP specification.
|
||||||
@@ -1557,43 +1559,55 @@ public class PduParser {
|
|||||||
* Attachment = <Octet 129>
|
* Attachment = <Octet 129>
|
||||||
* Inline = <Octet 130>
|
* Inline = <Octet 130>
|
||||||
*/
|
*/
|
||||||
int len = parseValueLength(pduDataStream);
|
|
||||||
pduDataStream.mark(1);
|
|
||||||
int thisStartPos = pduDataStream.available();
|
|
||||||
int thisEndPos = 0;
|
|
||||||
int value = pduDataStream.read();
|
|
||||||
|
|
||||||
if (value == PduPart.P_DISPOSITION_FROM_DATA ) {
|
/*
|
||||||
part.setContentDisposition(PduPart.DISPOSITION_FROM_DATA);
|
* some carrier mmsc servers do not support content_disposition
|
||||||
} else if (value == PduPart.P_DISPOSITION_ATTACHMENT) {
|
* field correctly
|
||||||
part.setContentDisposition(PduPart.DISPOSITION_ATTACHMENT);
|
*/
|
||||||
} else if (value == PduPart.P_DISPOSITION_INLINE) {
|
boolean contentDisposition = Resources.getSystem().getBoolean(com
|
||||||
part.setContentDisposition(PduPart.DISPOSITION_INLINE);
|
.android.internal.R.bool.config_mms_content_disposition_support);
|
||||||
} else {
|
|
||||||
pduDataStream.reset();
|
|
||||||
/* Token-text */
|
|
||||||
part.setContentDisposition(parseWapString(pduDataStream, TYPE_TEXT_STRING));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* get filename parameter and skip other parameters */
|
if (contentDisposition) {
|
||||||
thisEndPos = pduDataStream.available();
|
int len = parseValueLength(pduDataStream);
|
||||||
if (thisStartPos - thisEndPos < len) {
|
pduDataStream.mark(1);
|
||||||
value = pduDataStream.read();
|
int thisStartPos = pduDataStream.available();
|
||||||
if (value == PduPart.P_FILENAME) { //filename is text-string
|
int thisEndPos = 0;
|
||||||
part.setFilename(parseWapString(pduDataStream, TYPE_TEXT_STRING));
|
int value = pduDataStream.read();
|
||||||
|
|
||||||
|
if (value == PduPart.P_DISPOSITION_FROM_DATA ) {
|
||||||
|
part.setContentDisposition(PduPart.DISPOSITION_FROM_DATA);
|
||||||
|
} else if (value == PduPart.P_DISPOSITION_ATTACHMENT) {
|
||||||
|
part.setContentDisposition(PduPart.DISPOSITION_ATTACHMENT);
|
||||||
|
} else if (value == PduPart.P_DISPOSITION_INLINE) {
|
||||||
|
part.setContentDisposition(PduPart.DISPOSITION_INLINE);
|
||||||
|
} else {
|
||||||
|
pduDataStream.reset();
|
||||||
|
/* Token-text */
|
||||||
|
part.setContentDisposition(parseWapString(pduDataStream
|
||||||
|
, TYPE_TEXT_STRING));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip other parameters */
|
/* get filename parameter and skip other parameters */
|
||||||
thisEndPos = pduDataStream.available();
|
thisEndPos = pduDataStream.available();
|
||||||
if (thisStartPos - thisEndPos < len) {
|
if (thisStartPos - thisEndPos < len) {
|
||||||
int last = len - (thisStartPos - thisEndPos);
|
value = pduDataStream.read();
|
||||||
byte[] temp = new byte[last];
|
if (value == PduPart.P_FILENAME) { //filename is text-string
|
||||||
pduDataStream.read(temp, 0, last);
|
part.setFilename(parseWapString(pduDataStream
|
||||||
}
|
, TYPE_TEXT_STRING));
|
||||||
}
|
}
|
||||||
|
|
||||||
tempPos = pduDataStream.available();
|
/* skip other parameters */
|
||||||
lastLen = length - (startPos - tempPos);
|
thisEndPos = pduDataStream.available();
|
||||||
|
if (thisStartPos - thisEndPos < len) {
|
||||||
|
int last = len - (thisStartPos - thisEndPos);
|
||||||
|
byte[] temp = new byte[last];
|
||||||
|
pduDataStream.read(temp, 0, last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tempPos = pduDataStream.available();
|
||||||
|
lastLen = length - (startPos - tempPos);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (LOCAL_LOGV) {
|
if (LOCAL_LOGV) {
|
||||||
|
|||||||
23
core/res/res/values/config.xml
Normal file → Executable file
23
core/res/res/values/config.xml
Normal file → Executable file
@@ -402,4 +402,27 @@
|
|||||||
|
|
||||||
<!-- The VoiceMail default value is displayed to my own number if it is true -->
|
<!-- The VoiceMail default value is displayed to my own number if it is true -->
|
||||||
<bool name="config_telephony_use_own_number_for_voicemail">false</bool>
|
<bool name="config_telephony_use_own_number_for_voicemail">false</bool>
|
||||||
|
|
||||||
|
<!-- If this value is true, Sms encoded as octet is decoded by utf8 decoder.
|
||||||
|
If false, decoded by Latin decoder. -->
|
||||||
|
<bool name="config_sms_utf8_support">false</bool>
|
||||||
|
|
||||||
|
<!-- If this value is true, The mms content-disposition field is supported correctly.
|
||||||
|
If false, Content-disposition fragments are ignored -->
|
||||||
|
<bool name="config_mms_content_disposition_support">true</bool>
|
||||||
|
|
||||||
|
<!-- If this value is true, the carrier supports sms delivery reports.
|
||||||
|
If false, sms delivery reports are not supported and the preference
|
||||||
|
option to enable/disable delivery reports is removed in the Messaging app. -->
|
||||||
|
<bool name="config_sms_delivery_reports_support">true</bool>
|
||||||
|
|
||||||
|
<!-- If this value is true, the carrier supports mms delivery reports.
|
||||||
|
If false, mms delivery reports are not supported and the preference
|
||||||
|
option to enable/disable delivery reports is removed in the Messaging app. -->
|
||||||
|
<bool name="config_mms_delivery_reports_support">true</bool>
|
||||||
|
|
||||||
|
<!-- If this value is true, the carrier supports mms read reports.
|
||||||
|
If false, mms read reports are not supported and the preference
|
||||||
|
option to enable/disable read reports is removed in the Messaging app. -->
|
||||||
|
<bool name="config_mms_read_reports_support">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
45
telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
Normal file → Executable file
45
telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java
Normal file → Executable file
@@ -37,6 +37,9 @@ import com.android.internal.util.HexDump;
|
|||||||
import com.android.internal.util.BitwiseInputStream;
|
import com.android.internal.util.BitwiseInputStream;
|
||||||
import com.android.internal.util.BitwiseOutputStream;
|
import com.android.internal.util.BitwiseOutputStream;
|
||||||
|
|
||||||
|
import android.content.res.Resources;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object to encode and decode CDMA SMS bearer data.
|
* An object to encode and decode CDMA SMS bearer data.
|
||||||
@@ -912,6 +915,16 @@ public final class BearerData {
|
|||||||
return true;
|
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)
|
private static String decodeUtf16(byte[] data, int offset, int numFields)
|
||||||
throws CodingException
|
throws CodingException
|
||||||
{
|
{
|
||||||
@@ -996,19 +1009,29 @@ public final class BearerData {
|
|||||||
}
|
}
|
||||||
switch (userData.msgEncoding) {
|
switch (userData.msgEncoding) {
|
||||||
case UserData.ENCODING_OCTET:
|
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
|
* Octet decoding depends on the carrier service.
|
||||||
// by code elsewhere that only considers the payload array length.
|
*/
|
||||||
byte[] payload = new byte[userData.numFields];
|
boolean decodingtypeUTF8 = Resources.getSystem()
|
||||||
int copyLen = userData.numFields < userData.payload.length
|
.getBoolean(com.android.internal.R.bool.config_sms_utf8_support);
|
||||||
? userData.numFields : userData.payload.length;
|
|
||||||
|
|
||||||
System.arraycopy(userData.payload, 0, payload, 0, copyLen);
|
if (!decodingtypeUTF8) {
|
||||||
userData.payload = payload;
|
// 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;
|
||||||
|
|
||||||
// There are many devices in the market that send 8bit text sms (latin encoded) as
|
System.arraycopy(userData.payload, 0, payload, 0, copyLen);
|
||||||
// octet encoded.
|
userData.payload = payload;
|
||||||
userData.payloadStr = decodeLatin(userData.payload, offset, userData.numFields);
|
|
||||||
|
// 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;
|
break;
|
||||||
case UserData.ENCODING_IA5:
|
case UserData.ENCODING_IA5:
|
||||||
case UserData.ENCODING_7BIT_ASCII:
|
case UserData.ENCODING_7BIT_ASCII:
|
||||||
|
|||||||
Reference in New Issue
Block a user