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

Commit 2b2c0162 authored by Malcolm Chen's avatar Malcolm Chen Committed by Xiangyu/Malcolm Chen
Browse files

Make sure on non-dds phone, try MMS data connection when PS is not

attached.

1) mAutoAttachEnabled is not updated for certain scenarios. So instead
of updating it true for non-dds case, we always check before setting up
data connection, that if it's on non-dds and voice is registered on
non-LTE network, if true we'll setup the data connection even if it's
not attached.

2) If data is not registered, we use voice rat to find the matching APN.
The criteria is APN supports a rat that maps to the same accessNetworkType
as voice rat.

Bug: 134086103
Test: manual
Change-Id: If3c80d5745b956f1c2b1b79d480bf2c2680d8923
parent 7b9367d2
Loading
Loading
Loading
Loading
+29 −22
Original line number Diff line number Diff line
@@ -1313,7 +1313,7 @@ public class DcTracker extends Handler {
            reasons.add(DataDisallowedReasonType.IN_ECBM);
        }

        if (!attachedState && !mAutoAttachEnabled.get() && requestType != REQUEST_TYPE_HANDOVER) {
        if (!attachedState && !shouldAutoAttach() && requestType != REQUEST_TYPE_HANDOVER) {
            reasons.add(DataDisallowedReasonType.NOT_ATTACHED);
        }
        if (!recordsLoaded) {
@@ -1481,6 +1481,9 @@ public class DcTracker extends Handler {
                apnContext.setState(DctConstants.State.IDLE);
            }
            int radioTech = getDataRat();
            if (radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
                radioTech = getVoiceRat();
            }
            log("service state=" + mPhone.getServiceState());
            apnContext.setConcurrentVoiceAndDataAllowed(mPhone.getServiceStateTracker()
                    .isConcurrentVoiceAndDataAllowed());
@@ -1754,8 +1757,8 @@ public class DcTracker extends Handler {
        }

        for (ApnSetting dunSetting : dunCandidates) {
            if (!ServiceState.bitmaskHasTech(dunSetting.getNetworkTypeBitmask(),
                    ServiceState.rilRadioTechnologyToNetworkType(bearer))) {
            if (!ServiceState.networkBitmaskHasAccessNetworkType(dunSetting.getNetworkTypeBitmask(),
                    ServiceState.rilRadioTechnologyToAccessNetworkType(bearer))) {
                continue;
            }
            retDunSettings.add(dunSetting);
@@ -2197,10 +2200,6 @@ public class DcTracker extends Handler {
        }
    }

    public boolean getAutoAttachEnabled() {
        return mAutoAttachEnabled.get();
    }

    private void onRecordsLoadedOrSubIdChanged() {
        if (DBG) log("onRecordsLoadedOrSubIdChanged: createAllApnList");
        if (mTransportType == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
@@ -3270,8 +3269,9 @@ public class DcTracker extends Handler {
                        + mPreferredApn.getOperatorNumeric() + ":" + mPreferredApn);
            }
            if (mPreferredApn.getOperatorNumeric().equals(operator)) {
                if (ServiceState.bitmaskHasTech(mPreferredApn.getNetworkTypeBitmask(),
                        ServiceState.rilRadioTechnologyToNetworkType(radioTech))) {
                if (ServiceState.networkBitmaskHasAccessNetworkType(
                        mPreferredApn.getNetworkTypeBitmask(),
                        ServiceState.rilRadioTechnologyToAccessNetworkType(radioTech))) {
                    apnList.add(mPreferredApn);
                    apnList = sortApnListByPreferred(apnList);
                    if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
@@ -3291,8 +3291,8 @@ public class DcTracker extends Handler {
        if (DBG) log("buildWaitingApns: mAllApnSettings=" + mAllApnSettings);
        for (ApnSetting apn : mAllApnSettings) {
            if (apn.canHandleType(requestedApnTypeBitmask)) {
                if (ServiceState.bitmaskHasTech(apn.getNetworkTypeBitmask(),
                        ServiceState.rilRadioTechnologyToNetworkType(radioTech))) {
                if (ServiceState.networkBitmaskHasAccessNetworkType(apn.getNetworkTypeBitmask(),
                        ServiceState.rilRadioTechnologyToAccessNetworkType(radioTech))) {
                    if (VDBG) log("buildWaitingApns: adding apn=" + apn);
                    apnList.add(apn);
                } else {
@@ -3861,7 +3861,7 @@ public class DcTracker extends Handler {
        log("update(): Active DDS, register for all events now!");
        onUpdateIcc();

        updateAutoAttachOnCreation();
        mAutoAttachEnabled.set(false);

        mPhone.updateCurrentCarrierInProvider();
    }
@@ -3872,20 +3872,17 @@ public class DcTracker extends Handler {
     * try setting up data call even if it's not attached for 2G or 3G networks. And doing so will
     * trigger PS attach if possible.
     */
    public void updateAutoAttachOnCreation() {
    @VisibleForTesting
    public boolean shouldAutoAttach() {
        if (mAutoAttachEnabled.get()) return true;

        PhoneSwitcher phoneSwitcher = PhoneSwitcher.getInstance();
        ServiceState serviceState = mPhone.getServiceState();
        if (PhoneSwitcher.getInstance() == null || serviceState == null) {
            mAutoAttachEnabled.set(false);
            return;
        }

        // If it's non DDS phone, and voice is registered on 2G or 3G network, we set
        // mAutoAttachEnabled to true.
        mAutoAttachEnabled.set(mPhone.getPhoneId() != phoneSwitcher.getPreferredDataPhoneId()
        return phoneSwitcher != null && serviceState != null
                && mPhone.getPhoneId() != phoneSwitcher.getPreferredDataPhoneId()
                && serviceState.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
                && serviceState.getVoiceNetworkType() != NETWORK_TYPE_LTE
                && serviceState.getVoiceNetworkType() != NETWORK_TYPE_NR);
                && serviceState.getVoiceNetworkType() != NETWORK_TYPE_NR;
    }

    private void notifyAllDataDisconnected() {
@@ -4827,4 +4824,14 @@ public class DcTracker extends Handler {
        }
        return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
    }

    private int getVoiceRat() {
        ServiceState ss = mPhone.getServiceState();
        NetworkRegistrationInfo nrs = ss.getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_CS, mTransportType);
        if (nrs != null) {
            return ServiceState.networkTypeToRilRadioTechnology(nrs.getAccessNetworkTechnology());
        }
        return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
    }
}
+0 −7
Original line number Diff line number Diff line
@@ -228,13 +228,6 @@ public class TelephonyNetworkFactory extends NetworkFactory {

    // apply or revoke requests if our active-ness changes
    private void onActivePhoneSwitch() {
        // For non DDS phone, mAutoAttachOnCreation should be true because it may be detached
        // automatically from network only because it's idle for too long. In this case, we should
        // try setting up data call even if it's not attached. And doing so will trigger PS attach
        // if possible.
        mPhone.getDcTracker(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .updateAutoAttachOnCreation();

        for (HashMap.Entry<NetworkRequest, Integer> entry : mNetworkRequests.entrySet()) {
            NetworkRequest networkRequest = entry.getKey();
            boolean applied = entry.getValue() != AccessNetworkConstants.TRANSPORT_TYPE_INVALID;
+2 −2
Original line number Diff line number Diff line
@@ -967,10 +967,10 @@ public class DcTrackerTest extends TelephonyTest {

        verifyDataConnected(FAKE_APN1);

        assertTrue(mDct.getAutoAttachEnabled());
        assertTrue(mDct.shouldAutoAttach());
        mDct.update();
        // The auto attach flag should be reset after update
        assertFalse(mDct.getAutoAttachEnabled());
        assertFalse(mDct.shouldAutoAttach());

        verify(mSST, times(1)).registerForDataConnectionDetached(
                eq(AccessNetworkConstants.TRANSPORT_TYPE_WWAN), eq(mDct),