Search in sources :

Example 6 with SmsHeader

use of com.android.internal.telephony.SmsHeader in project android_frameworks_opt_telephony by LineageOS.

the class GsmInboundSmsHandler method dispatchMessageRadioSpecific.

/**
 * Handle type zero, SMS-PP data download, and 3GPP/CPHS MWI type SMS. Normal SMS messages
 * are handled by {@link #dispatchNormalMessage} in parent class.
 *
 * @param smsb the SmsMessageBase object from the RIL
 * @return a result code from {@link android.provider.Telephony.Sms.Intents},
 * or {@link Activity#RESULT_OK} for delayed acknowledgment to SMSC
 */
@Override
protected int dispatchMessageRadioSpecific(SmsMessageBase smsb) {
    SmsMessage sms = (SmsMessage) smsb;
    if (sms.isTypeZero()) {
        // Some carriers will send visual voicemail SMS as type zero.
        int destPort = -1;
        SmsHeader smsHeader = sms.getUserDataHeader();
        if (smsHeader != null && smsHeader.portAddrs != null) {
            // The message was sent to a port.
            destPort = smsHeader.portAddrs.destPort;
        }
        VisualVoicemailSmsFilter.filter(mContext, new byte[][] { sms.getPdu() }, SmsConstants.FORMAT_3GPP, destPort, mPhone.getSubId());
        // As per 3GPP TS 23.040 9.2.3.9, Type Zero messages should not be
        // Displayed/Stored/Notified. They should only be acknowledged.
        log("Received short message type 0, Don't display or store it. Send Ack");
        addSmsTypeZeroToMetrics();
        return Intents.RESULT_SMS_HANDLED;
    }
    // Send SMS-PP data download messages to UICC. See 3GPP TS 31.111 section 7.1.1.
    if (sms.isUsimDataDownload()) {
        UsimServiceTable ust = mPhone.getUsimServiceTable();
        return mDataDownloadHandler.handleUsimDataDownload(ust, sms);
    }
    boolean handled = false;
    if (sms.isMWISetMessage()) {
        updateMessageWaitingIndicator(sms.getNumOfVoicemails());
        handled = sms.isMwiDontStore();
        if (DBG)
            log("Received voice mail indicator set SMS shouldStore=" + !handled);
    } else if (sms.isMWIClearMessage()) {
        updateMessageWaitingIndicator(0);
        handled = sms.isMwiDontStore();
        if (DBG)
            log("Received voice mail indicator clear SMS shouldStore=" + !handled);
    }
    if (handled) {
        addVoicemailSmsToMetrics();
        return Intents.RESULT_SMS_HANDLED;
    }
    if (!mStorageMonitor.isStorageAvailable() && sms.getMessageClass() != SmsConstants.MessageClass.CLASS_0) {
        // (See TS 23.038 for a description of class 0 messages.)
        return Intents.RESULT_SMS_OUT_OF_MEMORY;
    }
    return dispatchNormalMessage(smsb);
}
Also used : SmsHeader(com.android.internal.telephony.SmsHeader) UsimServiceTable(com.android.internal.telephony.uicc.UsimServiceTable)

Example 7 with SmsHeader

use of com.android.internal.telephony.SmsHeader in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsTest method testUserDataHeaderWithEightCharMsg.

@SmallTest
public void testUserDataHeaderWithEightCharMsg() throws Exception {
    SmsHeader smsHeader = getConcatUserDataHeader(2, 2);
    encodeDecodeAssertEquals("01234567", smsHeader, -1);
    SmsHeader smsHeader2 = getOddLengthUserDataHeader();
    encodeDecodeAssertEquals("01234567", smsHeader2, -1);
}
Also used : SmsHeader(com.android.internal.telephony.SmsHeader) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 8 with SmsHeader

use of com.android.internal.telephony.SmsHeader in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsTest method testUserDataHeaderConcatRefFeedback.

@SmallTest
public void testUserDataHeaderConcatRefFeedback() throws Exception {
    BearerData bearerData = new BearerData();
    bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
    bearerData.messageId = 55;
    SmsHeader.ConcatRef concatRef = new SmsHeader.ConcatRef();
    concatRef.refNumber = 0xEE;
    concatRef.msgCount = 2;
    concatRef.seqNumber = 2;
    concatRef.isEightBits = true;
    SmsHeader smsHeader = new SmsHeader();
    smsHeader.concatRef = concatRef;
    byte[] encodedHeader = SmsHeader.toByteArray(smsHeader);
    SmsHeader decodedHeader = SmsHeader.fromByteArray(encodedHeader);
    assertEquals(decodedHeader.concatRef.refNumber, concatRef.refNumber);
    assertEquals(decodedHeader.concatRef.msgCount, concatRef.msgCount);
    assertEquals(decodedHeader.concatRef.seqNumber, concatRef.seqNumber);
    assertEquals(decodedHeader.concatRef.isEightBits, concatRef.isEightBits);
    assertEquals(decodedHeader.portAddrs, null);
    UserData userData = new UserData();
    userData.payloadStr = "User Data Header (UDH) feedback test";
    userData.userDataHeader = smsHeader;
    bearerData.userData = userData;
    byte[] encodedSms = BearerData.encode(bearerData);
    BearerData revBearerData = BearerData.decode(encodedSms);
    decodedHeader = revBearerData.userData.userDataHeader;
    assertEquals(decodedHeader.concatRef.refNumber, concatRef.refNumber);
    assertEquals(decodedHeader.concatRef.msgCount, concatRef.msgCount);
    assertEquals(decodedHeader.concatRef.seqNumber, concatRef.seqNumber);
    assertEquals(decodedHeader.concatRef.isEightBits, concatRef.isEightBits);
    assertEquals(decodedHeader.portAddrs, null);
}
Also used : SmsHeader(com.android.internal.telephony.SmsHeader) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 9 with SmsHeader

