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

Commit 78b6e899 authored by Robert Greenwalt's avatar Robert Greenwalt
Browse files

Add support for DUN over a cdma connection.

It uses the data profile paramater when setting up the connection to indicate
it's a tethered connection.  We get different behavior from vzw afterwards, so
it is getting picked up.

bug:2422545
Change-Id: Ic022845088726d723813b82e166d15d7b2945da1
parent ceffa159
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ import android.os.Message;
import android.util.Log;
import android.util.Log;


import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.gsm.ApnSetting;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RILConstants;


/**
/**
@@ -71,12 +73,20 @@ public class CdmaDataConnection extends DataConnection {
        createTime = -1;
        createTime = -1;
        lastFailTime = -1;
        lastFailTime = -1;
        lastFailCause = FailCause.NONE;
        lastFailCause = FailCause.NONE;
        int dataProfile;
        if ((cp.apn != null) && (cp.apn.types.length > 0) && (cp.apn.types[0] != null) &&
                (cp.apn.types[0].equals(Phone.APN_TYPE_DUN))) {
            if (DBG) log("CdmaDataConnection using DUN");
            dataProfile = RILConstants.DATA_PROFILE_TETHERED;
        } else {
            dataProfile = RILConstants.DATA_PROFILE_DEFAULT;
        }


        // msg.obj will be returned in AsyncResult.userObj;
        // msg.obj will be returned in AsyncResult.userObj;
        Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
        Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
        msg.obj = cp;
        msg.obj = cp;
        phone.mCM.setupDataCall(Integer.toString(RILConstants.SETUP_DATA_TECH_CDMA),
        phone.mCM.setupDataCall(Integer.toString(RILConstants.SETUP_DATA_TECH_CDMA),
                Integer.toString(RILConstants.DATA_PROFILE_DEFAULT), null, null,
                Integer.toString(dataProfile), null, null,
                null, Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP), msg);
                null, Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP), msg);
    }
    }


+24 −14
Original line number Original line Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.internal.telephony.DataConnection.FailCause;
import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.DataConnection;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.DataConnectionTracker;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.EventLogTags;
import com.android.internal.telephony.gsm.ApnSetting;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.RetryManager;
import com.android.internal.telephony.RetryManager;
import com.android.internal.telephony.ServiceStateTracker;
import com.android.internal.telephony.ServiceStateTracker;
@@ -77,9 +78,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
    /** Currently active CdmaDataConnection */
    /** Currently active CdmaDataConnection */
    private CdmaDataConnection mActiveDataConnection;
    private CdmaDataConnection mActiveDataConnection;


    /** mimic of GSM's mActiveApn */
    private boolean mIsApnActive = false;

    private boolean mPendingRestartRadio = false;
    private boolean mPendingRestartRadio = false;
    private static final int TIME_DELAYED_TO_RESTART_RADIO =
    private static final int TIME_DELAYED_TO_RESTART_RADIO =
            SystemProperties.getInt("ro.cdma.timetoradiorestart", 60000);
            SystemProperties.getInt("ro.cdma.timetoradiorestart", 60000);
@@ -108,6 +106,14 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
            Phone.APN_TYPE_DUN,
            Phone.APN_TYPE_DUN,
            Phone.APN_TYPE_HIPRI };
            Phone.APN_TYPE_HIPRI };


    private static final String[] mDefaultApnTypes = {
            Phone.APN_TYPE_DEFAULT,
            Phone.APN_TYPE_MMS,
            Phone.APN_TYPE_HIPRI };

    // if we have no active Apn this is null
    protected ApnSetting mActiveApn;

    // Possibly promoate to base class, the only difference is
    // Possibly promoate to base class, the only difference is
    // the INTENT_RECONNECT_ALARM action is a different string.
    // the INTENT_RECONNECT_ALARM action is a different string.
    // Do consider technology changes if it is promoted.
    // Do consider technology changes if it is promoted.
