Loading src/java/com/android/internal/telephony/NetworkTypeController.java +18 −14 Original line number Diff line number Diff line Loading @@ -620,8 +620,7 @@ public class NetworkTypeController extends StateMachine { parseCarrierConfigs(); break; case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); transitionToCurrentState(); break; case EVENT_PHYSICAL_LINK_STATUS_CHANGED: Loading Loading @@ -731,8 +730,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -814,8 +812,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -900,8 +897,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -986,8 +982,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -1066,8 +1061,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -1147,8 +1141,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -1211,6 +1204,17 @@ public class NetworkTypeController extends StateMachine { private final NrConnectedAdvancedState mNrConnectedAdvancedState = new NrConnectedAdvancedState(); /** On service state changed. */ private void onServiceStateChanged() { ServiceState newSS = mPhone.getServiceStateTracker().getServiceState(); if (!TextUtils.equals(mServiceState.getOperatorAlpha(), newSS.getOperatorAlpha())) { log("PLMN changed, reset any timers"); resetAllTimers(); } mServiceState = newSS; if (DBG) log("ServiceState updated: " + mServiceState); } private void updatePhysicalChannelConfigs(List<PhysicalChannelConfig> physicalChannelConfigs) { boolean isPccListEmpty = physicalChannelConfigs == null || physicalChannelConfigs.isEmpty(); if (isPccListEmpty && isUsingPhysicalChannelConfigForRrcDetection()) { Loading tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -1776,6 +1776,38 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertTrue(mNetworkTypeController.areAnyTimersActive()); } @Test public void testNrTimerResetWhenPlmnChanged() throws Exception { testTransitionToCurrentStateNrConnectedMmwave(); mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING, "connected_mmwave,any,10;connected,any,10;not_restricted_rrc_con,any,10"); mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING, "connected_mmwave,any,30"); sendCarrierConfigChanged(); // should trigger 10 second primary timer doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState(); doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("legacy", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); // PLMN changed, should cancel any active timers ServiceState newSS = mock(ServiceState.class); doReturn("different plmn").when(newSS).getOperatorAlpha(); doReturn(newSS).when(mSST).getServiceState(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertFalse(mNetworkTypeController.areAnyTimersActive()); } private void setPhysicalLinkStatus(boolean state) { List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>(); // If PhysicalChannelConfigList is empty, PhysicalLinkStatus is Loading Loading
src/java/com/android/internal/telephony/NetworkTypeController.java +18 −14 Original line number Diff line number Diff line Loading @@ -620,8 +620,7 @@ public class NetworkTypeController extends StateMachine { parseCarrierConfigs(); break; case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); transitionToCurrentState(); break; case EVENT_PHYSICAL_LINK_STATUS_CHANGED: Loading Loading @@ -731,8 +730,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -814,8 +812,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -900,8 +897,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -986,8 +982,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -1066,8 +1061,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -1147,8 +1141,7 @@ public class NetworkTypeController extends StateMachine { AsyncResult ar; switch (msg.what) { case EVENT_SERVICE_STATE_CHANGED: mServiceState = mPhone.getServiceStateTracker().getServiceState(); if (DBG) log("ServiceState updated: " + mServiceState); onServiceStateChanged(); // fallthrough case EVENT_UPDATE: int rat = getDataNetworkType(); Loading Loading @@ -1211,6 +1204,17 @@ public class NetworkTypeController extends StateMachine { private final NrConnectedAdvancedState mNrConnectedAdvancedState = new NrConnectedAdvancedState(); /** On service state changed. */ private void onServiceStateChanged() { ServiceState newSS = mPhone.getServiceStateTracker().getServiceState(); if (!TextUtils.equals(mServiceState.getOperatorAlpha(), newSS.getOperatorAlpha())) { log("PLMN changed, reset any timers"); resetAllTimers(); } mServiceState = newSS; if (DBG) log("ServiceState updated: " + mServiceState); } private void updatePhysicalChannelConfigs(List<PhysicalChannelConfig> physicalChannelConfigs) { boolean isPccListEmpty = physicalChannelConfigs == null || physicalChannelConfigs.isEmpty(); if (isPccListEmpty && isUsingPhysicalChannelConfigForRrcDetection()) { Loading
tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -1776,6 +1776,38 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertTrue(mNetworkTypeController.areAnyTimersActive()); } @Test public void testNrTimerResetWhenPlmnChanged() throws Exception { testTransitionToCurrentStateNrConnectedMmwave(); mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING, "connected_mmwave,any,10;connected,any,10;not_restricted_rrc_con,any,10"); mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_SECONDARY_GRACE_PERIOD_STRING, "connected_mmwave,any,30"); sendCarrierConfigChanged(); // should trigger 10 second primary timer doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState(); doReturn(ServiceState.FREQUENCY_RANGE_UNKNOWN).when(mServiceState).getNrFrequencyRange(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("legacy", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); // PLMN changed, should cancel any active timers ServiceState newSS = mock(ServiceState.class); doReturn("different plmn").when(newSS).getOperatorAlpha(); doReturn(newSS).when(mSST).getServiceState(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertFalse(mNetworkTypeController.areAnyTimersActive()); } private void setPhysicalLinkStatus(boolean state) { List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>(); // If PhysicalChannelConfigList is empty, PhysicalLinkStatus is Loading