use of com.android.internal.telephony.SmsHeader in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsTest method testUserDataHeaderMixedFeedback.

@SmallTest
public void testUserDataHeaderMixedFeedback() throws Exception {
    BearerData bearerData = new BearerData();
    bearerData.messageType = BearerData.MESSAGE_TYPE_DELIVER;
    bearerData.messageId = 42;
    SmsHeader.ConcatRef concatRef = new SmsHeader.ConcatRef();
    concatRef.refNumber = 0x34;
    concatRef.msgCount = 5;
    concatRef.seqNumber = 2;
    concatRef.isEightBits = false;
    SmsHeader.PortAddrs portAddrs = new SmsHeader.PortAddrs();
    portAddrs.destPort = 88;
    portAddrs.origPort = 66;
    portAddrs.areEightBits = false;
    SmsHeader smsHeader = new SmsHeader();
    smsHeader.concatRef = concatRef;
    smsHeader.portAddrs = portAddrs;
    byte[] encodedHeader = SmsHeader.toByteArray(smsHeader);
    SmsHeader decodedHeader = SmsHeader.fromByteArray(encodedHeader);
    assertEquals(decodedHeader.concatRef.refNumber, concatRef.refNumber);
    assertEquals(decodedHeader.concatRef.msgCount, concatRef.msgCount);
    assertEquals(decodedHeader.concatRef.seqNumber, concatRef.seqNumber);
    assertEquals(decodedHeader.concatRef.isEightBits, concatRef.isEightBits);
    assertEquals(decodedHeader.portAddrs.destPort, portAddrs.destPort);
    assertEquals(decodedHeader.portAddrs.origPort, portAddrs.origPort);
    assertEquals(decodedHeader.portAddrs.areEightBits, portAddrs.areEightBits);
    UserData userData = new UserData();
    userData.payloadStr = "User Data Header (UDH) feedback test";
    userData.userDataHeader = smsHeader;
    bearerData.userData = userData;
    byte[] encodedSms = BearerData.encode(bearerData);
    BearerData revBearerData = BearerData.decode(encodedSms);
    decodedHeader = revBearerData.userData.userDataHeader;
    assertEquals(decodedHeader.concatRef.refNumber, concatRef.refNumber);
    assertEquals(decodedHeader.concatRef.msgCount, concatRef.msgCount);
    assertEquals(decodedHeader.concatRef.seqNumber, concatRef.seqNumber);
    assertEquals(decodedHeader.concatRef.isEightBits, concatRef.isEightBits);
    assertEquals(decodedHeader.portAddrs.destPort, portAddrs.destPort);
    assertEquals(decodedHeader.portAddrs.origPort, portAddrs.origPort);
    assertEquals(decodedHeader.portAddrs.areEightBits, portAddrs.areEightBits);
}
Also used : SmsHeader(com.android.internal.telephony.SmsHeader) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 10 with SmsHeader

use of com.android.internal.telephony.SmsHeader in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsTest method getOddLengthUserDataHeader.

// Return a user data header of odd length to verify correct UTF-16 header padding
private static SmsHeader getOddLengthUserDataHeader() {
    SmsHeader smsHeader = new SmsHeader();
    SmsHeader.MiscElt miscElt = new SmsHeader.MiscElt();
    // reserved for future use; ignored on decode
    miscElt.id = 0x27;
    miscElt.data = new byte[] { 0x12, 0x34 };
    smsHeader.miscEltList.add(miscElt);
    return smsHeader;
}
Also used : SmsHeader(com.android.internal.telephony.SmsHeader)

Aggregations

SmsHeader (com.android.internal.telephony.SmsHeader)10 SmallTest (android.test.suitebuilder.annotation.SmallTest)6 TextEncodingDetails (com.android.internal.telephony.GsmAlphabet.TextEncodingDetails)1 UserData (com.android.internal.telephony.cdma.sms.UserData)1 UsimServiceTable (com.android.internal.telephony.uicc.UsimServiceTable)1