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

Commit 389afecf authored by Jack Yu's avatar Jack Yu
Browse files

Reverted to the old logic for APN selection

Reverted to the old logic that we select APN based on
RAT, but adding a special handling for 2G cases. This can
deal with the case that some APN settings has EHRPD which
we incorrectly thought that APN setting can be used on CDMA
network.

Bug: 134086103
Test: Unit tests
Change-Id: I9aefefcaf3852075b32d774c1c5236bc336a9190
parent d6bdf0be
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.telephony.NetworkRegistrationInfo;
import android.telephony.PcoData;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.ServiceState.RilRadioTechnology;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
@@ -1757,8 +1758,8 @@ public class DcTracker extends Handler {
        }

        for (ApnSetting dunSetting : dunCandidates) {
            if (!ServiceState.networkBitmaskHasAccessNetworkType(dunSetting.getNetworkTypeBitmask(),
                    ServiceState.rilRadioTechnologyToAccessNetworkType(bearer))) {
            if (!dunSetting.canSupportNetworkType(
                    ServiceState.rilRadioTechnologyToNetworkType(bearer))) {
                continue;
            }
            retDunSettings.add(dunSetting);
@@ -3270,9 +3271,8 @@ public class DcTracker extends Handler {
                        + mPreferredApn.getOperatorNumeric() + ":" + mPreferredApn);
            }
            if (mPreferredApn.getOperatorNumeric().equals(operator)) {
                if (ServiceState.networkBitmaskHasAccessNetworkType(
                        mPreferredApn.getNetworkTypeBitmask(),
                        ServiceState.rilRadioTechnologyToAccessNetworkType(radioTech))) {
                if (mPreferredApn.canSupportNetworkType(
                        ServiceState.rilRadioTechnologyToNetworkType(radioTech))) {
                    apnList.add(mPreferredApn);
                    apnList = sortApnListByPreferred(apnList);
                    if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
@@ -3292,8 +3292,8 @@ public class DcTracker extends Handler {
        if (DBG) log("buildWaitingApns: mAllApnSettings=" + mAllApnSettings);
        for (ApnSetting apn : mAllApnSettings) {
            if (apn.canHandleType(requestedApnTypeBitmask)) {
                if (ServiceState.networkBitmaskHasAccessNetworkType(apn.getNetworkTypeBitmask(),
                        ServiceState.rilRadioTechnologyToAccessNetworkType(radioTech))) {
                if (apn.canSupportNetworkType(
                        ServiceState.rilRadioTechnologyToNetworkType(radioTech))) {
                    if (VDBG) log("buildWaitingApns: adding apn=" + apn);
                    apnList.add(apn);
                } else {
@@ -4816,6 +4816,7 @@ public class DcTracker extends Handler {
        return "UNKNOWN";
    }

    @RilRadioTechnology
    private int getDataRat() {
        ServiceState ss = mPhone.getServiceState();
        NetworkRegistrationInfo nrs = ss.getNetworkRegistrationInfo(
@@ -4826,6 +4827,7 @@ public class DcTracker extends Handler {
        return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
    }

    @RilRadioTechnology
    private int getVoiceRat() {
        ServiceState ss = mPhone.getServiceState();
        NetworkRegistrationInfo nrs = ss.getNetworkRegistrationInfo(
+72 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.net.Uri;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.test.suitebuilder.annotation.SmallTest;

@@ -684,4 +685,75 @@ public class ApnSettingTest extends TelephonyTest {
        assertTrue(apn1.equals(apn2, false));
        assertFalse(apn1.equals(apn2, true));
    }

    @Test
    @SmallTest
    public void testCanHandleNetwork() throws Exception {
        ApnSetting apn1 = ApnSetting.makeApnSetting(
                1234,
                "310260",
                "",
                "ims",
                null,
                -1,
                null,
                null,
                -1,
                "",
                "",
                -1,
                ApnSetting.TYPE_IMS,
                ApnSetting.PROTOCOL_IPV6,
                -1,
                true,
                (int) (TelephonyManager.NETWORK_TYPE_BITMASK_LTE
                        | TelephonyManager.NETWORK_TYPE_BITMASK_UMTS),
                0,
                false,
                0,
                0,
                0,
                1440,
                -1,
                "");

        ApnSetting apn2 = ApnSetting.makeApnSetting(
                1235,
                "310260",
                "",
                "ims",
                null,
                -1,
                null,
                null,
                -1,
                "",
                "",
                -1,
                ApnSetting.TYPE_IMS,
                ApnSetting.PROTOCOL_IPV6,
                ApnSetting.PROTOCOL_IPV6,
                true,
                (int) (TelephonyManager.NETWORK_TYPE_BITMASK_EDGE
                        | TelephonyManager.NETWORK_TYPE_BITMASK_GPRS),
                0,
                false,
                0,
                0,
                0,
                1440,
                -1,
                "");

        assertFalse(apn1.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_1xRTT));
        assertTrue(apn1.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_LTE));
        assertTrue(apn1.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_UMTS));

        assertFalse(apn2.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_1xRTT));
        assertFalse(apn2.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_LTE));
        assertTrue(apn2.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_GPRS));
        assertTrue(apn2.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_EDGE));

        assertTrue(apn2.canSupportNetworkType(TelephonyManager.NETWORK_TYPE_GSM));
    }
}