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

Commit 9adc2bf8 authored by Sridhar Dubbaka's avatar Sridhar Dubbaka Committed by Steve Kondik
Browse files

Parsing of CDMA MMS notification carried by SMS

Decode operator specific WDP header.

Change-Id: I4ac1a66dba8590c496fd4375c8dfb9c49272617e
parent b9ed811d
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -168,6 +168,10 @@ public class CdmaInboundSmsHandler extends InboundSmsHandler {
                // handled below, after storage check
                break;

            case SmsEnvelope.TELESERVICE_CT_WAP:
                // handled below, after TELESERVICE_WAP
                break;

            default:
                loge("unsupported teleservice 0x" + Integer.toHexString(teleService));
                return Intents.RESULT_SMS_UNSUPPORTED;
@@ -184,6 +188,14 @@ public class CdmaInboundSmsHandler extends InboundSmsHandler {
        if (SmsEnvelope.TELESERVICE_WAP == teleService) {
            return processCdmaWapPdu(sms.getUserData(), sms.mMessageRef,
                    sms.getOriginatingAddress(), sms.getTimestampMillis());
        } else if (SmsEnvelope.TELESERVICE_CT_WAP == teleService) {
            /* China Telecom WDP header contains Message identifier
               and User data subparametrs extract these fields */
            if (!sms.processCdmaCTWdpHeader(sms)) {
                return Intents.RESULT_SMS_HANDLED;
            }
            return processCdmaWapPdu(sms.getUserData(), sms.mMessageRef,
                    sms.getOriginatingAddress(), sms.getTimestampMillis());
        }

        return dispatchNormalMessage(smsb);
+57 −0
Original line number Diff line number Diff line
@@ -1049,4 +1049,61 @@ public class SmsMessage extends SmsMessageBase {
    public ArrayList<CdmaSmsCbProgramData> getSmsCbProgramData() {
        return mBearerData.serviceCategoryProgramData;
    }

    /**
    * CT WDP header contains WDP Msg Identifier and WDP Userdata
    */
    protected boolean processCdmaCTWdpHeader(SmsMessage sms) {
        int subparamId = 0;
        int subParamLen = 0;
        int msgID = 0;
        boolean decodeSuccess = false;
        try {
            BitwiseInputStream inStream = new BitwiseInputStream(sms.getUserData());

            /* Decode WDP Messsage Identifier */
            subparamId = inStream.read(8);
            if (subparamId != 0) {
                Rlog.e(LOG_TAG, "Invalid WDP SubparameterId");
                return false;
            }
            subParamLen = inStream.read(8);
            if (subParamLen != 3) {
                Rlog.e(LOG_TAG, "Invalid WDP subparameter length");
                return false;
            }
            sms.mBearerData.messageType = inStream.read(4);
            msgID = inStream.read(8) << 8;
            msgID |= inStream.read(8);
            sms.mBearerData.hasUserDataHeader = (inStream.read(1) == 1);
            if (sms.mBearerData.hasUserDataHeader) {
                Rlog.e(LOG_TAG, "Invalid WDP UserData header value");
                return false;
            }
            inStream.skip(3);
            sms.mBearerData.messageId = msgID;
            sms.mMessageRef = msgID;

            /* Decode WDP User Data */
            subparamId = inStream.read(8);
            subParamLen = inStream.read(8) * 8;
            sms.mBearerData.userData.msgEncoding = inStream.read(5);
            int consumedBits = 5;
            if (sms.mBearerData.userData.msgEncoding != 0) {
                Rlog.e(LOG_TAG, "Invalid WDP encoding");
                return false;
            }
            sms.mBearerData.userData.numFields = inStream.read(8);
            consumedBits += 8;
            int remainingBits = subParamLen - consumedBits;
            int dataBits = sms.mBearerData.userData.numFields * 8;
            dataBits = dataBits < remainingBits ? dataBits : remainingBits;
            sms.mBearerData.userData.payload = inStream.readByteArray(dataBits);
            sms.mUserData = sms.mBearerData.userData.payload;
            decodeSuccess = true;
        } catch (BitwiseInputStream.AccessException ex) {
            Rlog.e(LOG_TAG, "CT WDP Header decode failed: " + ex);
        }
        return decodeSuccess;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public final class SmsEnvelope {
    static public final int TELESERVICE_WAP               = 0x1004;
    static public final int TELESERVICE_WEMT              = 0x1005;
    static public final int TELESERVICE_SCPT              = 0x1006;
    static public final int TELESERVICE_CT_WAP            = 0xFDEA;

    /**
     * The following are defined as extensions to the standard teleservices