Search in sources :

Example 1 with SmsCbMessage

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

the class GsmSmsCbTest method testGetMessageBodyUcs2WithLanguageInBody.

@Test
@SmallTest
public void testGetMessageBodyUcs2WithLanguageInBody() {
    byte[] pdu = { (byte) 0xC0, (byte) 0x00, (byte) 0x00, (byte) 0x32, (byte) 0x11, (byte) 0x11, (byte) 0x78, (byte) 0x3C, (byte) 0x00, (byte) 0x41, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x55, (byte) 0x00, (byte) 0x43, (byte) 0x00, (byte) 0x53, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x6D, (byte) 0x00, (byte) 0x65, (byte) 0x00, (byte) 0x73, (byte) 0x00, (byte) 0x73, (byte) 0x00, (byte) 0x61, (byte) 0x00, (byte) 0x67, (byte) 0x00, (byte) 0x65, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x63, (byte) 0x00, (byte) 0x6F, (byte) 0x00, (byte) 0x6E, (byte) 0x00, (byte) 0x74, (byte) 0x00, (byte) 0x61, (byte) 0x00, (byte) 0x69, (byte) 0x00, (byte) 0x6E, (byte) 0x00, (byte) 0x69, (byte) 0x00, (byte) 0x6E, (byte) 0x00, (byte) 0x67, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x61, (byte) 0x00, (byte) 0x20, (byte) 0x04, (byte) 0x34, (byte) 0x00, (byte) 0x20, (byte) 0x00, (byte) 0x63, (byte) 0x00, (byte) 0x68, (byte) 0x00, (byte) 0x61, (byte) 0x00, (byte) 0x72, (byte) 0x00, (byte) 0x61, (byte) 0x00, (byte) 0x63, (byte) 0x00, (byte) 0x74, (byte) 0x00, (byte) 0x65, (byte) 0x00, (byte) 0x72, (byte) 0x00, (byte) 0x0D };
    SmsCbMessage msg = createFromPdu(pdu);
    assertEquals("Unexpected 7-bit string decoded", "A UCS2 message containing a \u0434 character", msg.getMessageBody());
    assertEquals("Unexpected language indicator decoded", "xx", msg.getLanguageCode());
}
Also used : SmsCbMessage(android.telephony.SmsCbMessage) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with SmsCbMessage

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

the class GsmSmsCbTest method testGetMessageBodyUcs2MultipageUmts.

