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

Commit 1484bfe9 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Support bearer-specific DUN APN on CDMA

The DUN apn needs to be listed last, and this should only be used on networks
that don't show the apn editor.

bug:17571681
Change-Id: Iefa676d3c741ffb2eef201a8683429ed9dbe44d1
parent 1b2607bd
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1939,9 +1939,13 @@ public final class DataConnection extends StateMachine {
        }

        protected void unwanted() {
            if (mNetworkAgent != this) {
                log("unwanted found mNetworkAgent=" + mNetworkAgent +
                        ", which isn't me.  Aborting unwanted");
                return;
            }
            // this can only happen if our exit has been called - we're already disconnected
            if (mApnContexts == null) return;

            for (ApnContext apnContext : mApnContexts) {
                Message msg = mDct.obtainMessage(DctConstants.EVENT_DISCONNECT_DONE, apnContext);
                DisconnectParams dp = new DisconnectParams(apnContext, apnContext.getReason(), msg);
+38 −12
Original line number Diff line number Diff line
@@ -966,9 +966,7 @@ public final class DcTracker extends DcTrackerBase {
                        if (PhoneConstants.APN_TYPE_DUN.equals(apnContext.getApnType())) {
                            // CAF_MSIM is this below condition required.
                            // if (PhoneConstants.APN_TYPE_DUN.equals(PhoneConstants.APN_TYPE_DEFAULT)) {
                            ApnSetting dunSetting = fetchDunApn();
                            if (dunSetting != null &&
                                    dunSetting.equals(apnContext.getApnSetting())) {
                            if (teardownForDun()) {
                                if (DBG) log("tearing down dedicated DUN connection");
                                // we need to tear it down - we brought it up just for dun and
                                // other people are camped on it and now dun is done.  We need
@@ -1017,6 +1015,17 @@ public final class DcTracker extends DcTrackerBase {
        }
    }

    /**
     * Determine if DUN connection is special and we need to teardown on start/stop
     */
    private boolean teardownForDun() {
        // CDMA always needs to do this the profile id is correct
        final int rilRat = mPhone.getServiceState().getRilDataRadioTechnology();
        if (ServiceState.isCdma(rilRat)) return true;

        return (fetchDunApn() != null);
    }

    /**
     * Cancels the alarm associated with apnContext.
     *
@@ -1201,7 +1210,7 @@ public final class DcTracker extends DcTrackerBase {
    private boolean setupData(ApnContext apnContext, int radioTech) {
        if (DBG) log("setupData: apnContext=" + apnContext);
        ApnSetting apnSetting;
        DcAsyncChannel dcac;
        DcAsyncChannel dcac = null;

        apnSetting = apnContext.getNextWaitingApn();
        if (apnSetting == null) {
@@ -1214,6 +1223,12 @@ public final class DcTracker extends DcTrackerBase {
            profileId = getApnProfileID(apnContext.getApnType());
        }

        // On CDMA, if we're explicitly asking for DUN, we need have
        // a dun-profiled connection so we can't share an existing one
        // On GSM/LTE we can share existing apn connections provided they support
        // this type.
        if (apnContext.getApnType() != PhoneConstants.APN_TYPE_DUN ||
                teardownForDun() == false) {
            dcac = checkForCompatibleConnectedApnContext(apnContext);
            if (dcac != null) {
                // Get the dcacApnSetting for the connection we want to share.
@@ -1223,6 +1238,7 @@ public final class DcTracker extends DcTrackerBase {
                    apnSetting = dcacApnSetting;
                }
            }
        }
        if (dcac == null) {
            if (isOnlySingleDcAllowed(radioTech)) {
                if (isHigherPriorityApnContextActive(apnContext)) {
@@ -1509,7 +1525,17 @@ public final class DcTracker extends DcTrackerBase {
                // If ConnectivityService has disabled this network, stop trying to bring
                // it up, but do not tear it down - ConnectivityService will do that
                // directly by talking with the DataConnection.
                //
                // This doesn't apply to DUN, however.  Those connections have special
                // requirements from carriers and we need stop using them when the dun
                // request goes away.  This applies to both CDMA and GSM because they both
                // can declare the DUN APN sharable by default traffic, thus still satisfying
                // those requests and not torn down organically.
                if (apnContext.getApnType() == PhoneConstants.APN_TYPE_DUN && teardownForDun()) {
                    cleanup = true;
                } else {
                    cleanup = false;
                }
            } else {
                apnContext.setReason(Phone.REASON_DATA_DEPENDENCY_UNMET);
            }