Search in sources :

Example 1 with CdmaSmsCbProgramData

use of android.telephony.cdma.CdmaSmsCbProgramData in project android_frameworks_opt_telephony by LineageOS.

the class CdmaServiceCategoryProgramHandler method handleServiceCategoryProgramData.

/**
 * Send SCPD request to CellBroadcastReceiver as an ordered broadcast.
 * @param sms the CDMA SmsMessage containing the SCPD request
 * @return true if an ordered broadcast was sent; false on failure
 */
private boolean handleServiceCategoryProgramData(SmsMessage sms) {
    ArrayList<CdmaSmsCbProgramData> programDataList = sms.getSmsCbProgramData();
    if (programDataList == null) {
        loge("handleServiceCategoryProgramData: program data list is null!");
        return false;
    }
    Intent intent = new Intent(Intents.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED_ACTION);
    intent.setPackage(mContext.getResources().getString(com.android.internal.R.string.config_defaultCellBroadcastReceiverPkg));
    intent.putExtra("sender", sms.getOriginatingAddress());
    intent.putParcelableArrayListExtra("program_data", programDataList);
    SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
    mContext.sendOrderedBroadcast(intent, Manifest.permission.RECEIVE_SMS, AppOpsManager.OP_RECEIVE_SMS, mScpResultsReceiver, getHandler(), Activity.RESULT_OK, null, null);
    return true;
}
Also used : Intent(android.content.Intent) CdmaSmsCbProgramData(android.telephony.cdma.CdmaSmsCbProgramData)

Example 2 with CdmaSmsCbProgramData

use of android.telephony.cdma.CdmaSmsCbProgramData in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsCbTest method testServiceCategoryProgramDataAddCategory.

@Test
@SmallTest
public void testServiceCategoryProgramDataAddCategory() throws Exception {
    CdmaSmsMessage cdmaSmsMessage = createServiceCategoryProgramDataParcel();
    BitwiseOutputStream bos = createBearerDataStream(123, -1, -1);
    int categoryNameLength = CAT_EXTREME_THREAT.length();
    int subparamLengthBits = (53 + (categoryNameLength * 7));
    int subparamLengthBytes = (subparamLengthBits + 7) / 8;
    int subparamPadBits = (subparamLengthBytes * 8) - subparamLengthBits;
    bos.write(8, SUBPARAM_SERVICE_CATEGORY_PROGRAM_DATA);
    bos.write(8, subparamLengthBytes);
    bos.write(5, UserData.ENCODING_7BIT_ASCII);
    bos.write(4, CdmaSmsCbProgramData.OPERATION_ADD_CATEGORY);
    bos.write(8, (SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT >>> 8));
    bos.write(8, (SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT & 0xff));
    bos.write(8, BearerData.LANGUAGE_ENGLISH);
    // max messages
    bos.write(8, 100);
    bos.write(4, CdmaSmsCbProgramData.ALERT_OPTION_DEFAULT_ALERT);
    bos.write(8, categoryNameLength);
    for (int i = 0; i < categoryNameLength; i++) {
        bos.write(7, CAT_EXTREME_THREAT.charAt(i));
    }
    bos.write(subparamPadBits, 0);
    SmsMessage msg = createMessageFromParcel(cdmaSmsMessage, bos.toByteArray());
    assertNotNull(msg);
    msg.parseSms();
    List<CdmaSmsCbProgramData> programDataList = msg.getSmsCbProgramData();
    assertNotNull(programDataList);
    assertEquals(1, programDataList.size());
    CdmaSmsCbProgramData programData = programDataList.get(0);
    assertEquals(CdmaSmsCbProgramData.OPERATION_ADD_CATEGORY, programData.getOperation());
    assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_EXTREME_THREAT, programData.getCategory());
    assertEquals(CAT_EXTREME_THREAT, programData.getCategoryName());
    assertEquals(BearerData.LANGUAGE_ENGLISH, programData.getLanguage());
    assertEquals(100, programData.getMaxMessages());
    assertEquals(CdmaSmsCbProgramData.ALERT_OPTION_DEFAULT_ALERT, programData.getAlertOption());
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) CdmaSmsCbProgramData(android.telephony.cdma.CdmaSmsCbProgramData) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 3 with CdmaSmsCbProgramData

use of android.telephony.cdma.CdmaSmsCbProgramData in project android_frameworks_opt_telephony by LineageOS.

the class CdmaSmsCbTest method testServiceCategoryProgramDataDeleteTwoCategories.

