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

Commit ded15447 authored by Jack Yu's avatar Jack Yu
Browse files

Traffic descriptor only data profile should be enabled

If a data profile only contains traffic descriptor, and has no
APN setting, it should be considered enabled.

Fix: 233557423
Test: Manual + atest DataProfileTest
Change-Id: Idb671b67fbf3e9ed0f78654e5276a77fad5463d1
parent 229cbaf2
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.net.NetworkCapabilities;
import android.os.Parcel;
import android.telephony.data.ApnSetting;
import android.telephony.data.DataProfile;
import android.telephony.data.TrafficDescriptor;

import org.junit.Test;

@@ -99,6 +100,26 @@ public class DataProfileTest {
            .setMaxConnsTime(789)
            .build();

    // Disabled APN
    private ApnSetting mApn5 = new ApnSetting.Builder()
            .setId(2163)
            .setOperatorNumeric("12345")
            .setEntryName("fake_apn")
            .setApnName("fake_apn")
            .setUser("user")
            .setPassword("passwd")
            .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_SUPL)
            .setProtocol(ApnSetting.PROTOCOL_IPV6)
            .setRoamingProtocol(ApnSetting.PROTOCOL_IP)
            .setCarrierEnabled(false)
            .setNetworkTypeBitmask(0)
            .setProfileId(1234)
            .setMaxConns(321)
            .setWaitTime(456)
            .setMaxConnsTime(789)
            .build();


    @Test
    public void testCreateFromApnSetting() throws Exception {
        DataProfile dp = new DataProfile.Builder()
@@ -196,4 +217,26 @@ public class DataProfileTest {

        parcel.recycle();
    }

    @Test
    public void testIsEnabled() {
        TrafficDescriptor td = new TrafficDescriptor(null, new TrafficDescriptor.OsAppId(
                TrafficDescriptor.OsAppId.ANDROID_OS_ID, "ENTERPRISE", 1).getBytes());

        DataProfile dp = new DataProfile.Builder()
                .setApnSetting(mApn5)
                .setPreferred(false)
                .build();
        assertThat(dp.isEnabled()).isFalse();

        dp = new DataProfile.Builder()
                .setApnSetting(mApn1)
                .build();
        assertThat(dp.isEnabled()).isTrue();

        dp = new DataProfile.Builder()
                .setTrafficDescriptor(td)
                .build();
        assertThat(dp.isEnabled()).isTrue();
    }
}