Search in sources :

Example 1 with CdmaSmsMessage

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);
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) SmsCbMessage(android.telephony.SmsCbMessage) SmsCbCmasInfo(android.telephony.SmsCbCmasInfo) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 2 with CdmaSmsMessage

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));
    }
}
Also used : SmsMessage(android.telephony.SmsMessage) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) AsyncResult(android.os.AsyncResult)

Example 3 with CdmaSmsMessage

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);
        }
    }
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) ImsSmsMessage(android.hardware.radio.V1_0.ImsSmsMessage) FlakyTest(androidx.test.filters.FlakyTest) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 4 with CdmaSmsMessage

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);
        }
    }
}
Also used : IRadio(android.hardware.radio.V1_0.IRadio) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) ImsSmsMessage(android.hardware.radio.V1_0.ImsSmsMessage) RemoteException(android.os.RemoteException)

Example 5 with CdmaSmsMessage

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;
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) CdmaSmsSubaddress(com.android.internal.telephony.cdma.sms.CdmaSmsSubaddress) SmsEnvelope(com.android.internal.telephony.cdma.sms.SmsEnvelope) CdmaSmsAddress(com.android.internal.telephony.cdma.sms.CdmaSmsAddress)

Aggregations

CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)15 FlakyTest (androidx.test.filters.FlakyTest)6 Test (org.junit.Test)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)5 IRadio (android.hardware.radio.V1_0.IRadio)3 RemoteException (android.os.RemoteException)3 SmsCbMessage (android.telephony.SmsCbMessage)3 ImsSmsMessage (android.hardware.radio.V1_0.ImsSmsMessage)2 CdmaSmsCbProgramData (android.telephony.cdma.CdmaSmsCbProgramData)2 Random (java.util.Random)2 AsyncResult (android.os.AsyncResult)1 SmsCbCmasInfo (android.telephony.SmsCbCmasInfo)1 SmsMessage (android.telephony.SmsMessage)1 CdmaSmsAddress (com.android.internal.telephony.cdma.sms.CdmaSmsAddress)1 CdmaSmsSubaddress (com.android.internal.telephony.cdma.sms.CdmaSmsSubaddress)1 SmsEnvelope (com.android.internal.telephony.cdma.sms.SmsEnvelope)1