use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTest method testMergeSameNumbersInEmergencyNumberListCornerCases.
public void testMergeSameNumbersInEmergencyNumberListCornerCases() throws Exception {
// Corner case 1: Empty List
List<EmergencyNumber> inputNumberList = new ArrayList<>();
List<EmergencyNumber> outputNumberList = new ArrayList<>();
EmergencyNumber.mergeSameNumbersInEmergencyNumberList(inputNumberList);
assertEquals(outputNumberList, inputNumberList);
// Corner case 2: Single element
EmergencyNumber num = new EmergencyNumber("110", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DATABASE, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
inputNumberList = new ArrayList<>();
outputNumberList = new ArrayList<>();
inputNumberList.add(num);
outputNumberList.add(num);
EmergencyNumber.mergeSameNumbersInEmergencyNumberList(inputNumberList);
assertEquals(outputNumberList, inputNumberList);
// Corner case 3: multiple element not ordered
inputNumberList = new ArrayList<>();
outputNumberList = new ArrayList<>();
EmergencyNumber num1 = new EmergencyNumber("911", "us", "", 0b111, new ArrayList<String>(), 0b10000, 0);
EmergencyNumber num12 = new EmergencyNumber("911", "us", "", 0b111, new ArrayList<String>(), 0b10000, 0);
EmergencyNumber num3 = new EmergencyNumber("112", "", "", 0, new ArrayList<String>(), 0, 0);
EmergencyNumber num4 = new EmergencyNumber("*911", "", "", 0, new ArrayList<String>(), 0, 0);
EmergencyNumber num13 = new EmergencyNumber("911", "us", "", 0b111, new ArrayList<String>(), 0b10000, 0);
EmergencyNumber num6 = new EmergencyNumber("#911", "", "", 0, new ArrayList<String>(), 0, 0);
EmergencyNumber num31 = new EmergencyNumber("112", "", "", 0, new ArrayList<String>(), 0, 0);
EmergencyNumber num14 = new EmergencyNumber("911", "us", "", 0b111, new ArrayList<String>(), 0b10000, 0);
inputNumberList.add(num1);
inputNumberList.add(num12);
inputNumberList.add(num3);
inputNumberList.add(num4);
inputNumberList.add(num13);
inputNumberList.add(num6);
inputNumberList.add(num31);
inputNumberList.add(num14);
EmergencyNumber.mergeSameNumbersInEmergencyNumberList(inputNumberList);
outputNumberList.add(num1);
outputNumberList.add(num3);
outputNumberList.add(num4);
outputNumberList.add(num6);
Collections.sort(outputNumberList);
assertEquals(outputNumberList, inputNumberList);
}
use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTest method testEmergencyNumberMultipleServices.
public void testEmergencyNumberMultipleServices() throws Exception {
EmergencyNumber number = new EmergencyNumber("110", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_POLICE | EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AMBULANCE | EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MIEC, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING | EmergencyNumber.EMERGENCY_NUMBER_SOURCE_SIM | EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DEFAULT, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
assertEquals(number.getNumber(), "110");
assertEquals(number.getCountryIso(), "jp");
assertEquals(number.getMnc(), "30");
assertFalse(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_POLICE));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AMBULANCE));
assertFalse(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE));
assertFalse(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MARINE_GUARD));
assertFalse(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MOUNTAIN_RESCUE));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MIEC));
assertFalse(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AIEC));
assertEquals(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_POLICE | EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AMBULANCE | EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MIEC, number.getEmergencyServiceCategoryBitmask());
List<Integer> categories = number.getEmergencyServiceCategories();
assertEquals(3, categories.size());
Collections.sort(categories);
List<Integer> categoriesToVerify = new ArrayList<Integer>();
categoriesToVerify.add(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_POLICE);
categoriesToVerify.add(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AMBULANCE);
categoriesToVerify.add(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MIEC);
Collections.sort(categoriesToVerify);
assertTrue(categoriesToVerify.equals(categories));
assertTrue(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING));
assertTrue(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_SIM));
assertFalse(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_MODEM_CONFIG));
assertTrue(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DEFAULT));
assertEquals(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING | EmergencyNumber.EMERGENCY_NUMBER_SOURCE_SIM | EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DEFAULT, number.getEmergencyNumberSourceBitmask());
List<Integer> sources = number.getEmergencyNumberSources();
assertEquals(3, sources.size());
Collections.sort(sources);
List<Integer> sourcesToVerify = new ArrayList<Integer>();
sourcesToVerify.add(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING);
sourcesToVerify.add(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_SIM);
sourcesToVerify.add(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DEFAULT);
Collections.sort(sourcesToVerify);
assertTrue(sourcesToVerify.equals(sources));
assertEquals(EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL, number.getEmergencyCallRouting());
}
use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTest method testSameEmergencyNumberDifferentMnc.
public void testSameEmergencyNumberDifferentMnc() throws Exception {
EmergencyNumber num1 = new EmergencyNumber("911", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
EmergencyNumber num2 = new EmergencyNumber("911", "jp", "20", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
assertFalse(EmergencyNumber.areSameEmergencyNumbers(num1, num2));
}
use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTest method testEmergencyNumberUnspecified.
public void testEmergencyNumberUnspecified() throws Exception {
EmergencyNumber number = new EmergencyNumber("911", "us", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
assertEquals(number.getNumber(), "911");
assertEquals(number.getCountryIso(), "us");
assertEquals(number.getMnc(), "30");
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_POLICE));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AMBULANCE));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_FIRE_BRIGADE));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MARINE_GUARD));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MOUNTAIN_RESCUE));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_MIEC));
assertTrue(number.isInEmergencyServiceCategories(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_AIEC));
assertEquals(0, number.getEmergencyServiceCategoryBitmask());
List<Integer> categories = number.getEmergencyServiceCategories();
assertEquals(1, categories.size());
assertEquals(EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, (int) categories.get(0));
assertTrue(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING));
assertFalse(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_SIM));
assertFalse(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_MODEM_CONFIG));
assertFalse(number.isFromSources(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DEFAULT));
assertEquals(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, number.getEmergencyNumberSourceBitmask());
List<Integer> sources = number.getEmergencyNumberSources();
assertEquals(1, sources.size());
assertEquals(EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, (int) sources.get(0));
assertEquals(EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL, number.getEmergencyCallRouting());
}
use of android.telephony.emergency.EmergencyNumber in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTest method testSameEmergencyNumberDifferentSource.
public void testSameEmergencyNumberDifferentSource() throws Exception {
EmergencyNumber num1 = new EmergencyNumber("911", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_NETWORK_SIGNALING, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
EmergencyNumber num2 = new EmergencyNumber("911", "jp", "30", EmergencyNumber.EMERGENCY_SERVICE_CATEGORY_UNSPECIFIED, new ArrayList<String>(), EmergencyNumber.EMERGENCY_NUMBER_SOURCE_DATABASE, EmergencyNumber.EMERGENCY_CALL_ROUTING_NORMAL);
assertTrue(EmergencyNumber.areSameEmergencyNumbers(num1, num2));
}
Aggregations