Loading src/java/com/android/internal/telephony/TelephonyCountryDetector.java +9 −1 Original line number Diff line number Diff line Loading @@ -236,7 +236,15 @@ public class TelephonyCountryDetector extends Handler { } List<String> result = new ArrayList<>(); for (Phone phone : PhoneFactory.getPhones()) { Phone[] phones; try { phones = PhoneFactory.getPhones(); } catch (IllegalStateException e) { logd("getCurrentNetworkCountryIso: PhoneFactory.getPhones() failed, e=" + e); return result; } for (Phone phone : phones) { String countryIso = getNetworkCountryIsoForPhone(phone); if (isValid(countryIso)) { String countryIsoInUpperCase = countryIso.toUpperCase(Locale.US); Loading src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java +19 −4 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.flags.FeatureFlags; import com.android.internal.telephony.satellite.metrics.SessionMetricsStats; import com.android.internal.telephony.util.ArrayUtils; import com.android.internal.util.IState; import com.android.internal.util.State; import com.android.internal.util.StateMachine; import com.android.telephony.Rlog; Loading Loading @@ -623,8 +624,15 @@ public class SatelliteSessionController extends StateMachine { * @return {@code true} if state machine is in enabling state and {@code false} otherwise. */ public boolean isInEnablingState() { if (DBG) plogd("isInEnablingState: getCurrentState=" + getCurrentState()); return getCurrentState() == mEnablingState; try { IState currentState = getCurrentState(); if (DBG) plogd("isInEnablingState: getCurrentState=" + currentState); return currentState == mEnablingState; } catch (Exception e) { plogw("isInEnablingState: Exception: " + e + ", mCurrentState=" + mCurrentState); return mCurrentState == SatelliteManager.SATELLITE_MODEM_STATE_ENABLING_SATELLITE; } } /** Loading @@ -633,8 +641,15 @@ public class SatelliteSessionController extends StateMachine { * @return {@code true} if state machine is in disabling state and {@code false} otherwise. */ public boolean isInDisablingState() { if (DBG) plogd("isInDisablingState: getCurrentState=" + getCurrentState()); return getCurrentState() == mDisablingState; try { IState currentState = getCurrentState(); if (DBG) plogd("isInDisablingState: getCurrentState=" + currentState); return currentState == mDisablingState; } catch (Exception e) { plogw("isInDisablingState: Exception: " + e + ", mCurrentState=" + mCurrentState); return mCurrentState == SatelliteManager.SATELLITE_MODEM_STATE_DISABLING_SATELLITE; } } /** Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyCountryDetectorTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { mTestableLooper = new TestableLooper(mLooper); mLocaleTrackers = new LocaleTracker[]{mMockLocaleTracker, mMockLocaleTracker2}; replaceInstance(PhoneFactory.class, "sMadeDefaults", null, true); replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone, mPhone2}); when(mPhone.getServiceStateTracker()).thenReturn(mSST); when(mPhone.getPhoneId()).thenReturn(0); Loading Loading @@ -196,6 +197,12 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { assertTrue(mCountryDetectorUT.getCurrentNetworkCountryIso().contains("CA")); } @Test public void testGetCurrentNetworkCountryIso_DefaultPhoneNotCreated() throws Exception { replaceInstance(PhoneFactory.class, "sMadeDefaults", null, false); assertTrue(mCountryDetectorUT.getCurrentNetworkCountryIso().isEmpty()); } @Test public void testCachedNetworkCountryCodeUpdate() { assertTrue(mCountryDetectorUT.getCachedNetworkCountryIsoInfo().isEmpty()); Loading Loading
src/java/com/android/internal/telephony/TelephonyCountryDetector.java +9 −1 Original line number Diff line number Diff line Loading @@ -236,7 +236,15 @@ public class TelephonyCountryDetector extends Handler { } List<String> result = new ArrayList<>(); for (Phone phone : PhoneFactory.getPhones()) { Phone[] phones; try { phones = PhoneFactory.getPhones(); } catch (IllegalStateException e) { logd("getCurrentNetworkCountryIso: PhoneFactory.getPhones() failed, e=" + e); return result; } for (Phone phone : phones) { String countryIso = getNetworkCountryIsoForPhone(phone); if (isValid(countryIso)) { String countryIsoInUpperCase = countryIso.toUpperCase(Locale.US); Loading
src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java +19 −4 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ import com.android.internal.telephony.PhoneFactory; import com.android.internal.telephony.flags.FeatureFlags; import com.android.internal.telephony.satellite.metrics.SessionMetricsStats; import com.android.internal.telephony.util.ArrayUtils; import com.android.internal.util.IState; import com.android.internal.util.State; import com.android.internal.util.StateMachine; import com.android.telephony.Rlog; Loading Loading @@ -623,8 +624,15 @@ public class SatelliteSessionController extends StateMachine { * @return {@code true} if state machine is in enabling state and {@code false} otherwise. */ public boolean isInEnablingState() { if (DBG) plogd("isInEnablingState: getCurrentState=" + getCurrentState()); return getCurrentState() == mEnablingState; try { IState currentState = getCurrentState(); if (DBG) plogd("isInEnablingState: getCurrentState=" + currentState); return currentState == mEnablingState; } catch (Exception e) { plogw("isInEnablingState: Exception: " + e + ", mCurrentState=" + mCurrentState); return mCurrentState == SatelliteManager.SATELLITE_MODEM_STATE_ENABLING_SATELLITE; } } /** Loading @@ -633,8 +641,15 @@ public class SatelliteSessionController extends StateMachine { * @return {@code true} if state machine is in disabling state and {@code false} otherwise. */ public boolean isInDisablingState() { if (DBG) plogd("isInDisablingState: getCurrentState=" + getCurrentState()); return getCurrentState() == mDisablingState; try { IState currentState = getCurrentState(); if (DBG) plogd("isInDisablingState: getCurrentState=" + currentState); return currentState == mDisablingState; } catch (Exception e) { plogw("isInDisablingState: Exception: " + e + ", mCurrentState=" + mCurrentState); return mCurrentState == SatelliteManager.SATELLITE_MODEM_STATE_DISABLING_SATELLITE; } } /** Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyCountryDetectorTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { mTestableLooper = new TestableLooper(mLooper); mLocaleTrackers = new LocaleTracker[]{mMockLocaleTracker, mMockLocaleTracker2}; replaceInstance(PhoneFactory.class, "sMadeDefaults", null, true); replaceInstance(PhoneFactory.class, "sPhones", null, new Phone[] {mPhone, mPhone2}); when(mPhone.getServiceStateTracker()).thenReturn(mSST); when(mPhone.getPhoneId()).thenReturn(0); Loading Loading @@ -196,6 +197,12 @@ public class TelephonyCountryDetectorTest extends TelephonyTest { assertTrue(mCountryDetectorUT.getCurrentNetworkCountryIso().contains("CA")); } @Test public void testGetCurrentNetworkCountryIso_DefaultPhoneNotCreated() throws Exception { replaceInstance(PhoneFactory.class, "sMadeDefaults", null, false); assertTrue(mCountryDetectorUT.getCurrentNetworkCountryIso().isEmpty()); } @Test public void testCachedNetworkCountryCodeUpdate() { assertTrue(mCountryDetectorUT.getCachedNetworkCountryIsoInfo().isEmpty()); Loading