Loading src/java/com/android/internal/telephony/NetworkTypeController.java +7 −0 Original line number Diff line number Diff line Loading @@ -1136,6 +1136,13 @@ public class NetworkTypeController extends StateMachine { resetAllTimers(); } if (currentState.equals(STATE_CONNECTED) && !mPrimaryTimerState.equals(STATE_CONNECTED_NR_ADVANCED) && !mSecondaryTimerState.equals(STATE_CONNECTED_NR_ADVANCED)) { if (DBG) log("Reset non-NR_advanced timers since state is NR_CONNECTED"); resetAllTimers(); } int rat = getDataNetworkType(); if (!isLte(rat) && rat != TelephonyManager.NETWORK_TYPE_NR) { if (DBG) log("Reset timers since 2G and 3G don't need NR timers."); Loading tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +76 −0 Original line number Diff line number Diff line Loading @@ -1155,6 +1155,82 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testNrTimerResetWhenConnected() throws Exception { 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"); broadcastCarrierConfigs(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); mNetworkTypeController.sendMessage(4 /* EVENT_PHYSICAL_LINK_STATUS_CHANGED */, new AsyncResult(null, DataCallResponse.LINK_STATUS_ACTIVE, null)); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("not_restricted_rrc_con", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA, mNetworkTypeController.getOverrideNetworkType()); // 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_NSA, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); // rat is NR, should stop timer NetworkRegistrationInfo nri = new NetworkRegistrationInfo.Builder() .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .build(); doReturn(nri).when(mServiceState).getNetworkRegistrationInfo(anyInt(), anyInt()); doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("connected", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testNrTimerResetWhenConnectedAdvanced() 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"); broadcastCarrierConfigs(); // 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()); // not advanced, should not stop timer doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("connected", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, mNetworkTypeController.getOverrideNetworkType()); assertTrue(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 +7 −0 Original line number Diff line number Diff line Loading @@ -1136,6 +1136,13 @@ public class NetworkTypeController extends StateMachine { resetAllTimers(); } if (currentState.equals(STATE_CONNECTED) && !mPrimaryTimerState.equals(STATE_CONNECTED_NR_ADVANCED) && !mSecondaryTimerState.equals(STATE_CONNECTED_NR_ADVANCED)) { if (DBG) log("Reset non-NR_advanced timers since state is NR_CONNECTED"); resetAllTimers(); } int rat = getDataNetworkType(); if (!isLte(rat) && rat != TelephonyManager.NETWORK_TYPE_NR) { if (DBG) log("Reset timers since 2G and 3G don't need NR timers."); Loading
tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +76 −0 Original line number Diff line number Diff line Loading @@ -1155,6 +1155,82 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testNrTimerResetWhenConnected() throws Exception { 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"); broadcastCarrierConfigs(); doReturn(NetworkRegistrationInfo.NR_STATE_NOT_RESTRICTED).when(mServiceState).getNrState(); mNetworkTypeController.sendMessage(4 /* EVENT_PHYSICAL_LINK_STATUS_CHANGED */, new AsyncResult(null, DataCallResponse.LINK_STATUS_ACTIVE, null)); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("not_restricted_rrc_con", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA, mNetworkTypeController.getOverrideNetworkType()); // 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_NSA, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); // rat is NR, should stop timer NetworkRegistrationInfo nri = new NetworkRegistrationInfo.Builder() .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .build(); doReturn(nri).when(mServiceState).getNetworkRegistrationInfo(anyInt(), anyInt()); doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("connected", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testNrTimerResetWhenConnectedAdvanced() 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"); broadcastCarrierConfigs(); // 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()); // not advanced, should not stop timer doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState(); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("connected", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); } private void setPhysicalLinkStatus(boolean state) { List<PhysicalChannelConfig> lastPhysicalChannelConfigList = new ArrayList<>(); // If PhysicalChannelConfigList is empty, PhysicalLinkStatus is Loading