Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff5a0990 authored by Soojung Shin's avatar Soojung Shin Committed by Simon Wilson
Browse files

Added to check for supporting mms content-disposition, utf8 decoding.



Change-Id: Ieae1bb2ac36675f569fb21285ca6ef289c367bf7
Signed-off-by: default avatarSoojung Shin <sj46.shin@samsung.com>
parent b028ce55
Loading
Loading
Loading
Loading
+44 −30
Original line number Diff line number Diff line
@@ -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.
@@ -1550,6 +1552,15 @@ public class PduParser {
                         * Attachment = <Octet 129>
                         * Inline = <Octet 130>
                         */

                        /*
                         * 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();
@@ -1565,7 +1576,8 @@ public class PduParser {
                            } else {
                                pduDataStream.reset();
                                /* Token-text */
                            part.setContentDisposition(parseWapString(pduDataStream, TYPE_TEXT_STRING));
                                part.setContentDisposition(parseWapString(pduDataStream
                                        , TYPE_TEXT_STRING));
                            }

                            /* get filename parameter and skip other parameters */
@@ -1573,7 +1585,8 @@ public class PduParser {
                            if (thisStartPos - thisEndPos < len) {
                                value = pduDataStream.read();
                                if (value == PduPart.P_FILENAME) { //filename is text-string
                                part.setFilename(parseWapString(pduDataStream, TYPE_TEXT_STRING));
                                    part.setFilename(parseWapString(pduDataStream
                                            , TYPE_TEXT_STRING));
                                }

                                /* skip other parameters */
@@ -1587,6 +1600,7 @@ public class PduParser {

                            tempPos = pduDataStream.available();
                            lastLen = length - (startPos - tempPos);
                        }
                        break;
                    default:
                        if (LOCAL_LOGV) {

core/res/res/values/config.xml

100644 → 100755
+23 −0
Original line number Diff line number Diff line
@@ -380,4 +380,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>
+36 −13
Original line number Diff line number Diff line
@@ -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,9 +1009,16 @@ 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);

            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.
                // 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;
@@ -1009,6 +1029,9 @@ public final class BearerData {
                // 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: