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

Commit f6e91488 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Parsing of CDMA MMS notification carried by SMS"

parents cc499d94 a9ca3083
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -175,6 +175,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;
@@ -191,6 +195,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);
+55 −0
Original line number Diff line number Diff line
@@ -1088,4 +1088,59 @@ 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 dataBits = subParamLen - consumedBits;
            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