use of com.android.internal.telephony.HalVersion in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTrackerTest method testUsingEmergencyNumberDatabaseWheneverHal_1_3.
/**
* In 1.3 or less HAL. we should not use database number.
*/
@Test
public void testUsingEmergencyNumberDatabaseWheneverHal_1_3() {
doReturn(new HalVersion(1, 3)).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;
}
}
assertFalse(hasDatabaseNumber);
}
use of com.android.internal.telephony.HalVersion in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTrackerTest method testOtaEmergencyNumberDatabase.
/**
* Test OTA Emergency Number Database Update Status.
*/
@Test
public void testOtaEmergencyNumberDatabase() {
// Set up the Hal version as 1.4 to apply emergency number database
doReturn(new HalVersion(1, 4)).when(mPhone).getHalVersion();
sendEmergencyNumberPrefix(mEmergencyNumberTrackerMock);
mEmergencyNumberTrackerMock.updateEmergencyCountryIsoAllPhones("");
processAllMessages();
// Emergency Number Db is cached per country, given the country is empty at this time,
// we should not expect any db number there.
assertFalse(hasDbEmergencyNumber(CONFIG_EMERGENCY_NUMBER_ADDRESS, mEmergencyNumberTrackerMock.getEmergencyNumberList()));
// Set up the OTA database file folder as sdcard for testing purposes
setOtaEmergencyNumberDbFileFolderForTesting(mEmergencyNumberTrackerMock, mPhone);
// Notify EmergerncyNumberTracker OTA database is installed.
sendOtaEmergencyNumberDb(mEmergencyNumberTrackerMock);
processAllMessages();
assertEquals(OTA_UNIT_TEST_EMERGENCY_NUMBER_DB_VERSION, mEmergencyNumberTrackerMock.getEmergencyNumberDbVersion());
// Emergency Number Db is cached per country, given the country is empty at this time,
// we should not expect any db number there.
assertFalse(hasDbEmergencyNumber(OTA_EMERGENCY_NUMBER_ADDRESS, mEmergencyNumberTrackerMock.getEmergencyNumberList()));
mEmergencyNumberTrackerMock.updateEmergencyCountryIsoAllPhones("us");
processAllMessages();
assertEquals(OTA_UNIT_TEST_EMERGENCY_NUMBER_DB_VERSION, mEmergencyNumberTrackerMock.getEmergencyNumberDbVersion());
// Emergency Number Db is cached per country, given the country is 'us' at this time,
// we should expect the 'us' db number there.
assertTrue(hasDbEmergencyNumber(OTA_EMERGENCY_NUMBER_ADDRESS, mEmergencyNumberTrackerMock.getEmergencyNumberList()));
// Reset the OTA database file to default after testing completion
resetOtaEmergencyNumberDbFileFolderForTesting(mEmergencyNumberTrackerMock);
}
use of com.android.internal.telephony.HalVersion in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTracker method getEmergencyNumberListFromEccListDatabaseAndTest.
private List<EmergencyNumber> getEmergencyNumberListFromEccListDatabaseAndTest() {
List<EmergencyNumber> mergedEmergencyNumberList = getEmergencyNumberListFromEccList();
if (mPhone.getHalVersion().greaterOrEqual(new HalVersion(1, 4))) {
loge("getEmergencyNumberListFromEccListDatabaseAndTest: radio indication is" + " unavailable in 1.4 HAL.");
mergedEmergencyNumberList.addAll(mEmergencyNumberListFromDatabase);
mergedEmergencyNumberList.addAll(getEmergencyNumberListWithPrefix(mEmergencyNumberListFromDatabase));
}
mergedEmergencyNumberList.addAll(getEmergencyNumberListTestMode());
EmergencyNumber.mergeSameNumbersInEmergencyNumberList(mergedEmergencyNumberList);
return mergedEmergencyNumberList;
}
use of com.android.internal.telephony.HalVersion in project android_frameworks_opt_telephony by LineageOS.
the class EmergencyNumberTracker method isEmergencyNumberFromDatabase.
private boolean isEmergencyNumberFromDatabase(String number) {
if (!mPhone.getHalVersion().greaterOrEqual(new HalVersion(1, 4))) {
return false;
}
number = PhoneNumberUtils.stripSeparators(number);
for (EmergencyNumber num : mEmergencyNumberListFromDatabase) {
if (num.getNumber().equals(number)) {
return true;
}
}
List<EmergencyNumber> emergencyNumberListFromDatabaseWithPrefix = getEmergencyNumberListWithPrefix(mEmergencyNumberListFromDatabase);
for (EmergencyNumber num : emergencyNumberListFromDatabaseWithPrefix) {
if (num.getNumber().equals(number)) {
return true;
}
}
return false;
}
use of com.android.internal.telephony.HalVersion 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);
}
Aggregations