Loading src/java/com/android/internal/telephony/LocaleTracker.java +4 −0 Original line number Diff line number Diff line Loading @@ -563,6 +563,10 @@ public class LocaleTracker extends Handler { timeZoneCountryIsoDebugInfo = countryIsoDebugInfo; } if (mLastServiceState == ServiceState.STATE_POWER_OFF) { countryIso = ""; } log("updateLocale: countryIso = " + countryIso + ", countryIsoDebugInfo = " + countryIsoDebugInfo); if (!Objects.equals(countryIso, mCurrentCountryIso)) { Loading src/java/com/android/internal/telephony/emergency/EmergencyNumberTracker.java +14 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.PersistableBundle; import android.os.SystemProperties; import android.telephony.CarrierConfigManager; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.emergency.EmergencyNumber; import android.telephony.emergency.EmergencyNumber.EmergencyCallRouting; Loading Loading @@ -144,17 +145,27 @@ public class EmergencyNumberTracker extends Handler { TelephonyManager.EXTRA_NETWORK_COUNTRY); logd("ACTION_NETWORK_COUNTRY_CHANGED: PhoneId: " + phoneId + " CountryIso: " + countryIso); boolean isInApm = false; ServiceStateTracker serviceStateTracker = mPhone.getServiceStateTracker(); if (serviceStateTracker != null) { if (serviceStateTracker.getServiceState().getState() == ServiceState.STATE_POWER_OFF) { isInApm = true; } } // Sometimes the country is updated as an empty string when the network signal // is lost; though we may not call emergency when there is no signal, we want // to keep the old country iso to provide country-related emergency numbers, // because they think they are still in that country. We don't need to update // country change in this case. if (TextUtils.isEmpty(countryIso)) { // country change in this case. We will still need to update the empty string // if device is in APM. if (TextUtils.isEmpty(countryIso) && !isInApm) { return; } // Update country iso change for available Phones updateEmergencyCountryIsoAllPhones(countryIso); updateEmergencyCountryIsoAllPhones(countryIso == null ? "" : countryIso); } return; } Loading tests/telephonytests/src/com/android/internal/telephony/LocaleTrackerTest.java +15 −3 Original line number Diff line number Diff line Loading @@ -136,19 +136,24 @@ public class LocaleTrackerTest extends TelephonyTest { @SmallTest public void testUpdateOperatorNumericSync() throws Exception { mLocaleTracker.updateOperatorNumeric(US_MCC + FAKE_MNC); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{US_COUNTRY_CODE}); // Because the service state is in APM, the country ISO should be set empty. assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); } @Test @SmallTest public void testNoSim() throws Exception { // Set the state as STATE_OUT_OF_SERVICE. This will trigger an country change to US. sendServiceState(ServiceState.STATE_OUT_OF_SERVICE); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); // updateOperatorNumeric("") will not trigger an instantaneous country change mLocaleTracker.updateOperatorNumeric(""); sendGsmCellInfo(); sendServiceState(ServiceState.STATE_EMERGENCY_ONLY); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{US_COUNTRY_CODE}); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); assertTrue(mLocaleTracker.isTracking()); } Loading Loading @@ -178,6 +183,13 @@ public class LocaleTrackerTest extends TelephonyTest { verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); sendServiceState(ServiceState.STATE_POWER_OFF); assertFalse(mLocaleTracker.isTracking()); // updateOperatorNumeric("") will trigger a country change in APM mLocaleTracker.updateOperatorNumeric(""); processAllMessages(); assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE, COUNTRY_CODE_UNAVAILABLE}); } @Test Loading Loading
src/java/com/android/internal/telephony/LocaleTracker.java +4 −0 Original line number Diff line number Diff line Loading @@ -563,6 +563,10 @@ public class LocaleTracker extends Handler { timeZoneCountryIsoDebugInfo = countryIsoDebugInfo; } if (mLastServiceState == ServiceState.STATE_POWER_OFF) { countryIso = ""; } log("updateLocale: countryIso = " + countryIso + ", countryIsoDebugInfo = " + countryIsoDebugInfo); if (!Objects.equals(countryIso, mCurrentCountryIso)) { Loading
src/java/com/android/internal/telephony/emergency/EmergencyNumberTracker.java +14 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.os.PersistableBundle; import android.os.SystemProperties; import android.telephony.CarrierConfigManager; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; import android.telephony.TelephonyManager; import android.telephony.emergency.EmergencyNumber; import android.telephony.emergency.EmergencyNumber.EmergencyCallRouting; Loading Loading @@ -144,17 +145,27 @@ public class EmergencyNumberTracker extends Handler { TelephonyManager.EXTRA_NETWORK_COUNTRY); logd("ACTION_NETWORK_COUNTRY_CHANGED: PhoneId: " + phoneId + " CountryIso: " + countryIso); boolean isInApm = false; ServiceStateTracker serviceStateTracker = mPhone.getServiceStateTracker(); if (serviceStateTracker != null) { if (serviceStateTracker.getServiceState().getState() == ServiceState.STATE_POWER_OFF) { isInApm = true; } } // Sometimes the country is updated as an empty string when the network signal // is lost; though we may not call emergency when there is no signal, we want // to keep the old country iso to provide country-related emergency numbers, // because they think they are still in that country. We don't need to update // country change in this case. if (TextUtils.isEmpty(countryIso)) { // country change in this case. We will still need to update the empty string // if device is in APM. if (TextUtils.isEmpty(countryIso) && !isInApm) { return; } // Update country iso change for available Phones updateEmergencyCountryIsoAllPhones(countryIso); updateEmergencyCountryIsoAllPhones(countryIso == null ? "" : countryIso); } return; } Loading
tests/telephonytests/src/com/android/internal/telephony/LocaleTrackerTest.java +15 −3 Original line number Diff line number Diff line Loading @@ -136,19 +136,24 @@ public class LocaleTrackerTest extends TelephonyTest { @SmallTest public void testUpdateOperatorNumericSync() throws Exception { mLocaleTracker.updateOperatorNumeric(US_MCC + FAKE_MNC); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{US_COUNTRY_CODE}); // Because the service state is in APM, the country ISO should be set empty. assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); } @Test @SmallTest public void testNoSim() throws Exception { // Set the state as STATE_OUT_OF_SERVICE. This will trigger an country change to US. sendServiceState(ServiceState.STATE_OUT_OF_SERVICE); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); // updateOperatorNumeric("") will not trigger an instantaneous country change mLocaleTracker.updateOperatorNumeric(""); sendGsmCellInfo(); sendServiceState(ServiceState.STATE_EMERGENCY_ONLY); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{US_COUNTRY_CODE}); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); assertTrue(mLocaleTracker.isTracking()); } Loading Loading @@ -178,6 +183,13 @@ public class LocaleTrackerTest extends TelephonyTest { verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); sendServiceState(ServiceState.STATE_POWER_OFF); assertFalse(mLocaleTracker.isTracking()); // updateOperatorNumeric("") will trigger a country change in APM mLocaleTracker.updateOperatorNumeric(""); processAllMessages(); assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE, COUNTRY_CODE_UNAVAILABLE}); } @Test Loading