@@ -250,7 +256,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {


    @Override
    @Override
    protected boolean isApnTypeActive(String type) {
    protected boolean isApnTypeActive(String type) {
        return (mIsApnActive && isApnTypeAvailable(type));
        return mActiveApn != null && mActiveApn.canHandleType(type);
    }
    }


    @Override
    @Override
@@ -265,10 +271,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {


    protected String[] getActiveApnTypes() {
    protected String[] getActiveApnTypes() {
        String[] result;
        String[] result;
        if (mIsApnActive) {
        if (mActiveApn != null) {
            result = mSupportedApnTypes.clone();
            result = mActiveApn.types;
        } else {
        } else {
            // TODO - should this return an empty array?  See GSM too.
            result = new String[1];
            result = new String[1];
            result[0] = Phone.APN_TYPE_DEFAULT;
            result[0] = Phone.APN_TYPE_DEFAULT;
        }
        }
@@ -414,7 +419,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
    }
    }


    private boolean setupData(String reason) {
    private boolean setupData(String reason) {

        CdmaDataConnection conn = findFreeDataConnection();
        CdmaDataConnection conn = findFreeDataConnection();


        if (conn == null) {
        if (conn == null) {
@@ -423,12 +427,19 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        }
        }


        mActiveDataConnection = conn;
        mActiveDataConnection = conn;
        mIsApnActive = true;
        String[] types;
        if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) {
            types = new String[1];
            types[0] = Phone.APN_TYPE_DUN;
        } else {
            types = mDefaultApnTypes;
        }
        mActiveApn = new ApnSetting(0, "", "", "", "", "", "", "", "", "", "", 0, types);


        Message msg = obtainMessage();
        Message msg = obtainMessage();
        msg.what = EVENT_DATA_SETUP_COMPLETE;
        msg.what = EVENT_DATA_SETUP_COMPLETE;
        msg.obj = reason;
        msg.obj = reason;
        conn.connect(msg);
        conn.connect(msg, mActiveApn);


        setState(State.INITING);
        setState(State.INITING);
        phone.notifyDataConnection(reason);
        phone.notifyDataConnection(reason);
@@ -627,7 +638,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        if (DBG) log("gotoIdleAndNotifyDataConnection: reason=" + reason);
        if (DBG) log("gotoIdleAndNotifyDataConnection: reason=" + reason);
        setState(State.IDLE);
        setState(State.IDLE);
        phone.notifyDataConnection(reason);
        phone.notifyDataConnection(reason);
        mIsApnActive = false;
        mActiveApn = null;
    }
    }


    protected void onRecordsLoaded() {
    protected void onRecordsLoaded() {
@@ -649,8 +660,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
     */
     */
    @Override
    @Override
    protected void onEnableNewApn() {
    protected void onEnableNewApn() {
        // for cdma we only use this when default data is enabled..
          cleanUpConnection(true, Phone.REASON_APN_SWITCHED);
        onTrySetupData(Phone.REASON_DATA_ENABLED);
    }
    }


    /**
    /**
@@ -763,7 +773,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
        }
        }


        phone.notifyDataConnection(reason);
        phone.notifyDataConnection(reason);
        mIsApnActive = false;
        mActiveApn = null;
        if (retryAfterDisconnected(reason)) {
        if (retryAfterDisconnected(reason)) {
          trySetupData(reason);
          trySetupData(reason);
      }
      }
+3 −3
Original line number Original line Diff line number Diff line
@@ -32,12 +32,12 @@ public class ApnSetting {
    String user;
    String user;
    String password;
    String password;
    int authType;
    int authType;
    String[] types;
    public String[] types;
    int id;
    int id;
    String numeric;
    String numeric;




    ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port,
    public ApnSetting(int id, String numeric, String carrier, String apn, String proxy, String port,
            String mmsc, String mmsProxy, String mmsPort,
            String mmsc, String mmsProxy, String mmsPort,
            String user, String password, int authType, String[] types) {
            String user, String password, int authType, String[] types) {
        this.id = id;
        this.id = id;
@@ -73,7 +73,7 @@ public class ApnSetting {
        return sb.toString();
        return sb.toString();
    }
    }


    boolean canHandleType(String type) {
    public boolean canHandleType(String type) {
        for (String t : types) {
        for (String t : types) {
            // DEFAULT handles all, and HIPRI is handled by DEFAULT
            // DEFAULT handles all, and HIPRI is handled by DEFAULT
            if (t.equals(type) || t.equals(Phone.APN_TYPE_ALL) ||
            if (t.equals(type) || t.equals(Phone.APN_TYPE_ALL) ||