@Test
@SmallTest
public void testGetMessageBodyUcs2MultipageUmts() {
    byte[] pdu = { (byte) 0x01, (byte) 0x00, (byte) 0x32, (byte) 0xC0, (byte) 0x00, (byte) 0x48, (byte) 0x02, (byte) 0x00, (byte) 0x41, (byte) 0x00, (byte) 0x41, (byte) 0x00, (byte) 0x41, (byte) 0x00, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x06, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x0D, (byte) 0x06 };
    SmsCbMessage msg = createFromPdu(pdu);
    assertEquals("Unexpected multipage UCS2 string decoded", "AAABBB", 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 3 with SmsCbMessage

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

the class GsmSmsCbTest method testGetMessageBody7BitWithLanguageInBodyUmts.

@Test
@SmallTest
public void testGetMessageBody7BitWithLanguageInBodyUmts() {
    byte[] pdu = { (byte) 0x01, (byte) 0x00, (byte) 0x32, (byte) 0xC0, (byte) 0x00, (byte) 0x10, (byte) 0x01, (byte) 0x73, (byte) 0x7B, (byte) 0x23, (byte) 0x08, (byte) 0x3A, (byte) 0x4E, (byte) 0x9B, (byte) 0x20, (byte) 0x72, (byte) 0xD9, (byte) 0x1C, (byte) 0xAE, (byte) 0xB3, (byte) 0xE9, (byte) 0xA0, (byte) 0x30, (byte) 0x1B, (byte) 0x8E, (byte) 0x0E, (byte) 0x8B, (byte) 0xCB, (byte) 0x74, (byte) 0x50, (byte) 0xBB, (byte) 0x3C, (byte) 0x9F, (byte) 0x87, (byte) 0xCF, (byte) 0x65, (byte) 0xD0, (byte) 0x3D, (byte) 0x4D, (byte) 0x47, (byte) 0x83, (byte) 0xC6, (byte) 0x61, (byte) 0xB9, (byte) 0x3C, (byte) 0x1D, (byte) 0x3E, (byte) 0x97, (byte) 0x41, (byte) 0xF2, (byte) 0x32, (byte) 0xBD, (byte) 0x2E, (byte) 0x77, (byte) 0x83, (byte) 0xE0, (byte) 0x61, (byte) 0x32, (byte) 0x39, (byte) 0xED, (byte) 0x3E, (byte) 0x37, (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) 0x37 };
    SmsCbMessage msg = createFromPdu(pdu);
    assertEquals("Unexpected 7-bit string decoded", "A GSM default alphabet message with carriage return padding", msg.getMessageBody());
    assertEquals("Unexpected language indicator decoded", "sv", msg.getLanguageCode());
}
Also used : SmsCbMessage(android.telephony.SmsCbMessage) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 4 with SmsCbMessage

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

the class CdmaSmsCbTest method testCmasUnsupportedCharSet.

// VZW requirement is to discard message with unsupported charset. Verify that we return null
// for this unsupported character set.
@FlakyTest
@Ignore
@Test
@SmallTest
public void testCmasUnsupportedCharSet() throws Exception {
    SmsMessage msg = createCmasSmsMessage(SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT, 12345, BearerData.PRIORITY_EMERGENCY, BearerData.LANGUAGE_ENGLISH, 0x1F, EXTREME_ALERT, -1, -1, -1, -1, -1);
    SmsCbMessage cbMessage = msg.parseBroadcastSms();
    assertNull("expected null for unsupported charset", cbMessage);
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) FlakyTest(android.support.test.filters.FlakyTest) Ignore(org.junit.Ignore) SmallTest(android.test.suitebuilder.annotation.SmallTest) FlakyTest(android.support.test.filters.FlakyTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 5 with SmsCbMessage

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

the class CdmaSmsCbTest method testDecodeRawBearerData.

// Test case for CMAS test message received on the Sprint network.
@Test
@SmallTest
public void testDecodeRawBearerData() throws Exception {
    CdmaSmsMessage cdmaSmsMessage = createBroadcastParcel(SmsEnvelope.SERVICE_CATEGORY_CMAS_TEST_MESSAGE);
    SmsMessage msg = createMessageFromParcel(cdmaSmsMessage, CMAS_TEST_BEARER_DATA);
    SmsCbMessage cbMessage = msg.parseBroadcastSms();
    assertNotNull("expected non-null for bearer data", cbMessage);
    assertEquals("geoScope", cbMessage.getGeographicalScope(), 1);
    assertEquals("serialNumber", cbMessage.getSerialNumber(), 51072);
    assertEquals("serviceCategory", cbMessage.getServiceCategory(), SmsEnvelope.SERVICE_CATEGORY_CMAS_TEST_MESSAGE);
    assertEquals("payload", cbMessage.getMessageBody(), "This is a test of the Commercial Mobile Alert System. This is only a test.");
    SmsCbCmasInfo cmasInfo = cbMessage.getCmasWarningInfo();
    assertNotNull("expected non-null for CMAS info", cmasInfo);
    assertEquals("category", cmasInfo.getCategory(), SmsCbCmasInfo.CMAS_CATEGORY_OTHER);
    assertEquals("responseType", cmasInfo.getResponseType(), SmsCbCmasInfo.CMAS_RESPONSE_TYPE_NONE);
    assertEquals("severity", cmasInfo.getSeverity(), SmsCbCmasInfo.CMAS_SEVERITY_SEVERE);
    assertEquals("urgency", cmasInfo.getUrgency(), SmsCbCmasInfo.CMAS_URGENCY_EXPECTED);
    assertEquals("certainty", cmasInfo.getCertainty(), SmsCbCmasInfo.CMAS_CERTAINTY_LIKELY);
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) SmsCbCmasInfo(android.telephony.SmsCbCmasInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest) FlakyTest(android.support.test.filters.FlakyTest) 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 (android.support.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