Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 214fea45 authored by Ling Ma's avatar Ling Ma
Browse files

Clear cache upon radio off or unavailable

Clear all cache upon radio off or unavailable.

Test: voice call + data browsing
Fix: 313269921
Flag: Not needed as this is low risk bug fix
(go/android-flags-guidelines#flagging-policy)

Change-Id: I8fd6d33ef65bdf113dceb2e8bf426e81dd7c1a4f
parent bdb00c5b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -662,6 +662,11 @@ public class NetworkTypeController extends StateMachine {
                case EVENT_RADIO_OFF_OR_UNAVAILABLE:
                    if (DBG) log("Reset timers since radio is off or unavailable.");
                    resetAllTimers();
                    mRatchetedNrBands.clear();
                    mRatchetedNrBandwidths = 0;
                    mLastAnchorNrCellId = PhysicalChannelConfig.PHYSICAL_CELL_ID_UNKNOWN;
                    mDoesPccListIndicateIdle = false;
                    mPhysicalChannelConfigs = null;
                    transitionTo(mLegacyState);
                    break;
                case EVENT_PREFERRED_NETWORK_MODE_CHANGED:
+20 −3
Original line number Diff line number Diff line
@@ -958,15 +958,32 @@ public class NetworkTypeControllerTest extends TelephonyTest {

    @Test
    public void testEventRadioOffOrUnavailable() throws Exception {
        testTransitionToCurrentStateNrConnected();
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA,
                mNetworkTypeController.getOverrideNetworkType());
        mBundle.putBoolean(CarrierConfigManager.KEY_RATCHET_NR_ADVANCED_BANDWIDTH_IF_RRC_IDLE_BOOL,
                true);
        testTransitionToCurrentStateNrConnectedMmwaveWithAdditionalBandAndNoMmwaveNrNsa();

        // Radio off
        doReturn(NetworkRegistrationInfo.NR_STATE_NONE).when(mServiceState).getNrState();
        mNetworkTypeController.sendMessage(9 /* EVENT_RADIO_OFF_OR_UNAVAILABLE */);
        processAllMessages();

        assertEquals("legacy", getCurrentState().getName());
        assertEquals(TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE,
                mNetworkTypeController.getOverrideNetworkType());

        // NR connected: Primary serving NR PCC with cell ID = 1, band = none
        PhysicalChannelConfig pcc = new PhysicalChannelConfig.Builder()
                .setNetworkType(TelephonyManager.NETWORK_TYPE_NR)
                .setPhysicalCellId(1)
                .setCellConnectionStatus(CellInfo.CONNECTION_PRIMARY_SERVING)
                .build();

        mNetworkTypeController.sendMessage(11 /* EVENT_PHYSICAL_CHANNEL_CONFIGS_CHANGED */,
                new AsyncResult(null, List.of(pcc), null));
        doReturn(NetworkRegistrationInfo.NR_STATE_CONNECTED).when(mServiceState).getNrState();
        mNetworkTypeController.sendMessage(3 /* EVENT_SERVICE_STATE_CHANGED */);
        processAllMessages();
        assertEquals("connected", getCurrentState().getName());
    }

    @Test