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

Commit 1d52db3b authored by Ye Wen's avatar Ye Wen Committed by Android (Google) Code Review
Browse files

Merge "PduParser MSIM support (2/4)" into lmp-mr1-dev

parents 47f7fc63 032e0398
Loading
Loading
Loading
Loading
+21 −15
Original line number Diff line number Diff line
@@ -16,15 +16,9 @@

package com.android.internal.telephony;

import com.google.android.mms.MmsException;
import com.google.android.mms.pdu.DeliveryInd;
import com.google.android.mms.pdu.GenericPdu;
import com.google.android.mms.pdu.NotificationInd;
import com.google.android.mms.pdu.PduHeaders;
import com.google.android.mms.pdu.PduParser;
import com.google.android.mms.pdu.PduPersister;
import com.google.android.mms.pdu.ReadOrigInd;

import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_DELIVERY_IND;
import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_READ_ORIG_IND;
import android.app.Activity;
import android.app.AppOpsManager;
import android.content.BroadcastReceiver;
@@ -44,16 +38,20 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Telephony;
import android.provider.Telephony.Sms.Intents;
import android.telephony.Rlog;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.Rlog;
import android.util.Log;

import com.android.internal.telephony.uicc.IccUtils;

import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_DELIVERY_IND;
import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;
import static com.google.android.mms.pdu.PduHeaders.MESSAGE_TYPE_READ_ORIG_IND;
import com.google.android.mms.MmsException;
import com.google.android.mms.pdu.DeliveryInd;
import com.google.android.mms.pdu.GenericPdu;
import com.google.android.mms.pdu.NotificationInd;
import com.google.android.mms.pdu.PduHeaders;
import com.google.android.mms.pdu.PduParser;
import com.google.android.mms.pdu.PduPersister;
import com.google.android.mms.pdu.ReadOrigInd;

/**
 * WAP push handler class.
@@ -302,8 +300,16 @@ public class WapPushOverSms implements ServiceConnection {
        }
    }

    private static boolean shouldParseContentDisposition(int subId) {
        return SmsManager
                .getSmsManagerForSubscriptionId(subId)
                .getCarrierConfigValues()
                .getBoolean(SmsManager.MMS_CONFIG_SUPPORT_MMS_CONTENT_DISPOSITION, true);
    }

    private void writeInboxMessage(int subId, byte[] pushData) {
        final GenericPdu pdu = new PduParser(pushData).parse();
        final GenericPdu pdu =
                new PduParser(pushData, shouldParseContentDisposition(subId)).parse();
        if (pdu == null) {
            Rlog.e(TAG, "Invalid PUSH PDU");
        }
+13 −12
Original line number Diff line number Diff line
@@ -17,11 +17,10 @@

package com.google.android.mms.pdu;

import android.util.Log;

import com.google.android.mms.ContentType;
import com.google.android.mms.InvalidHeaderValueException;
import com.google.android.mms.pdu.EncodedStringValue;

import android.util.Log;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,8 +28,6 @@ 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.
@@ -88,13 +85,20 @@ public class PduParser {
    private static final boolean DEBUG = false;
    private static final boolean LOCAL_LOGV = false;

    /**
     * Whether to parse content-disposition part header
     */
    private final boolean mParseContentDisposition;

    /**
     * Constructor.
     *
     * @param pduDataStream pdu data to be parsed
     * @param parseContentDisposition whether to parse the Content-Disposition part header
     */
    public PduParser(byte[] pduDataStream) {
    public PduParser(byte[] pduDataStream, boolean parseContentDisposition) {
        mPduDataStream = new ByteArrayInputStream(pduDataStream);
        mParseContentDisposition = parseContentDisposition;
    }

    /**
@@ -828,7 +832,7 @@ public class PduParser {
     * @param pduDataStream pdu data input stream
     * @return parts in PduBody structure
     */
    protected static PduBody parseParts(ByteArrayInputStream pduDataStream) {
    protected PduBody parseParts(ByteArrayInputStream pduDataStream) {
        if (pduDataStream == null) {
            return null;
        }
@@ -1587,7 +1591,7 @@ public class PduParser {
     * @param length length of the headers
     * @return true if parse successfully, false otherwise
     */
    protected static boolean parsePartHeaders(ByteArrayInputStream pduDataStream,
    protected boolean parsePartHeaders(ByteArrayInputStream pduDataStream,
            PduPart part, int length) {
        assert(null != pduDataStream);
        assert(null != part);
@@ -1661,10 +1665,7 @@ public class PduParser {
                         * 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) {
                        if (mParseContentDisposition) {
                            int len = parseValueLength(pduDataStream);
                            pduDataStream.mark(1);
                            int thisStartPos = pduDataStream.available();