Loading src/java/com/android/internal/telephony/NetworkTypeController.java +3 −1 Original line number Diff line number Diff line Loading @@ -1349,7 +1349,9 @@ public class NetworkTypeController extends StateMachine { String currentState = getCurrentState().getName(); if (mIsPrimaryTimerActive && getOverrideNetworkType() == getCurrentOverrideNetworkType()) { if (mIsPrimaryTimerActive && getOverrideNetworkType() == getCurrentOverrideNetworkType() && getDataNetworkType() == mDisplayInfoController.getTelephonyDisplayInfo().getNetworkType()) { // remove primary timer if device goes back to the original icon if (DBG) { log("Remove primary timer since icon of primary state and current icon equal: " Loading tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; Loading Loading @@ -991,6 +992,54 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testPrimaryTimerNetworkTypeChanged() throws Exception { doAnswer(invocation -> { doReturn(new TelephonyDisplayInfo( mNetworkTypeController.getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType(), false)).when(mDisplayInfoController).getTelephonyDisplayInfo(); return null; }).when(mDisplayInfoController).updateTelephonyDisplayInfo(); mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder() .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .build(); doReturn(mNetworkRegistrationInfo).when(mServiceState).getNetworkRegistrationInfo( anyInt(), anyInt()); mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING, "connected_mmwave,any,10;connected,any,10;not_restricted_rrc_con,any,10"); sendCarrierConfigChanged(); assertEquals("connected", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); // trigger 10 second timer after disconnecting from NR advanced mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder() .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .build(); doReturn(mNetworkRegistrationInfo).when(mServiceState).getNetworkRegistrationInfo( anyInt(), anyInt()); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("legacy", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); // timer expires moveTimeForward(10 * 1000); processAllMessages(); assertEquals("legacy", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testPrimaryTimerDeviceIdleMode() throws Exception { doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState(); Loading Loading
src/java/com/android/internal/telephony/NetworkTypeController.java +3 −1 Original line number Diff line number Diff line Loading @@ -1349,7 +1349,9 @@ public class NetworkTypeController extends StateMachine { String currentState = getCurrentState().getName(); if (mIsPrimaryTimerActive && getOverrideNetworkType() == getCurrentOverrideNetworkType()) { if (mIsPrimaryTimerActive && getOverrideNetworkType() == getCurrentOverrideNetworkType() && getDataNetworkType() == mDisplayInfoController.getTelephonyDisplayInfo().getNetworkType()) { // remove primary timer if device goes back to the original icon if (DBG) { log("Remove primary timer since icon of primary state and current icon equal: " Loading
tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +49 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.any; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; Loading Loading @@ -991,6 +992,54 @@ public class NetworkTypeControllerTest extends TelephonyTest { assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testPrimaryTimerNetworkTypeChanged() throws Exception { doAnswer(invocation -> { doReturn(new TelephonyDisplayInfo( mNetworkTypeController.getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType(), false)).when(mDisplayInfoController).getTelephonyDisplayInfo(); return null; }).when(mDisplayInfoController).updateTelephonyDisplayInfo(); mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder() .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_NR) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .build(); doReturn(mNetworkRegistrationInfo).when(mServiceState).getNetworkRegistrationInfo( anyInt(), anyInt()); mBundle.putString(CarrierConfigManager.KEY_5G_ICON_DISPLAY_GRACE_PERIOD_STRING, "connected_mmwave,any,10;connected,any,10;not_restricted_rrc_con,any,10"); sendCarrierConfigChanged(); assertEquals("connected", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); // trigger 10 second timer after disconnecting from NR advanced mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder() .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE) .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME) .build(); doReturn(mNetworkRegistrationInfo).when(mServiceState).getNetworkRegistrationInfo( anyInt(), anyInt()); mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */); processAllMessages(); assertEquals("legacy", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertTrue(mNetworkTypeController.areAnyTimersActive()); // timer expires moveTimeForward(10 * 1000); processAllMessages(); assertEquals("legacy", getCurrentState().getName()); assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, mNetworkTypeController.getOverrideNetworkType()); assertFalse(mNetworkTypeController.areAnyTimersActive()); } @Test public void testPrimaryTimerDeviceIdleMode() throws Exception { doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState(); Loading