Search in sources :

Example 26 with EmergencyNumber

use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.

the class EmergencyNumberTest method testMergeSameNumbersInEmergencyNumberListWithDifferentSources.

public void testMergeSameNumbersInEmergencyNumberListWithDifferentSources() throws Exception {
    List<EmergencyNumber> inputNumberList = new ArrayList<>();
    EmergencyNumber num1 = new EmergencyNumber("110", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DATABASE, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
    EmergencyNumber num2 = new EmergencyNumber("110", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
    EmergencyNumber num3 = new EmergencyNumber("911", "us", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
    inputNumberList.add(num1);
    inputNumberList.add(num2);
    inputNumberList.add(num3);
    EmergencyNumber num4 = new EmergencyNumber("110", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING | EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DATABASE, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
    List<EmergencyNumber> outputNumberList = new ArrayList<>();
    outputNumberList.add(num3);
    outputNumberList.add(num4);
    Collections.sort(outputNumberList);
    EmergencyNumber.mergeSameNumbersInEmergencyNumberList(inputNumberList);
    assertEquals(outputNumberList, inputNumberList);
}
Also used : EmergencyNumber(android.telephony.emergency.EmergencyNumber) ArrayList(java.util.ArrayList)

Example 27 with EmergencyNumber

use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.

the class EmergencyNumberTrackerTest method testUsingEmergencyNumberDatabaseWheneverHal_1_4.

/**
 * In 1.4 or above HAL, we should use database number.
 */
@Test
public void testUsingEmergencyNumberDatabaseWheneverHal_1_4() {
    doReturn(new HalVersion(1, 4)).when(mPhone).getHalVersion();
    sendEmergencyNumberPrefix(mEmergencyNumberTrackerMock);
    mEmergencyNumberTrackerMock.updateEmergencyCountryIsoAllPhones("us");
    processAllMessages();
    boolean hasDatabaseNumber = false;
    for (EmergencyNumber number : mEmergencyNumberTrackerMock.getEmergencyNumberList()) {
        if (number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DATABASE)) {
            hasDatabaseNumber = true;
            break;
        }
    }
    assertTrue(hasDatabaseNumber);
}
Also used : EmergencyNumber(android.telephony.emergency.EmergencyNumber) HalVersion(com.android.internal.telephony.HalVersion) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test)

Example 28 with EmergencyNumber

use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.

the class EmergencyNumberTrackerTest method testEmergencyNumberListPrefix.

@Test
public void testEmergencyNumberListPrefix() throws Exception {
    sendEmergencyNumberListFromRadio();
    sendEmergencyNumberPrefix(mEmergencyNumberTrackerMock);
    List<EmergencyNumber> resultToVerify = mEmergencyNumberListTestSample;
    resultToVerify.add(new EmergencyNumber("123119", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN));
    resultToVerify.add(new EmergencyNumber("456119", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN));
    Collections.sort(resultToVerify);
    List<EmergencyNumber> resultFromRadio = mEmergencyNumberTrackerMock.getRadioEmergencyNumberList();
    Collections.sort(resultFromRadio);
    assertEquals(resultToVerify, resultFromRadio);
}
Also used : EmergencyNumber(android.telephony.emergency.EmergencyNumber) ArrayList(java.util.ArrayList) TelephonyTest(com.android.internal.telephony.TelephonyTest) Test(org.junit.Test)

Example 29 with EmergencyNumber

use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.

the class EmergencyNumberTrackerTest method initializeEmergencyNumberListTestSamples.

private void initializeEmergencyNumberListTestSamples() {
    EmergencyNumber emergencyNumberForTest = new EmergencyNumber("119", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN);
    mUsEmergencyNumber = new EmergencyNumber("911", "us", "", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_POLICE | EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AMBULANCE | EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DATABASE, EmergencyNumber.EMERGENCY_CALL_ROUTING_UNKNOWN);
    mEmergencyNumberListTestSample.add(emergencyNumberForTest);
}
Also used : EmergencyNumber(android.telephony.emergency.EmergencyNumber) ArrayList(java.util.ArrayList)

Aggregations

EmergencyNumber (android.telephony.emergency.EmergencyNumber)29 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)6 HalVersion (com.android.internal.telephony.HalVersion)4 TelephonyTest (com.android.internal.telephony.TelephonyTest)4 SmallTest (android.test.suitebuilder.annotation.SmallTest)3 AsyncResult (android.os.AsyncResult)2 ProtobufEccData (com.android.phone.ecc.nano.ProtobufEccData)2 EccInfo (com.android.phone.ecc.nano.ProtobufEccData.EccInfo)2 BufferedInputStream (java.io.BufferedInputStream)2 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 PhoneStateListener (android.telephony.PhoneStateListener)1 ServiceState (android.telephony.ServiceState)1 EmergencyNumberTracker (com.android.internal.telephony.emergency.EmergencyNumberTracker)1 TelephonyLog (com.android.internal.telephony.nano.TelephonyProto.TelephonyLog)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Before (org.junit.Before)1