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

Commit 68d40d4b authored by Ling Ma's avatar Ling Ma
Browse files

Don't add default IMS data profile before SIM loaded

Originally, before SIM loaded, or before TelephonyProvider database
finds any APN settings, default IMS data profile is added.

However, the default IMS data profile is prepared for the case where a SIM/carrier didn't
specify IMS.

The fix is to add the default IMS profile only when the detabase loaded
some data profile; otherwise, it means the SIM hasn't been read properly, in that case we do nothing but wait for SIM to be read.

Bug: 241121008
Test: atest
Change-Id: Ifbad8359db98dadabc754514f6f8038b1415200f
Merged-In: Ifbad8359db98dadabc754514f6f8038b1415200f
parent 2b02b5c6
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -285,20 +285,9 @@ public class DataProfileManager extends Handler {
            }
        }

        // Check if any of the profile already supports ENTERPRISE, if not, check if DPC has
        // configured one and retrieve the same.
        DataProfile dataProfile = profiles.stream()
                .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE))
                .findFirst()
                .orElse(null);
        if (dataProfile == null) {
            dataProfile = getEnterpriseDataProfile();
            if (dataProfile != null) {
                profiles.add(dataProfile);
                log("Added enterprise profile " + dataProfile);
            }
        }
        DataProfile dataProfile;

        if (!profiles.isEmpty()) { // APN database has been read successfully after SIM loaded
            // Check if any of the profile already supports IMS, if not, add the default one.
            dataProfile = profiles.stream()
                    .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS))
@@ -312,6 +301,21 @@ public class DataProfileManager extends Handler {
                        .build());
                log("Added default IMS data profile.");
            }
        }

        // Check if any of the profile already supports ENTERPRISE, if not, check if DPC has
        // configured one and retrieve the same.
        dataProfile = profiles.stream()
                .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_ENTERPRISE))
                .findFirst()
                .orElse(null);
        if (dataProfile == null) {
            dataProfile = getEnterpriseDataProfile();
            if (dataProfile != null) {
                profiles.add(dataProfile);
                log("Added enterprise profile " + dataProfile);
            }
        }

        // Check if any of the profile already supports EIMS, if not, add the default one.
        dataProfile = profiles.stream()
+3 −1
Original line number Diff line number Diff line
@@ -718,6 +718,7 @@ public class DataProfileManagerTest extends TelephonyTest {
                tnr, TelephonyManager.NETWORK_TYPE_LTE);
        assertThat(dataProfile).isNull();

        // expect default EIMS when SIM absent
        tnr = new TelephonyNetworkRequest(
                new NetworkRequest.Builder()
                        .addCapability(NetworkCapabilities.NET_CAPABILITY_EIMS)
@@ -726,13 +727,14 @@ public class DataProfileManagerTest extends TelephonyTest {
                tnr, TelephonyManager.NETWORK_TYPE_LTE);
        assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo("sos");

        // expect no default IMS when SIM absent
        tnr = new TelephonyNetworkRequest(
                new NetworkRequest.Builder()
                        .addCapability(NetworkCapabilities.NET_CAPABILITY_IMS)
                        .build(), mPhone);
        dataProfile = mDataProfileManagerUT.getDataProfileForNetworkRequest(
                tnr, TelephonyManager.NETWORK_TYPE_LTE);
        assertThat(dataProfile.getApnSetting().getApnName()).isEqualTo("ims");
        assertThat(dataProfile).isEqualTo(null);
    }

    @Test