Search in sources :

Example 31 with SmsCbMessage

use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.

the class GsmSmsCbTest method testGetMessageIdentifierUmts.

@Test
@SmallTest
public void testGetMessageIdentifierUmts() {
    byte[] pdu = { (byte) 0x01, (byte) 0x30, (byte) 0x39, (byte) 0x2A, (byte) 0xA5, (byte) 0x40, (byte) 0x01, (byte) 0x41, (byte) 0xD0, (byte) 0x71, (byte) 0xDA, (byte) 0x04, (byte) 0x91, (byte) 0xCB, (byte) 0xE6, (byte) 0x70, (byte) 0x9D, (byte) 0x4D, (byte) 0x07, (byte) 0x85, (byte) 0xD9, (byte) 0x70, (byte) 0x74, (byte) 0x58, (byte) 0x5C, (byte) 0xA6, (byte) 0x83, (byte) 0xDA, (byte) 0xE5, (byte) 0xF9, (byte) 0x3C, (byte) 0x7C, (byte) 0x2E, (byte) 0x83, (byte) 0xEE, (byte) 0x69, (byte) 0x3A, (byte) 0x1A, (byte) 0x34, (byte) 0x0E, (byte) 0xCB, (byte) 0xE5, (byte) 0xE9, (byte) 0xF0, (byte) 0xB9, (byte) 0x0C, (byte) 0x92, (byte) 0x97, (byte) 0xE9, (byte) 0x75, (byte) 0xB9, (byte) 0x1B, (byte) 0x04, (byte) 0x0F, (byte) 0x93, (byte) 0xC9, (byte) 0x69, (byte) 0xF7, (byte) 0xB9, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x00, (byte) 0x34 };
    SmsCbMessage msg = createFromPdu(pdu);
    assertEquals("Unexpected message identifier decoded", 12345, msg.getServiceCategory());
}
Also used : SmsCbMessage(android.telephony.SmsCbMessage) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 32 with SmsCbMessage

use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.

the class GsmSmsCbTest method testGetMessageBody7Bit.

@Test
@SmallTest
public void testGetMessageBody7Bit() {
    byte[] pdu = { (byte) 0xC0, (byte) 0x00, (byte) 0x00, (byte) 0x32, (byte) 0x40, (byte) 0x11, (byte) 0x41, (byte) 0xD0, (byte) 0x71, (byte) 0xDA, (byte) 0x04, (byte) 0x91, (byte) 0xCB, (byte) 0xE6, (byte) 0x70, (byte) 0x9D, (byte) 0x4D, (byte) 0x07, (byte) 0x85, (byte) 0xD9, (byte) 0x70, (byte) 0x74, (byte) 0x58, (byte) 0x5C, (byte) 0xA6, (byte) 0x83, (byte) 0xDA, (byte) 0xE5, (byte) 0xF9, (byte) 0x3C, (byte) 0x7C, (byte) 0x2E, (byte) 0x83, (byte) 0xEE, (byte) 0x69, (byte) 0x3A, (byte) 0x1A, (byte) 0x34, (byte) 0x0E, (byte) 0xCB, (byte) 0xE5, (byte) 0xE9, (byte) 0xF0, (byte) 0xB9, (byte) 0x0C, (byte) 0x92, (byte) 0x97, (byte) 0xE9, (byte) 0x75, (byte) 0xB9, (byte) 0x1B, (byte) 0x04, (byte) 0x0F, (byte) 0x93, (byte) 0xC9, (byte) 0x69, (byte) 0xF7, (byte) 0xB9, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x00 };
    SmsCbMessage msg = createFromPdu(pdu);
    assertEquals("Unexpected 7-bit string decoded", "A GSM default alphabet message with carriage return padding", msg.getMessageBody());
}
Also used : SmsCbMessage(android.telephony.SmsCbMessage) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 33 with SmsCbMessage

use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.

the class GsmSmsCbTest method testGetMessageBody7BitUmts.

@Test
@SmallTest
public void testGetMessageBody7BitUmts() {
    byte[] pdu = { (byte) 0x01, (byte) 0x00, (byte) 0x32, (byte) 0xC0, (byte) 0x00, (byte) 0x40, (byte) 0x01, (byte) 0x41, (byte) 0xD0, (byte) 0x71, (byte) 0xDA, (byte) 0x04, (byte) 0x91, (byte) 0xCB, (byte) 0xE6, (byte) 0x70, (byte) 0x9D, (byte) 0x4D, (byte) 0x07, (byte) 0x85, (byte) 0xD9, (byte) 0x70, (byte) 0x74, (byte) 0x58, (byte) 0x5C, (byte) 0xA6, (byte) 0x83, (byte) 0xDA, (byte) 0xE5, (byte) 0xF9, (byte) 0x3C, (byte) 0x7C, (byte) 0x2E, (byte) 0x83, (byte) 0xEE, (byte) 0x69, (byte) 0x3A, (byte) 0x1A, (byte) 0x34, (byte) 0x0E, (byte) 0xCB, (byte) 0xE5, (byte) 0xE9, (byte) 0xF0, (byte) 0xB9, (byte) 0x0C, (byte) 0x92, (byte) 0x97, (byte) 0xE9, (byte) 0x75, (byte) 0xB9, (byte) 0x1B, (byte) 0x04, (byte) 0x0F, (byte) 0x93, (byte) 0xC9, (byte) 0x69, (byte) 0xF7, (byte) 0xB9, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x68, (byte) 0x34, (byte) 0x1A, (byte) 0x8D, (byte) 0x46, (byte) 0xA3, (byte) 0xD1, (byte) 0x00, (byte) 0x34 };
    SmsCbMessage msg = createFromPdu(pdu);
    assertEquals("Unexpected 7-bit string decoded", "A GSM default alphabet message with carriage return padding", msg.getMessageBody());
}
Also used : SmsCbMessage(android.telephony.SmsCbMessage) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 34 with SmsCbMessage

