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

Commit 1dedaf61 authored by Jack Yu's avatar Jack Yu Committed by Android Build Coastguard Worker
Browse files

Fixed a crash when data network does not have PCO

Avoid crash when PCO data arrives, but it's only for certain data
networks but not all, it will crash in data network controller
when trying get PCO data from each network.

Test: Able to repro with unit test. Verified working after fix.
Fix: 242768045
Merged-In: I832ddcc80f4e92d487bd0fa93ec63f74e4978de3
Change-Id: I832ddcc80f4e92d487bd0fa93ec63f74e4978de3
(cherry picked from commit 06c7cada)
Merged-In: I832ddcc80f4e92d487bd0fa93ec63f74e4978de3
parent c1b6f39d
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -3180,14 +3180,14 @@ public class DataNetwork extends StateMachine {


    /**
    /**
     * @return The PCO data map of the network. The key is the PCO id, the value is the PCO data.
     * @return The PCO data map of the network. The key is the PCO id, the value is the PCO data.
     * An empty map if PCO data is not available.
     * An empty map if PCO data is not available (or when the network is on IWLAN).
     */
     */
    public @NonNull Map<Integer, PcoData> getPcoData() {
    public @NonNull Map<Integer, PcoData> getPcoData() {
        if (mTransport == AccessNetworkConstants.TRANSPORT_TYPE_WLAN
        if (mTransport == AccessNetworkConstants.TRANSPORT_TYPE_WLAN
                || mCid.get(mTransport) == INVALID_CID) {
                || mCid.get(mTransport) == INVALID_CID) {
            return Collections.emptyMap();
            return Collections.emptyMap();
        }
        }
        return mPcoData.get(mCid.get(mTransport));
        return mPcoData.getOrDefault(mCid.get(mTransport), Collections.emptyMap());
    }
    }


    /**
    /**
+14 −0
Original line number Original line Diff line number Diff line
@@ -2368,6 +2368,20 @@ public class DataNetworkControllerTest extends TelephonyTest {
        verify(mMockedDataNetworkControllerCallback).onNrAdvancedCapableByPcoChanged(eq(true));
        verify(mMockedDataNetworkControllerCallback).onNrAdvancedCapableByPcoChanged(eq(true));
    }
    }


    @Test
    public void testNrAdvancedByPcoMultipleNetworks() throws Exception {
        testSetupDataNetwork();
        setSuccessfulSetupDataResponse(mMockedDataServiceManagers
                .get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN), 2);
        testSetupImsDataNetwork();

        verify(mMockedDataNetworkControllerCallback, never())
                .onNrAdvancedCapableByPcoChanged(anyBoolean());
        mSimulatedCommands.triggerPcoData(2, "IPV6", 1234, new byte[]{1});
        processAllMessages();
        verify(mMockedDataNetworkControllerCallback).onNrAdvancedCapableByPcoChanged(eq(true));
    }

    @Test
    @Test
    public void testNrAdvancedByEarlyUnrelatedPco() {
    public void testNrAdvancedByEarlyUnrelatedPco() {
        Mockito.reset(mMockedWwanDataServiceManager);
        Mockito.reset(mMockedWwanDataServiceManager);