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

Commit 86b8b812 authored by David Ferguson's avatar David Ferguson
Browse files

telephony: when building apn list, use preferred apn if it can handle requested type

GsmDataConnectionTracker::setupData() does not consult TelephonyProvider when it
picks an APN for mms. It just uses apnContext.getNextWaitingApn() which picks the
first one in the list. On AT&T it picks wap.cingular, which is wrong for LTE.

Since the data connection is made properly, setupData() stops scanning and never
tries the correct APN (pta). The result is sending of the mms just hangs.

This change causes GsmDataConnectionTracker::buildWaitingApns() to first try the
currently active APN if it can handle the type of APN being requested, then it
tried the preferred APN and then the rest of the APN's, in that order.

This fixes the MMS problem since the correct APN (pta) is chosen.

Change-Id: I076b88d42f59241cf468d678ad0e628d0f2d9e8d
parent f305d1a2
Loading
Loading
Loading
Loading
+31 −5
Original line number Diff line number Diff line
@@ -1365,6 +1365,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                + ", reason:" + apnContext.getReason());
        }
        apnContext.setState(State.CONNECTED);
        mActiveApn = apnContext.getApnSetting();

        // setState(State.CONNECTED);
        mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
        startNetStatPoll();
@@ -2393,15 +2395,39 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                }
            }
        }

        // If the currently active data connect can handle the requested type, try it first
        if ((mActiveApn != null) && mActiveApn.canHandleType(requestedApnType)) {
            if (DBG) log("buildWaitingApns: X added already active apnList=" + apnList);
            apnList.add(mActiveApn);
        }

        if (mAllApns != null) {
            // Use the preferred APN if it can handle the type being requested
            if (canSetPreferApn && mPreferredApn != null) {
                if (DBG) {
                    log("buildWaitingApns: Preferred APN:" + operator + ":"
                        + mPreferredApn.numeric + ":" + mPreferredApn);
                }
                if ((mPreferredApn.numeric.equals(operator) && mPreferredApn.canHandleType(requestedApnType)) &&
                    (mPreferredApn.bearer == 0 || mPreferredApn.bearer == radioTech) && 
                    !apnList.contains(mPreferredApn))
                {
                    apnList.add(mPreferredApn);
                    if (DBG) log("buildWaitingApns: X added preferred apnList=" + apnList);
                }
            }

            // Add all the rest of the apns that can handle the requested type
            for (ApnSetting apn : mAllApns) {
                if (apn.canHandleType(requestedApnType)) {
                    if (apn.bearer == 0 || apn.bearer == radioTech) {
                if ((apn.canHandleType(requestedApnType)) &&
                    (apn.bearer == 0 || apn.bearer == radioTech) &&
                    !apnList.contains(apn))
                {
                    if (DBG) log("apn info : " +apn.toString());
                    apnList.add(apn);
                }
            }
            }
        } else {
            loge("mAllApns is empty!");
        }