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

Commit 4a7f763a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed duplicate APN issue"

parents 1b704721 9543dc2d
Loading
Loading
Loading
Loading
+25 −50
Original line number Diff line number Diff line
@@ -1981,7 +1981,7 @@ public class DcTracker extends Handler {
        // this type.
        if (!apnContext.getApnType().equals(PhoneConstants.APN_TYPE_DUN)
                || ServiceState.isGsm(getDataRat())) {
            dataConnection = checkForCompatibleConnectedApnContext(apnContext);
            dataConnection = checkForCompatibleDataConnection(apnContext);
            if (dataConnection != null) {
                // Get the apn setting used by the data connection
                ApnSetting dataConnectionApnSetting = dataConnection.getApnSetting();
@@ -2309,7 +2309,7 @@ public class DcTracker extends Handler {
        setDataProfilesAsNeeded();
    }

    private DataConnection checkForCompatibleConnectedApnContext(ApnContext apnContext) {
    private DataConnection checkForCompatibleDataConnection(ApnContext apnContext) {
        int apnType = apnContext.getApnTypeBitmask();
        ArrayList<ApnSetting> dunSettings = null;

@@ -2317,73 +2317,48 @@ public class DcTracker extends Handler {
            dunSettings = sortApnListByPreferred(fetchDunApns());
        }
        if (DBG) {
            log("checkForCompatibleConnectedApnContext: apnContext=" + apnContext );
            log("checkForCompatibleDataConnection: apnContext=" + apnContext);
        }

        DataConnection potentialDc = null;
        ApnContext potentialApnCtx = null;
        for (ApnContext curApnCtx : mApnContexts.values()) {
            DataConnection curDc = curApnCtx.getDataConnection();
        for (DataConnection curDc : mDataConnections.values()) {
            if (curDc != null) {
                ApnSetting apnSetting = curApnCtx.getApnSetting();
                ApnSetting apnSetting = curDc.getApnSetting();
                log("apnSetting: " + apnSetting);
                if (dunSettings != null && dunSettings.size() > 0) {
                    for (ApnSetting dunSetting : dunSettings) {
                        if (dunSetting.equals(apnSetting)) {
                            switch (curApnCtx.getState()) {
                                case CONNECTED:
                            if (curDc.isActive()) {
                                if (DBG) {
                                        log("checkForCompatibleConnectedApnContext:"
                                                + " found dun conn=" + curDc
                                                + " curApnCtx=" + curApnCtx);
                                    log("checkForCompatibleDataConnection:"
                                            + " found dun conn=" + curDc);
                                }
                                return curDc;
                                case CONNECTING:
                            } else if (curDc.isActivating()) {
                                potentialDc = curDc;
                                    potentialApnCtx = curApnCtx;
                                    break;
                                default:
                                    // Not connected, potential unchanged
                                    break;
                            }
                        }
                    }
                } else if (apnSetting != null && apnSetting.canHandleType(apnType)) {
                    switch (curApnCtx.getState()) {
                        case CONNECTED:
                    if (curDc.isActive()) {
                        if (DBG) {
                                log("checkForCompatibleConnectedApnContext:"
                                        + " found canHandle conn=" + curDc
                                        + " curApnCtx=" + curApnCtx);
                            log("checkForCompatibleDataConnection:"
                                    + " found canHandle conn=" + curDc);
                        }
                        return curDc;
                        case CONNECTING:
                    } else if (curDc.isActivating()) {
                        potentialDc = curDc;
                            potentialApnCtx = curApnCtx;
                            break;
                        default:
                            // Not connected, potential unchanged
                            break;
                    }
                    }
            } else {
                if (VDBG) {
                    log("checkForCompatibleConnectedApnContext: not conn curApnCtx=" + curApnCtx);
                }
            }
        }
        if (potentialDc != null) {

        if (DBG) {
                log("checkForCompatibleConnectedApnContext: found potential conn=" + potentialDc
                        + " curApnCtx=" + potentialApnCtx);
            log("checkForCompatibleDataConnection: potential dc=" + potentialDc);
        }
        return potentialDc;
    }

        if (DBG) log("checkForCompatibleConnectedApnContext: NO conn apnContext=" + apnContext);
        return null;
    }

    private void addRequestNetworkCompleteMsg(Message onCompleteMsg,
                                              @ApnType int apnType) {
        if (onCompleteMsg != null) {