Loading src/java/com/android/internal/telephony/LocaleTracker.java +4 −15 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; Loading Loading @@ -259,17 +258,6 @@ public class LocaleTracker extends Handler { mPhone.registerForCellInfo(this, EVENT_UNSOL_CELL_INFO, null); } private @NonNull String getCarrierCountry() { // The locale from the "ro.carrier" system property or R.array.carrier_properties. // This will be overwritten by the Locale from the SIM language settings (EF-PL, EF-LI) // if applicable. final Locale carrierLocale = mPhone.getLocaleFromCarrierProperties(); if (carrierLocale != null && !TextUtils.isEmpty(carrierLocale.getCountry())) { return carrierLocale.getCountry(); } return ""; } /** * Get the device's current country. * Loading Loading @@ -492,8 +480,8 @@ public class LocaleTracker extends Handler { */ private synchronized void updateLocale() { // If MCC is available from network service state, use it first. String countryIso = getCarrierCountry(); String countryIsoDebugInfo = "getCarrierCountry()"; String countryIso = ""; String countryIsoDebugInfo = "empty as default"; // For time zone detection we want the best geographical match we can get, which may differ // from the countryIso. Loading Loading @@ -539,8 +527,9 @@ public class LocaleTracker extends Handler { timeZoneCountryIsoDebugInfo = countryIsoDebugInfo; } if (mLastServiceState == ServiceState.STATE_POWER_OFF) { if (!mPhone.isRadioOn()) { countryIso = ""; countryIsoDebugInfo = "radio off"; } log("updateLocale: countryIso = " + countryIso Loading tests/telephonytests/src/com/android/internal/telephony/LocaleTrackerTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class LocaleTrackerTest extends TelephonyTest { m.sendToTarget(); return null; }).when(mPhone).requestCellInfoUpdate(any(), any()); doReturn(true).when(mPhone).isRadioOn(); processAllMessages(); logd("LocaleTrackerTest -Setup!"); } Loading Loading @@ -135,6 +136,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testUpdateOperatorNumericSync() throws Exception { doReturn(false).when(mPhone).isRadioOn(); mLocaleTracker.updateOperatorNumeric(US_MCC + FAKE_MNC); // Because the service state is in APM, the country ISO should be set empty. assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); Loading @@ -161,6 +163,7 @@ public class LocaleTrackerTest extends TelephonyTest { @SmallTest public void testBootupInAirplaneModeOn() throws Exception { mLocaleTracker.updateOperatorNumeric(""); doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE}); Loading @@ -170,6 +173,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testToggleAirplaneModeOn() throws Exception { doReturn(true).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_IN_SERVICE); mLocaleTracker.updateOperatorNumeric(US_MCC + FAKE_MNC); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); Loading @@ -183,6 +187,7 @@ public class LocaleTrackerTest extends TelephonyTest { assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getLastKnownCountryIso()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); assertFalse(mLocaleTracker.isTracking()); Loading @@ -198,6 +203,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testToggleAirplaneModeOff() throws Exception { doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); mLocaleTracker.updateOperatorNumeric(""); processAllMessages(); Loading @@ -205,6 +211,7 @@ public class LocaleTrackerTest extends TelephonyTest { verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE}); assertFalse(mLocaleTracker.isTracking()); doReturn(true).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_OUT_OF_SERVICE); processAllMessages(); assertTrue(mLocaleTracker.isTracking()); Loading @@ -214,6 +221,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testToggleAirplaneModeOosPlmn() throws Exception { doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); mLocaleTracker.updateOperatorNumeric(""); processAllMessages(); Loading @@ -228,6 +236,7 @@ public class LocaleTrackerTest extends TelephonyTest { m.sendToTarget(); return null; }).when(mPhone).requestCellInfoUpdate(any(), any()); doReturn(true).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_OUT_OF_SERVICE); processAllMessages(); assertTrue(mLocaleTracker.isTracking()); Loading Loading
src/java/com/android/internal/telephony/LocaleTracker.java +4 −15 Original line number Diff line number Diff line Loading @@ -49,7 +49,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; Loading Loading @@ -259,17 +258,6 @@ public class LocaleTracker extends Handler { mPhone.registerForCellInfo(this, EVENT_UNSOL_CELL_INFO, null); } private @NonNull String getCarrierCountry() { // The locale from the "ro.carrier" system property or R.array.carrier_properties. // This will be overwritten by the Locale from the SIM language settings (EF-PL, EF-LI) // if applicable. final Locale carrierLocale = mPhone.getLocaleFromCarrierProperties(); if (carrierLocale != null && !TextUtils.isEmpty(carrierLocale.getCountry())) { return carrierLocale.getCountry(); } return ""; } /** * Get the device's current country. * Loading Loading @@ -492,8 +480,8 @@ public class LocaleTracker extends Handler { */ private synchronized void updateLocale() { // If MCC is available from network service state, use it first. String countryIso = getCarrierCountry(); String countryIsoDebugInfo = "getCarrierCountry()"; String countryIso = ""; String countryIsoDebugInfo = "empty as default"; // For time zone detection we want the best geographical match we can get, which may differ // from the countryIso. Loading Loading @@ -539,8 +527,9 @@ public class LocaleTracker extends Handler { timeZoneCountryIsoDebugInfo = countryIsoDebugInfo; } if (mLastServiceState == ServiceState.STATE_POWER_OFF) { if (!mPhone.isRadioOn()) { countryIso = ""; countryIsoDebugInfo = "radio off"; } log("updateLocale: countryIso = " + countryIso Loading
tests/telephonytests/src/com/android/internal/telephony/LocaleTrackerTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class LocaleTrackerTest extends TelephonyTest { m.sendToTarget(); return null; }).when(mPhone).requestCellInfoUpdate(any(), any()); doReturn(true).when(mPhone).isRadioOn(); processAllMessages(); logd("LocaleTrackerTest -Setup!"); } Loading Loading @@ -135,6 +136,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testUpdateOperatorNumericSync() throws Exception { doReturn(false).when(mPhone).isRadioOn(); mLocaleTracker.updateOperatorNumeric(US_MCC + FAKE_MNC); // Because the service state is in APM, the country ISO should be set empty. assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); Loading @@ -161,6 +163,7 @@ public class LocaleTrackerTest extends TelephonyTest { @SmallTest public void testBootupInAirplaneModeOn() throws Exception { mLocaleTracker.updateOperatorNumeric(""); doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); assertEquals(COUNTRY_CODE_UNAVAILABLE, mLocaleTracker.getCurrentCountry()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE}); Loading @@ -170,6 +173,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testToggleAirplaneModeOn() throws Exception { doReturn(true).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_IN_SERVICE); mLocaleTracker.updateOperatorNumeric(US_MCC + FAKE_MNC); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); Loading @@ -183,6 +187,7 @@ public class LocaleTrackerTest extends TelephonyTest { assertEquals(US_COUNTRY_CODE, mLocaleTracker.getCurrentCountry()); assertEquals(US_COUNTRY_CODE, mLocaleTracker.getLastKnownCountryIso()); verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE, US_COUNTRY_CODE}); doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); assertFalse(mLocaleTracker.isTracking()); Loading @@ -198,6 +203,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testToggleAirplaneModeOff() throws Exception { doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); mLocaleTracker.updateOperatorNumeric(""); processAllMessages(); Loading @@ -205,6 +211,7 @@ public class LocaleTrackerTest extends TelephonyTest { verifyCountryCodeNotified(new String[]{COUNTRY_CODE_UNAVAILABLE}); assertFalse(mLocaleTracker.isTracking()); doReturn(true).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_OUT_OF_SERVICE); processAllMessages(); assertTrue(mLocaleTracker.isTracking()); Loading @@ -214,6 +221,7 @@ public class LocaleTrackerTest extends TelephonyTest { @Test @SmallTest public void testToggleAirplaneModeOosPlmn() throws Exception { doReturn(false).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_POWER_OFF); mLocaleTracker.updateOperatorNumeric(""); processAllMessages(); Loading @@ -228,6 +236,7 @@ public class LocaleTrackerTest extends TelephonyTest { m.sendToTarget(); return null; }).when(mPhone).requestCellInfoUpdate(any(), any()); doReturn(true).when(mPhone).isRadioOn(); sendServiceState(ServiceState.STATE_OUT_OF_SERVICE); processAllMessages(); assertTrue(mLocaleTracker.isTracking()); Loading