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

Commit 1fba3c1b authored by Jack Yu's avatar Jack Yu
Browse files

Apply slicing capabilities before connected

Slicing related capaiblities used to be set from the traffic
descriptors from modem after connected. This causes network
requests unexpectedly detached in connecting state. Fixed by
applying the capability from data profile's traffic descriptor.
This will grant the slicing capabilities while the data network
is still in connecting state.

Fix: 228107174
Test: atest DataNetworkTest
Change-Id: Ia15ce221847ce9cc00aa5d858d00f69d2dd077f9
parent 3c8a478a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -819,6 +819,12 @@ public class DataNetwork extends StateMachine {
        mDataCallSessionStats = new DataCallSessionStats(mPhone);
        mDataNetworkCallback = callback;
        mDataProfile = dataProfile;
        if (dataProfile.getTrafficDescriptor() != null) {
            // The initial traffic descriptor is from the data profile. After that traffic
            // descriptors will be updated by modem through setup data call response and data call
            // list changed event.
            mTrafficDescriptors.add(dataProfile.getTrafficDescriptor());
        }
        mTransport = transport;
        mDataAllowedReason = dataAllowedReason;
        dataProfile.setLastSetupTimestamp(SystemClock.elapsedRealtime());
+80 −0
Original line number Diff line number Diff line
@@ -162,6 +162,12 @@ public class DataNetworkTest extends TelephonyTest {
                            "PRIORITIZE_BANDWIDTH", 1).getBytes()))
            .build();

    private final DataProfile mCbsDataProfile = new DataProfile.Builder()
            .setTrafficDescriptor(new TrafficDescriptor(null,
                    new TrafficDescriptor.OsAppId(TrafficDescriptor.OsAppId.ANDROID_OS_ID,
                            "CBS", 1).getBytes()))
            .build();

    // Mocked classes
    private DataNetworkCallback mDataNetworkCallback;
    private DataCallSessionStats mDataCallSessionStats;
@@ -543,6 +549,80 @@ public class DataNetworkTest extends TelephonyTest {
                .isTrue();
    }

    @Test
    public void testCreateDataNetworkOnCbsSlice() throws Exception {
        DataNetworkController.NetworkRequestList
                networkRequestList = new DataNetworkController.NetworkRequestList();
        networkRequestList.add(new TelephonyNetworkRequest(new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_CBS)
                .build(), mPhone));

        List<TrafficDescriptor> tds = List.of(
                new TrafficDescriptor(null, new TrafficDescriptor.OsAppId(
                        TrafficDescriptor.OsAppId.ANDROID_OS_ID, "CBS", 1)
                        .getBytes())
        );

        setSuccessfulSetupDataResponse(mMockedWwanDataServiceManager, 123, tds);

        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
                mCbsDataProfile, networkRequestList,
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                mDataNetworkCallback);
        replaceInstance(DataNetwork.class, "mDataCallSessionStats",
                mDataNetworkUT, mDataCallSessionStats);
        sendServiceStateChangedEvent(ServiceState.STATE_IN_SERVICE,
                ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN);

        processAllMessages();

        verify(mMockedWwanDataServiceManager).setupDataCall(eq(AccessNetworkType.EUTRAN),
                eq(mCbsDataProfile), eq(false), eq(false),
                eq(DataService.REQUEST_REASON_NORMAL), nullable(LinkProperties.class),
                eq(DataCallResponse.PDU_SESSION_ID_NOT_SET), nullable(NetworkSliceInfo.class),
                any(TrafficDescriptor.class), eq(false), any(Message.class));

        NetworkCapabilities nc = mDataNetworkUT.getNetworkCapabilities();
        assertThat(nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_CBS))
                .isTrue();
    }

    @Test
    public void testSlicingDataNetworkHasSlicingCapabilitiesBeforeConnected() throws Exception {
        DataNetworkController.NetworkRequestList
                networkRequestList = new DataNetworkController.NetworkRequestList();
        networkRequestList.add(new TelephonyNetworkRequest(new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_CBS)
                .build(), mPhone));

        List<TrafficDescriptor> tds = List.of(
                new TrafficDescriptor(null, new TrafficDescriptor.OsAppId(
                        TrafficDescriptor.OsAppId.ANDROID_OS_ID, "CBS", 1)
                        .getBytes())
        );

        mDataNetworkUT = new DataNetwork(mPhone, Looper.myLooper(), mDataServiceManagers,
                mCbsDataProfile, networkRequestList,
                AccessNetworkConstants.TRANSPORT_TYPE_WWAN, DataAllowedReason.NORMAL,
                mDataNetworkCallback);
        replaceInstance(DataNetwork.class, "mDataCallSessionStats",
                mDataNetworkUT, mDataCallSessionStats);
        sendServiceStateChangedEvent(ServiceState.STATE_IN_SERVICE,
                ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN);

        processAllMessages();

        // Didn't call setSuccessfulSetupDataResponse, so data network should stuck in connecting.

        // Verify the network has the right capability at beginning.
        NetworkCapabilities nc = mDataNetworkUT.getNetworkCapabilities();
        assertThat(nc.hasCapability(NetworkCapabilities.NET_CAPABILITY_CBS))
                .isTrue();

        // Verify the network was not detached due to not satisfied.
        assertThat(networkRequestList).isEqualTo(mDataNetworkUT.getAttachedNetworkRequestList());
    }

    // The purpose of this test is to make sure data could be torn down properly.
    @Test
    public void testTearDown() throws Exception {