use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsCbTest method testRandomPdus.
// Make sure we don't throw an exception if we feed random data to the PDU parser.
@Test
@SmallTest
public void testRandomPdus() {
Random r = new Random(94040);
for (int run = 0; run < 10000; run++) {
int len = r.nextInt(140);
byte[] data = new byte[len];
for (int i = 0; i < len; i++) {
data[i] = (byte) r.nextInt(256);
}
try {
// this should return a SmsCbMessage object or null for invalid data
SmsCbMessage msg = createFromPdu(data);
} catch (Exception e) {
Rlog.d(TAG, "exception thrown", e);
fail("Exception in decoder at run " + run + " length " + len + ": " + e);
}
}
}
use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsCbTest method testCreateNullPdu.
@Test
@SmallTest
public void testCreateNullPdu() {
SmsCbMessage msg = createFromPdu(null);
assertNull("createFromPdu(byte[] with null pdu should return null", msg);
}
use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsCbTest method testGetMessageBody7BitWithLanguageInBody.
@Test
@SmallTest
public void testGetMessageBody7BitWithLanguageInBody() {
byte[] pdu = { (byte) 0xC0, (byte) 0x00, (byte) 0x00, (byte) 0x32, (byte) 0x10, (byte) 0x11, (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 };
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());
}
use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsCbTest method testEtwsMessageCancel.
@Test
@SmallTest
public void testEtwsMessageCancel() {
SmsCbMessage msg = createFromPdu(etwsMessageCancel);
Rlog.d(TAG, msg.toString());
assertEquals("GS mismatch", 0, msg.getGeographicalScope());
assertEquals("serial number mismatch", 0, msg.getSerialNumber());
assertEquals("message ID mismatch", 0x1100, msg.getServiceCategory());
assertEquals("warning type mismatch", SmsCbEtwsInfo.ETWS_WARNING_TYPE_EARTHQUAKE, msg.getEtwsWarningInfo().getWarningType());
}
use of android.telephony.SmsCbMessage in project android_frameworks_opt_telephony by LineageOS.
the class GsmSmsCbTest method testCreateTooShortPdu.
@Test
@SmallTest
public void testCreateTooShortPdu() {
byte[] pdu = new byte[4];
SmsCbMessage msg = createFromPdu(pdu);
assertNull("createFromPdu(byte[] with too short pdu should return null", msg);
}
Aggregations