use of android.hardware.radio.V1_0.CdmaSmsMessage 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("", 0, 1);
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);
}
use of android.hardware.radio.V1_0.CdmaSmsMessage in project android_frameworks_opt_telephony by LineageOS.
the class RadioIndication method cdmaNewSms.
public void cdmaNewSms(int indicationType, CdmaSmsMessage msg) {
mRil.processIndication(indicationType);
if (RIL.RILJ_LOGD)
mRil.unsljLog(RIL_UNSOL_RESPONSE_CDMA_NEW_SMS);
// todo: conversion from CdmaSmsMessage to SmsMessage should be contained in this class so
// that usage of auto-generated HAL classes is limited to this file
SmsMessage sms = SmsMessageConverter.newSmsMessageFromCdmaSmsMessage(msg);
if (mRil.mCdmaSmsRegistrant != null) {
mRil.mCdmaSmsRegistrant.notifyRegistrant(new AsyncResult(null, sms, null));
}
}
use of android.hardware.radio.V1_0.CdmaSmsMessage in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testSendRetryImsCdmaSms.
@FlakyTest
@Test
public void testSendRetryImsCdmaSms() throws Exception {
CdmaSmsMessage cdmaMsg = new CdmaSmsMessage();
ImsSmsMessage firstMsg = new ImsSmsMessage();
firstMsg.tech = RILConstants.CDMA_PHONE;
firstMsg.retry = false;
firstMsg.messageRef = 0;
firstMsg.cdmaMessage.add(cdmaMsg);
ImsSmsMessage retryMsg = new ImsSmsMessage();
retryMsg.tech = RILConstants.CDMA_PHONE;
retryMsg.retry = true;
retryMsg.messageRef = 0;
retryMsg.cdmaMessage.add(cdmaMsg);
int maxRetryCount = 3;
int firstTransmission = 0;
byte[] pdu = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
for (int i = 0; i <= maxRetryCount; i++) {
mRILUnderTest.sendImsCdmaSms(pdu, i, 0, obtainMessage());
if (i == firstTransmission) {
verify(mRadioProxy, times(1)).sendImsSms(mSerialNumberCaptor.capture(), eq(firstMsg));
verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_IMS_SEND_SMS);
} else {
verify(mRadioProxy, times(i)).sendImsSms(mSerialNumberCaptor.capture(), eq(retryMsg));
verifyRILResponse(mRILUnderTest, mSerialNumberCaptor.getValue(), RIL_REQUEST_IMS_SEND_SMS);
}
}
}
use of android.hardware.radio.V1_0.CdmaSmsMessage in project android_frameworks_opt_telephony by LineageOS.
the class RIL method sendImsCdmaSms.
@Override
public void sendImsCdmaSms(byte[] pdu, int retry, int messageRef, Message result) {
IRadio radioProxy = getRadioProxy(result);
if (radioProxy != null) {
RILRequest rr = obtainRequest(RIL_REQUEST_IMS_SEND_SMS, result, mRILDefaultWorkSource);
// Do not log function args for privacy
if (RILJ_LOGD)
riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
ImsSmsMessage msg = new ImsSmsMessage();
msg.tech = RILConstants.CDMA_PHONE;
msg.retry = (byte) retry >= 1 ? true : false;
msg.messageRef = messageRef;
CdmaSmsMessage cdmaMsg = new CdmaSmsMessage();
constructCdmaSendSmsRilRequest(cdmaMsg, pdu);
msg.cdmaMessage.add(cdmaMsg);
try {
radioProxy.sendImsSms(rr.mSerial, msg);
mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_IMS, SmsSession.Event.Format.SMS_FORMAT_3GPP2);
} catch (RemoteException | RuntimeException e) {
handleRadioProxyExceptionForRR(rr, "sendImsCdmaSms", e);
}
}
}
use of android.hardware.radio.V1_0.CdmaSmsMessage in project android_frameworks_opt_telephony by LineageOS.
the class SmsMessageConverter method newCdmaSmsMessageFromRil.
/**
* Create a "raw" CDMA SmsMessage from a Parcel that was forged in ril.cpp.
* Note: Only primitive fields are set.
*/
public static SmsMessage newCdmaSmsMessageFromRil(CdmaSmsMessage cdmaSmsMessage) {
// Note: Parcel.readByte actually reads one Int and masks to byte
SmsEnvelope env = new SmsEnvelope();
CdmaSmsAddress addr = new CdmaSmsAddress();
CdmaSmsSubaddress subaddr = new CdmaSmsSubaddress();
byte[] data;
byte count;
int countInt;
int addressDigitMode;
// currently not supported by the modem-lib: env.mMessageType
env.teleService = cdmaSmsMessage.teleserviceId;
if (cdmaSmsMessage.isServicePresent) {
env.messageType = SmsEnvelope.MESSAGE_TYPE_BROADCAST;
} else {
if (SmsEnvelope.TELESERVICE_NOT_SET == env.teleService) {
// assume type ACK
env.messageType = SmsEnvelope.MESSAGE_TYPE_ACKNOWLEDGE;
} else {
env.messageType = SmsEnvelope.MESSAGE_TYPE_POINT_TO_POINT;
}
}
env.serviceCategory = cdmaSmsMessage.serviceCategory;
// address
addressDigitMode = cdmaSmsMessage.address.digitMode;
addr.digitMode = (byte) (0xFF & addressDigitMode);
addr.numberMode = (byte) (0xFF & cdmaSmsMessage.address.numberMode);
addr.ton = cdmaSmsMessage.address.numberType;
addr.numberPlan = (byte) (0xFF & cdmaSmsMessage.address.numberPlan);
count = (byte) cdmaSmsMessage.address.digits.size();
addr.numberOfDigits = count;
data = new byte[count];
for (int index = 0; index < count; index++) {
data[index] = cdmaSmsMessage.address.digits.get(index);
// convert the value if it is 4-bit DTMF to 8 bit
if (addressDigitMode == CdmaSmsAddress.DIGIT_MODE_4BIT_DTMF) {
data[index] = SmsMessage.convertDtmfToAscii(data[index]);
}
}
addr.origBytes = data;
subaddr.type = cdmaSmsMessage.subAddress.subaddressType;
subaddr.odd = (byte) (cdmaSmsMessage.subAddress.odd ? 1 : 0);
count = (byte) cdmaSmsMessage.subAddress.digits.size();
if (count < 0) {
count = 0;
}
// p_cur->sSubAddress.digits[digitCount] :
data = new byte[count];
for (int index = 0; index < count; ++index) {
data[index] = cdmaSmsMessage.subAddress.digits.get(index);
}
subaddr.origBytes = data;
/* currently not supported by the modem-lib:
env.bearerReply
env.replySeqNo
env.errorClass
env.causeCode
*/
// bearer data
countInt = cdmaSmsMessage.bearerData.size();
if (countInt < 0) {
countInt = 0;
}
data = new byte[countInt];
for (int index = 0; index < countInt; index++) {
data[index] = cdmaSmsMessage.bearerData.get(index);
}
// BD gets further decoded when accessed in SMSDispatcher
env.bearerData = data;
// link the the filled objects to the SMS
env.origAddress = addr;
env.origSubaddress = subaddr;
SmsMessage msg = new SmsMessage(addr, env);
return msg;
}
Aggregations