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

Commit 5789a6df authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Merge "Preprocessing Teleservice Id 0xFDEA SMS WAP" am: 597234f1 am:...

Merge "Preprocessing Teleservice Id 0xFDEA SMS WAP" am: 597234f1 am: 18f96879 am: 7bebbb7c am: 9cfe7bab
am: 65d8b4af

Change-Id: I9828e5dbf228414907a7beee8f23aef5e1eb4fb5
parents ce766b3a 65d8b4af
Loading
Loading
Loading
Loading
+83 −0
Original line number Diff line number Diff line
@@ -695,6 +695,89 @@ public class SmsMessage extends SmsMessageBase {
        parseSms();
    }

    /**
     * Pre-processes an SMS WAP for Teleservice Id 0xFDEA(65002).
     *
     * It requires an additional header parsing to extract new Message Identifier and new User Data
     * from WDP SMS User Data.
     *
     * - WDP SMS User Data Subparameter =
     *   |User Data SUBPARAMETER_ID ~ NUM_FIELDS| + |CHARi| + |RESERVED|
     *
     * - WDP SMS User Data Subparameter CHARi =
     *   |New Message Identifier Subparameter(HEADER_IND = 0)| +
     *   |New User Data Subparameter(MSG_ENCODING = ENCODING_OCTET)|
     *
     * @return true if preprocessing is successful, false otherwise.
     */
    public boolean preprocessCdmaFdeaWap() {
        try {
            BitwiseInputStream inStream = new BitwiseInputStream(mUserData);

            // Message Identifier SUBPARAMETER_ID(0x00)
            if (inStream.read(8) != 0x00) {
                Rlog.e(LOG_TAG, "Invalid FDEA WDP Header Message Identifier SUBPARAMETER_ID");
                return false;
            }

            // Message Identifier SUBPARAM_LEN(0x03)
            if (inStream.read(8) != 0x03) {
                Rlog.e(LOG_TAG, "Invalid FDEA WDP Header Message Identifier SUBPARAM_LEN");
                return false;
            }

            // Message Identifier MESSAGE_TYPE
            mBearerData.messageType = inStream.read(4);

            // Message Identifier MESSAGE_ID
            int msgId = inStream.read(8) << 8;
            msgId |= inStream.read(8);
            mBearerData.messageId = msgId;
            mMessageRef = msgId;

            // Message Identifier HEADER_IND
            mBearerData.hasUserDataHeader = (inStream.read(1) == 1);
            if (mBearerData.hasUserDataHeader) {
                Rlog.e(LOG_TAG, "Invalid FDEA WDP Header Message Identifier HEADER_IND");
                return false;
            }

            // Message Identifier RESERVED
            inStream.skip(3);

            // User Data SUBPARAMETER_ID(0x01)
            if (inStream.read(8) != 0x01) {
                Rlog.e(LOG_TAG, "Invalid FDEA WDP Header User Data SUBPARAMETER_ID");
                return false;
            }

            // User Data SUBPARAM_LEN
            int userDataLen = inStream.read(8) * 8;

            // User Data MSG_ENCODING
            mBearerData.userData.msgEncoding = inStream.read(5);
            int consumedBits = 5;
            if (mBearerData.userData.msgEncoding != UserData.ENCODING_OCTET) {
                Rlog.e(LOG_TAG, "Invalid FDEA WDP Header User Data MSG_ENCODING");
                return false;
            }

            // User Data NUM_FIELDS
            mBearerData.userData.numFields = inStream.read(8);
            consumedBits += 8;

            int remainingBits = userDataLen - consumedBits;
            int dataBits = mBearerData.userData.numFields * 8;
            dataBits = dataBits < remainingBits ? dataBits : remainingBits;
            mBearerData.userData.payload = inStream.readByteArray(dataBits);
            mUserData = mBearerData.userData.payload;
            return true;
        } catch (BitwiseInputStream.AccessException ex) {
            Rlog.e(LOG_TAG, "Fail to preprocess FDEA WAP: " + ex);
        }
        return false;
    }

    /**
     * Parses a SMS message from its BearerData stream.
     */
+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,9 @@ public final class SmsEnvelope {
    static public final int TELESERVICE_WEMT              = 0x1005;
    static public final int TELESERVICE_SCPT              = 0x1006;

    /** Carriers specific Teleservice IDs. */
    public static final int TELESERVICE_FDEA_WAP = 0xFDEA; // 65002

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