Search in sources :

Example 1 with SmsCbCmasInfo

use of android.telephony.SmsCbCmasInfo 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)

Example 2 with SmsCbCmasInfo

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

the class CdmaSmsCbTest method doTestCmasBroadcast.

private static void doTestCmasBroadcast(int serviceCategory, int messageClass, String body) throws Exception {
    SmsMessage msg = createCmasSmsMessage(serviceCategory, 1234, BearerData.PRIORITY_EMERGENCY, BearerData.LANGUAGE_ENGLISH, UserData.ENCODING_7BIT_ASCII, body, -1, -1, -1, -1, -1);
    SmsCbMessage cbMessage = msg.parseBroadcastSms();
    verifyCbValues(cbMessage);
    assertEquals(serviceCategory, cbMessage.getServiceCategory());
    assertEquals(1234, cbMessage.getSerialNumber());
    assertEquals(SmsCbMessage.MESSAGE_PRIORITY_EMERGENCY, cbMessage.getMessagePriority());
    assertEquals("en", cbMessage.getLanguageCode());
    assertEquals(body, cbMessage.getMessageBody());
    assertEquals(true, cbMessage.isEmergencyMessage());
    assertEquals(true, cbMessage.isCmasMessage());
    SmsCbCmasInfo cmasInfo = cbMessage.getCmasWarningInfo();
    assertEquals(messageClass, cmasInfo.getMessageClass());
    assertEquals(SmsCbCmasInfo.CMAS_CATEGORY_UNKNOWN, cmasInfo.getCategory());
    assertEquals(SmsCbCmasInfo.CMAS_RESPONSE_TYPE_UNKNOWN, cmasInfo.getResponseType());
    assertEquals(SmsCbCmasInfo.CMAS_SEVERITY_UNKNOWN, cmasInfo.getSeverity());
    assertEquals(SmsCbCmasInfo.CMAS_URGENCY_UNKNOWN, cmasInfo.getUrgency());
    assertEquals(SmsCbCmasInfo.CMAS_CERTAINTY_UNKNOWN, cmasInfo.getCertainty());
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) SmsCbCmasInfo(android.telephony.SmsCbCmasInfo)

Example 3 with SmsCbCmasInfo

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

the class CdmaSmsCbTest method testCmasNoRecordType0.

// VZW requirement is to discard message without record type 0. The framework will decode it
// and the app will discard it.
@Test
@SmallTest
public void testCmasNoRecordType0() throws Exception {
    SmsMessage msg = createCmasSmsMessage(SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT, 1234, BearerData.PRIORITY_EMERGENCY, BearerData.LANGUAGE_ENGLISH, UserData.ENCODING_7BIT_ASCII, null, -1, -1, -1, -1, -1);
    SmsCbMessage cbMessage = msg.parseBroadcastSms();
    verifyCbValues(cbMessage);
    assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_PRESIDENTIAL_LEVEL_ALERT, cbMessage.getServiceCategory());
    assertEquals(1234, cbMessage.getSerialNumber());
    assertEquals(SmsCbMessage.MESSAGE_PRIORITY_EMERGENCY, cbMessage.getMessagePriority());
    assertEquals("en", cbMessage.getLanguageCode());
    assertEquals(null, cbMessage.getMessageBody());
    assertEquals(true, cbMessage.isEmergencyMessage());
    assertEquals(true, cbMessage.isCmasMessage());
    SmsCbCmasInfo cmasInfo = cbMessage.getCmasWarningInfo();
    assertEquals(SmsCbCmasInfo.CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT, cmasInfo.getMessageClass());
    assertEquals(SmsCbCmasInfo.CMAS_CATEGORY_UNKNOWN, cmasInfo.getCategory());
    assertEquals(SmsCbCmasInfo.CMAS_RESPONSE_TYPE_UNKNOWN, cmasInfo.getResponseType());
    assertEquals(SmsCbCmasInfo.CMAS_SEVERITY_UNKNOWN, cmasInfo.getSeverity());
    assertEquals(SmsCbCmasInfo.CMAS_URGENCY_UNKNOWN, cmasInfo.getUrgency());
    assertEquals(SmsCbCmasInfo.CMAS_CERTAINTY_UNKNOWN, cmasInfo.getCertainty());
}
Also used : 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)

Example 4 with SmsCbCmasInfo

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

the class CdmaSmsCbTest method testCmasExtremeAlertType1Elements.

@Test
@SmallTest
public void testCmasExtremeAlertType1Elements() throws Exception {
    SmsMessage msg = createCmasSmsMessage(SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT, 5678, BearerData.PRIORITY_EMERGENCY, BearerData.LANGUAGE_ENGLISH, UserData.ENCODING_7BIT_ASCII, EXTREME_ALERT, SmsCbCmasInfo.CMAS_CATEGORY_ENV, SmsCbCmasInfo.CMAS_RESPONSE_TYPE_MONITOR, SmsCbCmasInfo.CMAS_SEVERITY_SEVERE, SmsCbCmasInfo.CMAS_URGENCY_EXPECTED, SmsCbCmasInfo.CMAS_CERTAINTY_LIKELY);
    SmsCbMessage cbMessage = msg.parseBroadcastSms();
    verifyCbValues(cbMessage);
    assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT, cbMessage.getServiceCategory());
    assertEquals(5678, cbMessage.getSerialNumber());
    assertEquals(SmsCbMessage.MESSAGE_PRIORITY_EMERGENCY, cbMessage.getMessagePriority());
    assertEquals("en", cbMessage.getLanguageCode());
    assertEquals(EXTREME_ALERT, cbMessage.getMessageBody());
    assertEquals(true, cbMessage.isEmergencyMessage());
    assertEquals(true, cbMessage.isCmasMessage());
    SmsCbCmasInfo cmasInfo = cbMessage.getCmasWarningInfo();
    assertEquals(SmsCbCmasInfo.CMAS_CLASS_EXTREME_THREAT, cmasInfo.getMessageClass());
    assertEquals(SmsCbCmasInfo.CMAS_CATEGORY_ENV, cmasInfo.getCategory());
    assertEquals(SmsCbCmasInfo.CMAS_RESPONSE_TYPE_MONITOR, cmasInfo.getResponseType());
    assertEquals(SmsCbCmasInfo.CMAS_SEVERITY_SEVERE, cmasInfo.getSeverity());
    assertEquals(SmsCbCmasInfo.CMAS_URGENCY_EXPECTED, cmasInfo.getUrgency());
    assertEquals(SmsCbCmasInfo.CMAS_CERTAINTY_LIKELY, cmasInfo.getCertainty());
}
Also used : 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

CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)4 SmsCbCmasInfo (android.telephony.SmsCbCmasInfo)4 SmsCbMessage (android.telephony.SmsCbMessage)4 FlakyTest (android.support.test.filters.FlakyTest)3 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 Test (org.junit.Test)3