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

Commit 2cc19b1c authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Use shared connections over retries.

Old code would detect we were in a retry loop and ignore other active
connections we could share.  We really want live shared connections to
dominate over retrying disconnected ones.

bug:5525764
Change-Id: If93383c52024113eec595b31e46897d1fcabc44c
parent 01583ef7
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ public class GsmDataConnection extends DataConnection {

    //***** Instance Variables
    protected int mProfileId = RILConstants.DATA_PROFILE_DEFAULT;
    protected String mActiveApnType = Phone.APN_TYPE_DEFAULT;
    //***** Constructor
    private GsmDataConnection(PhoneBase phone, String name, int id, RetryManager rm) {
        super(phone, name, id, rm);
@@ -113,10 +112,6 @@ public class GsmDataConnection extends DataConnection {
        return mProfileId;
    }

    public void setActiveApnType(String apnType) {
        mActiveApnType = apnType;
    }

    @Override
    public String toString() {
        return "State=" + getCurrentState().getName() + " Apn=" + mApn +
+43 −28
Original line number Diff line number Diff line
@@ -993,17 +993,11 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
            return false;
        }

        // First, check to see if ApnContext already has DC.
        // This could happen if the retries are currently  engaged.
        dc = (GsmDataConnection)apnContext.getDataConnection();

        if (dc == null) {

        dc = (GsmDataConnection) checkForConnectionForApnContext(apnContext);

        if (dc == null) {
            dc = findReadyDataConnection(apn);
            }

            if (dc == null) {
                if (DBG) log("setupData: No ready GsmDataConnection found!");
@@ -1020,10 +1014,13 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
                if (DBG) log("setupData: No free GsmDataConnection found!");
                return false;
            }
        } else {
            apn = mDataConnectionAsyncChannels.get(dc.getDataConnectionId()).getApnSettingSync();
        }

        DataConnectionAc dcac = mDataConnectionAsyncChannels.get(dc.getDataConnectionId());
            dc.setProfileId( profileId );
            dc.setActiveApnType(apnContext.getApnType());
        dc.setProfileId( profileId );  //  assumed no connection sharing on profiled types

        int refCount = dcac.getRefCountSync();
        if (DBG) log("setupData: init dc and apnContext refCount=" + refCount);

@@ -1033,7 +1030,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
        }
        apnContext.setDataConnectionAc(dcac);
        apnContext.setDataConnection(dc);
        }

        apnContext.setApnSetting(apn);
        apnContext.setState(State.INITING);
@@ -1732,27 +1728,46 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
            dunSetting = fetchDunApn();
        }

        DataConnection potential = null;
        for (ApnContext c : mApnContexts.values()) {
            DataConnection conn = c.getDataConnection();
            if (conn != null) {
                ApnSetting apnSetting = c.getApnSetting();
                if (dunSetting != null) {
                    if (dunSetting.equals(apnSetting)) {
                        switch (c.getState()) {
                            case CONNECTED:
                                if (DBG) {
                            log("checkForConnectionForApnContext: apnContext=" + apnContext +
                                    " found conn=" + conn);
                                    log("checkForConnectionForApnContext: apnContext=" +
                                            apnContext + " found conn=" + conn);
                                }
                                return conn;
                            case CONNECTING:
                                potential = conn;
                        }
                    }
                } else if (apnSetting != null && apnSetting.canHandleType(apnType)) {
                    switch (c.getState()) {
                        case CONNECTED:
                            if (DBG) {
                                log("checkForConnectionForApnContext: apnContext=" + apnContext +
                                        " found conn=" + conn);
                            }
                            return conn;
                        case CONNECTING:
                            potential = conn;
                    }
                }
            }
        }
        if (potential != null) {
            if (DBG) {
                log("checkForConnectionForApnContext: apnContext=" + apnContext +
                    " found conn=" + potential);
            }
            return potential;
        }

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