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

Commit 64cbf70f authored by Jack Yu's avatar Jack Yu
Browse files

Fixed data disconnected for 10 seconds when disabling tethering

Before we always tear down the tethering data connection even
though the same data connection could be used for other
purposes (e.g. internet, mms). Now we don't do that if the
data connection can be shared for other purposes. Note that
we only do this for non-CDMA case.

Bug: 132322044
Bug: 131930219
Bug: 129387119

Test: Manual
Merged-In: I4061c4b86c09718d834a5dc16d24c52ed7801b0f
Change-Id: I4061c4b86c09718d834a5dc16d24c52ed7801b0f
(cherry picked from commit a40ce990)
parent 601913be
Loading
Loading
Loading
Loading
+11 −31
Original line number Diff line number Diff line
@@ -1663,20 +1663,15 @@ public class DcTracker extends Handler {
                if (dataConnection != null) {
                    if (apnContext.getState() != DctConstants.State.DISCONNECTING) {
                        boolean disconnectAll = false;
                        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)) {
                            if (teardownForDun()) {
                        if (PhoneConstants.APN_TYPE_DUN.equals(apnContext.getApnType())
                                && ServiceState.isCdma(getDataRat())) {
                            if (DBG) {
                                log("cleanUpConnectionInternal: disconnectAll 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
                                // to stop using it and let the normal apn list get used to find
                                // connections for the remaining desired connections
                            // For CDMA DUN, we need to tear it down immediately. A new data
                            // connection will be reestablished with correct profile id.
                            disconnectAll = true;
                        }
                        }
                        final int generation = apnContext.getConnectionGeneration();
                        str = "cleanUpConnectionInternal: tearing down"
                                + (disconnectAll ? " all" : "") + " using gen#" + generation;
@@ -1816,18 +1811,6 @@ public class DcTracker extends Handler {
        return null;
    }

    /**
     * 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 = getDataRat();
        if (ServiceState.isCdma(rilRat)) return true;

        ArrayList<ApnSetting> apns = fetchDunApns();
        return apns.size() > 0;
    }

    /**
     * Cancels the alarm associated with apnContext.
     *
@@ -2447,13 +2430,10 @@ public class DcTracker extends Handler {
                // 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 ((PhoneConstants.APN_TYPE_DUN.equals(apnContext.getApnType())
                        && teardownForDun())
                // This doesn't apply to DUN. When the user disable tethering, we would like to
                // detach the APN context from the data connection so the data connection can be
                // torn down if no other APN context attached to it.
                if (PhoneConstants.APN_TYPE_DUN.equals(apnContext.getApnType())
                        || apnContext.getState() != DctConstants.State.CONNECTED) {
                    str = "Clean up the connection. Apn type = " + apnContext.getApnType()
                            + ", state = " + apnContext.getState();