@Test
@SmallTest
public void testServiceCategoryProgramDataDeleteTwoCategories() throws Exception {
    CdmaSmsMessage cdmaSmsMessage = createServiceCategoryProgramDataParcel();
    BitwiseOutputStream bos = createBearerDataStream(456, -1, -1);
    int category1NameLength = CAT_SEVERE_THREAT.length();
    int category2NameLength = CAT_AMBER_ALERTS.length();
    int subparamLengthBits = (101 + (category1NameLength * 7) + (category2NameLength * 7));
    int subparamLengthBytes = (subparamLengthBits + 7) / 8;
    int subparamPadBits = (subparamLengthBytes * 8) - subparamLengthBits;
    bos.write(8, SUBPARAM_SERVICE_CATEGORY_PROGRAM_DATA);
    bos.write(8, subparamLengthBytes);
    bos.write(5, UserData.ENCODING_7BIT_ASCII);
    bos.write(4, CdmaSmsCbProgramData.OPERATION_DELETE_CATEGORY);
    bos.write(8, (SmsEnvelope.SERVICE_CATEGORY_CMAS_SEVERE_THREAT >>> 8));
    bos.write(8, (SmsEnvelope.SERVICE_CATEGORY_CMAS_SEVERE_THREAT & 0xff));
    bos.write(8, BearerData.LANGUAGE_ENGLISH);
    // max messages
    bos.write(8, 0);
    bos.write(4, CdmaSmsCbProgramData.ALERT_OPTION_NO_ALERT);
    bos.write(8, category1NameLength);
    for (int i = 0; i < category1NameLength; i++) {
        bos.write(7, CAT_SEVERE_THREAT.charAt(i));
    }
    bos.write(4, CdmaSmsCbProgramData.OPERATION_DELETE_CATEGORY);
    bos.write(8, (SmsEnvelope.SERVICE_CATEGORY_CMAS_CHILD_ABDUCTION_EMERGENCY >>> 8));
    bos.write(8, (SmsEnvelope.SERVICE_CATEGORY_CMAS_CHILD_ABDUCTION_EMERGENCY & 0xff));
    bos.write(8, BearerData.LANGUAGE_ENGLISH);
    // max messages
    bos.write(8, 0);
    bos.write(4, CdmaSmsCbProgramData.ALERT_OPTION_NO_ALERT);
    bos.write(8, category2NameLength);
    for (int i = 0; i < category2NameLength; i++) {
        bos.write(7, CAT_AMBER_ALERTS.charAt(i));
    }
    bos.write(subparamPadBits, 0);
    SmsMessage msg = createMessageFromParcel(cdmaSmsMessage, bos.toByteArray());
    assertNotNull(msg);
    msg.parseSms();
    List<CdmaSmsCbProgramData> programDataList = msg.getSmsCbProgramData();
    assertNotNull(programDataList);
    assertEquals(2, programDataList.size());
    CdmaSmsCbProgramData programData = programDataList.get(0);
    assertEquals(CdmaSmsCbProgramData.OPERATION_DELETE_CATEGORY, programData.getOperation());
    assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_SEVERE_THREAT, programData.getCategory());
    assertEquals(CAT_SEVERE_THREAT, programData.getCategoryName());
    assertEquals(BearerData.LANGUAGE_ENGLISH, programData.getLanguage());
    assertEquals(0, programData.getMaxMessages());
    assertEquals(CdmaSmsCbProgramData.ALERT_OPTION_NO_ALERT, programData.getAlertOption());
    programData = programDataList.get(1);
    assertEquals(CdmaSmsCbProgramData.OPERATION_DELETE_CATEGORY, programData.getOperation());
    assertEquals(SmsEnvelope.SERVICE_CATEGORY_CMAS_CHILD_ABDUCTION_EMERGENCY, programData.getCategory());
    assertEquals(CAT_AMBER_ALERTS, programData.getCategoryName());
    assertEquals(BearerData.LANGUAGE_ENGLISH, programData.getLanguage());
    assertEquals(0, programData.getMaxMessages());
    assertEquals(CdmaSmsCbProgramData.ALERT_OPTION_NO_ALERT, programData.getAlertOption());
}
Also used : CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) BitwiseOutputStream(com.android.internal.util.BitwiseOutputStream) CdmaSmsMessage(android.hardware.radio.V1_0.CdmaSmsMessage) CdmaSmsCbProgramData(android.telephony.cdma.CdmaSmsCbProgramData) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

CdmaSmsCbProgramData (android.telephony.cdma.CdmaSmsCbProgramData)3 CdmaSmsMessage (android.hardware.radio.V1_0.CdmaSmsMessage)2 SmallTest (android.test.suitebuilder.annotation.SmallTest)2 FlakyTest (androidx.test.filters.FlakyTest)2 BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)2 Test (org.junit.Test)2 Intent (android.content.Intent)1