diff options
-rwxr-xr-x[-rw-r--r--] | core/java/com/google/android/mms/pdu/PduParser.java | 74 | ||||
-rwxr-xr-x[-rw-r--r--] | core/res/res/values/config.xml | 23 | ||||
-rw-r--r-- | media/libstagefright/HTTPStream.cpp | 56 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/DataConnectionTracker.java | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java | 33 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java | 11 |
6 files changed, 151 insertions, 65 deletions
diff --git a/core/java/com/google/android/mms/pdu/PduParser.java b/core/java/com/google/android/mms/pdu/PduParser.java index 8edfe52..3f185aa 100644..100755 --- a/core/java/com/google/android/mms/pdu/PduParser.java +++ b/core/java/com/google/android/mms/pdu/PduParser.java @@ -29,6 +29,8 @@ import java.io.UnsupportedEncodingException; import java.util.Arrays; import java.util.HashMap; +import android.content.res.Resources; + public class PduParser { /** * The next are WAP values defined in WSP specification. @@ -1557,43 +1559,55 @@ public class PduParser { * Attachment = <Octet 129> * 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); - } 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)); - } - /* get filename parameter and skip other parameters */ - thisEndPos = pduDataStream.available(); - if (thisStartPos - thisEndPos < len) { - value = pduDataStream.read(); - if (value == PduPart.P_FILENAME) { //filename is text-string - part.setFilename(parseWapString(pduDataStream, TYPE_TEXT_STRING)); + /* + * some carrier mmsc servers do not support content_disposition + * field correctly + */ + boolean contentDisposition = Resources.getSystem().getBoolean(com + .android.internal.R.bool.config_mms_content_disposition_support); + + if (contentDisposition) { + 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); + } 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(); if (thisStartPos - thisEndPos < len) { - int last = len - (thisStartPos - thisEndPos); - byte[] temp = new byte[last]; - pduDataStream.read(temp, 0, last); + value = pduDataStream.read(); + if (value == PduPart.P_FILENAME) { //filename is text-string + part.setFilename(parseWapString(pduDataStream + , TYPE_TEXT_STRING)); + } + + /* skip other parameters */ + 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); + tempPos = pduDataStream.available(); + lastLen = length - (startPos - tempPos); + } break; default: if (LOCAL_LOGV) { diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index e46eecc..b24ee9e 100644..100755 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -563,4 +563,27 @@ <!-- 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> + + <!-- 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> diff --git a/media/libstagefright/HTTPStream.cpp b/media/libstagefright/HTTPStream.cpp index 498c7b8..2caf211 100644 --- a/media/libstagefright/HTTPStream.cpp +++ b/media/libstagefright/HTTPStream.cpp @@ -220,40 +220,58 @@ status_t HTTPStream::connect(const char *server, int port, bool https) { return ERROR_ALREADY_CONNECTED; } - struct hostent *ent = gethostbyname(server); - if (ent == NULL) { - return ERROR_UNKNOWN_HOST; + if (port < 0 || port > (int) USHRT_MAX) { + return UNKNOWN_ERROR; } - CHECK_EQ(mSocket, -1); - mSocket = socket(AF_INET, SOCK_STREAM, 0); + char service[sizeof("65536")]; + sprintf(service, "%d", port); + struct addrinfo hints, *ai; + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV; + hints.ai_socktype = SOCK_STREAM; - if (mSocket < 0) { - return UNKNOWN_ERROR; + int ret = getaddrinfo(server, service, &hints, &ai); + if (ret) { + return ERROR_UNKNOWN_HOST; } - setReceiveTimeout(30); // Time out reads after 30 secs by default + CHECK_EQ(mSocket, -1); mState = CONNECTING; + status_t res = -1; + struct addrinfo *tmp; + for (tmp = ai; tmp; tmp = tmp->ai_next) { + mSocket = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol); + if (mSocket < 0) { + continue; + } - int s = mSocket; + setReceiveTimeout(30); // Time out reads after 30 secs by default. - mLock.unlock(); + int s = mSocket; - struct sockaddr_in addr; - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr = *(in_addr_t *)ent->h_addr; - memset(addr.sin_zero, 0, sizeof(addr.sin_zero)); + mLock.unlock(); - status_t res = MyConnect(s, (const struct sockaddr *)&addr, sizeof(addr)); + res = MyConnect(s, tmp->ai_addr, tmp->ai_addrlen); - mLock.lock(); + mLock.lock(); - if (mState != CONNECTING) { - return UNKNOWN_ERROR; + if (mState != CONNECTING) { + close(s); + freeaddrinfo(ai); + return UNKNOWN_ERROR; + } + + if (res == OK) { + break; + } + + close(s); } + freeaddrinfo(ai); + if (res != OK) { close(mSocket); mSocket = -1; diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java index 7f8485b..7c616d6 100644 --- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java @@ -38,6 +38,8 @@ import android.provider.Settings.SettingNotFoundException; import android.text.TextUtils; import android.util.Log; +import com.android.internal.R; + import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; @@ -360,9 +362,26 @@ public abstract class DataConnectionTracker extends Handler { public boolean isApnTypeActive(String type) { // TODO: support simultaneous with List instead + if (Phone.APN_TYPE_DUN.equals(type)) { + ApnSetting dunApn = fetchDunApn(); + if (dunApn != null) { + return ((mActiveApn != null) && (dunApn.toString().equals(mActiveApn.toString()))); + } + } return mActiveApn != null && mActiveApn.canHandleType(type); } + protected ApnSetting fetchDunApn() { + Context c = mPhone.getContext(); + String apnData = Settings.Secure.getString(c.getContentResolver(), + Settings.Secure.TETHER_DUN_APN); + ApnSetting dunSetting = ApnSetting.fromString(apnData); + if (dunSetting != null) return dunSetting; + + apnData = c.getResources().getString(R.string.config_tether_apndata); + return ApnSetting.fromString(apnData); + } + public String[] getActiveApnTypes() { String[] result; if (mActiveApn != null) { 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 cf06dab..12644c8 100644..100755 --- a/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java +++ b/telephony/java/com/android/internal/telephony/cdma/sms/BearerData.java @@ -34,6 +34,9 @@ import com.android.internal.telephony.SmsMessageBase.TextEncodingDetails; 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. @@ -910,6 +913,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 { @@ -994,9 +1007,15 @@ public final class BearerData { } switch (userData.msgEncoding) { case UserData.ENCODING_OCTET: + /* + * Octet decoding depends on the carrier service. + */ + boolean decodingtypeUTF8 = Resources.getSystem() + .getBoolean(com.android.internal.R.bool.config_sms_utf8_support); + // 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. + // 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; @@ -1004,9 +1023,13 @@ public final class BearerData { 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); + if (!decodingtypeUTF8) { + // 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: diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index c57f2f1..55cffba 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -1164,17 +1164,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { } } - private ApnSetting fetchDunApn() { - Context c = mPhone.getContext(); - String apnData = Settings.Secure.getString(c.getContentResolver(), - Settings.Secure.TETHER_DUN_APN); - ApnSetting dunSetting = ApnSetting.fromString(apnData); - if (dunSetting != null) return dunSetting; - - apnData = c.getResources().getString(R.string.config_tether_apndata); - return ApnSetting.fromString(apnData); - } - /** * Build a list of APNs to be used to create PDP's. * |