use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.

the class CdmaInboundSmsHandler method dispatchMessageRadioSpecific.

/**
 * Process Cell Broadcast, Voicemail Notification, and other 3GPP/3GPP2-specific messages.
 * @param smsb the SmsMessageBase object from the RIL
 * @return true if the message was handled here; false to continue processing
 */
@Override
protected int dispatchMessageRadioSpecific(SmsMessageBase smsb) {
    SmsMessage sms = (SmsMessage) smsb;
    boolean isBroadcastType = (SmsEnvelope.MESSAGE_TYPE_BROADCAST == sms.getMessageType());
    // Handle CMAS emergency broadcast messages.
    if (isBroadcastType) {
        log("Broadcast type message");
        SmsCbMessage cbMessage = sms.parseBroadcastSms();
        if (cbMessage != null) {
            mCellBroadcastHandler.dispatchSmsMessage(cbMessage);
        } else {
            loge("error trying to parse broadcast SMS");
        }
        return Intents.RESULT_SMS_HANDLED;
    }
    // Initialize fingerprint field, and see if we have a network duplicate SMS.
    mLastDispatchedSmsFingerprint = sms.getIncomingSmsFingerprint();
    if (mLastAcknowledgedSmsFingerprint != null && Arrays.equals(mLastDispatchedSmsFingerprint, mLastAcknowledgedSmsFingerprint)) {
        return Intents.RESULT_SMS_HANDLED;
    }
    // Decode BD stream and set sms variables.
    sms.parseSms();
    int teleService = sms.getTeleService();
    switch(teleService) {
        case SmsEnvelope.TELESERVICE_VMN:
        case SmsEnvelope.TELESERVICE_MWI:
            // handle voicemail indication
            handleVoicemailTeleservice(sms);
            return Intents.RESULT_SMS_HANDLED;
        case SmsEnvelope.TELESERVICE_WMT:
        case SmsEnvelope.TELESERVICE_WEMT:
            if (sms.isStatusReportMessage()) {
                mSmsDispatcher.sendStatusReportMessage(sms);
                return Intents.RESULT_SMS_HANDLED;
            }
            break;
        case SmsEnvelope.TELESERVICE_SCPT:
            mServiceCategoryProgramHandler.dispatchSmsMessage(sms);
            return Intents.RESULT_SMS_HANDLED;
        case SmsEnvelope.TELESERVICE_WAP:
            // handled below, after storage check
            break;
        default:
            loge("unsupported teleservice 0x" + Integer.toHexString(teleService));
            return Intents.RESULT_SMS_UNSUPPORTED;
    }
    if (!mStorageMonitor.isStorageAvailable() && sms.getMessageClass() != SmsConstants.MessageClass.CLASS_0) {
        // messages, which we represent as CLASS_0.)
        return Intents.RESULT_SMS_OUT_OF_MEMORY;
    }
    if (SmsEnvelope.TELESERVICE_WAP == teleService) {
        return processCdmaWapPdu(sms.getUserData(), sms.mMessageRef, sms.getOriginatingAddress(), sms.getDisplayOriginatingAddress(), sms.getTimestampMillis());
    }
    return dispatchNormalMessage(smsb);
}
Also used : SmsCbMessage(android.telephony.SmsCbMessage)

Example 35 with SmsCbMessage

use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsCbTest method testNonEmergencyBroadcastIs91Extended.

@Test
@SmallTest
public void testNonEmergencyBroadcastIs91Extended() throws Exception {
    // IS-91 doesn't support language or priority subparameters, max 14 chars text
    SmsMessage msg = createBroadcastSmsMessage(987, 654, -1, -1, UserData.ENCODING_IS91_EXTENDED_PROTOCOL, IS91_TEXT);
    SmsCbMessage cbMessage = msg.parseBroadcastSms("", 0, 1);
    verifyCbValues(cbMessage);
    assertEquals(987, cbMessage.getServiceCategory());
    assertEquals(654, cbMessage.getSerialNumber());
    assertEquals(SmsCbMessage.MESSAGE_PRIORITY_NORMAL, cbMessage.getMessagePriority());
    assertEquals(null, cbMessage.getLanguageCode());
    assertEquals(IS91_TEXT, cbMessage.getMessageBody());
    assertEquals(false, cbMessage.isEmergencyMessage());
    assertEquals(false, cbMessage.isCmasMessage());
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SmsCbMessage (android.telephony.SmsCbMessage)39 SmallTest (android.test.suitebuilder.annotation.SmallTest)35 Test (org.junit.Test)35 CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)10 FlakyTest (androidx.test.filters.FlakyTest)8 SmsCbCmasInfo (android.telephony.SmsCbCmasInfo)4 Random (java.util.Random)3 BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)1 Ignore (org.junit.Ignore)1