FileDocCategorySizeDatePackage
DcAsyncChannel.javaAPI DocAndroid 5.1 API14961Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.dataconnection

DcAsyncChannel

public class DcAsyncChannel extends com.android.internal.util.AsyncChannel
AsyncChannel to a DataConnection

Fields Summary
private static final boolean
DBG
private String
mLogTag
private DataConnection
mDc
private long
mDcThreadId
public static final int
BASE
public static final int
REQ_IS_INACTIVE
public static final int
RSP_IS_INACTIVE
public static final int
REQ_GET_CID
public static final int
RSP_GET_CID
public static final int
REQ_GET_APNSETTING
public static final int
RSP_GET_APNSETTING
public static final int
REQ_GET_LINK_PROPERTIES
public static final int
RSP_GET_LINK_PROPERTIES
public static final int
REQ_SET_LINK_PROPERTIES_HTTP_PROXY
public static final int
RSP_SET_LINK_PROPERTIES_HTTP_PROXY
public static final int
REQ_GET_NETWORK_CAPABILITIES
public static final int
RSP_GET_NETWORK_CAPABILITIES
public static final int
REQ_RESET
public static final int
RSP_RESET
private static final int
CMD_TO_STRING_COUNT
private static String[]
sCmdToString
Constructors Summary
public DcAsyncChannel(DataConnection dc, String logTag)

        mDc = dc;
        mDcThreadId = mDc.getHandler().getLooper().getThread().getId();
        mLogTag = logTag;
    
Methods Summary
public voidbringUp(ApnContext apnContext, int initialMaxRetry, int profileId, int rilRadioTechnology, boolean retryWhenSSChange, android.os.Message onCompletedMsg)
Bring up a connection to the apn and return an AsyncResult in onCompletedMsg. Used for cellular networks that use Acesss Point Names (APN) such as GSM networks.

param
apnContext is the Access Point Name to bring up a connection to
param
initialMaxRetry the number of retires for initial bringup.
param
profileId for the conneciton
param
onCompletedMsg is sent with its msg.obj as an AsyncResult object. With AsyncResult.userObj set to the original msg.obj, AsyncResult.result = FailCause and AsyncResult.exception = Exception().

        if (DBG) {
            log("bringUp: apnContext=" + apnContext + " initialMaxRetry=" + initialMaxRetry
                + " onCompletedMsg=" + onCompletedMsg);
        }
        sendMessage(DataConnection.EVENT_CONNECT,
                    new ConnectionParams(apnContext, initialMaxRetry, profileId,
                            rilRadioTechnology, retryWhenSSChange, onCompletedMsg));
    
protected static java.lang.StringcmdToString(int cmd)

     
        sCmdToString[REQ_IS_INACTIVE - BASE] = "REQ_IS_INACTIVE";
        sCmdToString[RSP_IS_INACTIVE - BASE] = "RSP_IS_INACTIVE";
        sCmdToString[REQ_GET_CID - BASE] = "REQ_GET_CID";
        sCmdToString[RSP_GET_CID - BASE] = "RSP_GET_CID";
        sCmdToString[REQ_GET_APNSETTING - BASE] = "REQ_GET_APNSETTING";
        sCmdToString[RSP_GET_APNSETTING - BASE] = "RSP_GET_APNSETTING";
        sCmdToString[REQ_GET_LINK_PROPERTIES - BASE] = "REQ_GET_LINK_PROPERTIES";
        sCmdToString[RSP_GET_LINK_PROPERTIES - BASE] = "RSP_GET_LINK_PROPERTIES";
        sCmdToString[REQ_SET_LINK_PROPERTIES_HTTP_PROXY - BASE] =
                "REQ_SET_LINK_PROPERTIES_HTTP_PROXY";
        sCmdToString[RSP_SET_LINK_PROPERTIES_HTTP_PROXY - BASE] =
                "RSP_SET_LINK_PROPERTIES_HTTP_PROXY";
        sCmdToString[REQ_GET_NETWORK_CAPABILITIES - BASE] = "REQ_GET_NETWORK_CAPABILITIES";
        sCmdToString[RSP_GET_NETWORK_CAPABILITIES - BASE] = "RSP_GET_NETWORK_CAPABILITIES";
        sCmdToString[REQ_RESET - BASE] = "REQ_RESET";
        sCmdToString[RSP_RESET - BASE] = "RSP_RESET";
    
        cmd -= BASE;
        if ((cmd >= 0) && (cmd < sCmdToString.length)) {
            return sCmdToString[cmd];
        } else {
            return AsyncChannel.cmdToString(cmd + BASE);
        }
    
public ApnSettinggetApnSettingSync()
Get the connections ApnSetting.

return
ApnSetting or null if an error

        ApnSetting value;
        if (isCallerOnDifferentThread()) {
            Message response = sendMessageSynchronously(REQ_GET_APNSETTING);
            if ((response != null) && (response.what == RSP_GET_APNSETTING)) {
                value = rspApnSetting(response);
            } else {
                log("getApnSetting error response=" + response);
                value = null;
            }
        } else {
            value = mDc.getApnSetting();
        }
        return value;
    
public intgetCidSync()

return
connection id or -1 if an error

        int value;
        if (isCallerOnDifferentThread()) {
            Message response = sendMessageSynchronously(REQ_GET_CID);
            if ((response != null) && (response.what == RSP_GET_CID)) {
                value = rspCid(response);
            } else {
                log("rspCid error response=" + response);
                value = -1;
            }
        } else {
            value = mDc.getCid();
        }
        return value;
    
public intgetDataConnectionIdSync()

return
connection id

        // Safe because this is owned by the caller.
        return mDc.getDataConnectionId();
    
public android.net.LinkPropertiesgetLinkPropertiesSync()
Get the connections LinkProperties.

return
LinkProperties or null if an error

        LinkProperties value;
        if (isCallerOnDifferentThread()) {
            Message response = sendMessageSynchronously(REQ_GET_LINK_PROPERTIES);
            if ((response != null) && (response.what == RSP_GET_LINK_PROPERTIES)) {
                value = rspLinkProperties(response);
            } else {
                log("getLinkProperties error response=" + response);
                value = null;
            }
        } else {
            value = mDc.getCopyLinkProperties();
        }
        return value;
    
public android.net.NetworkCapabilitiesgetNetworkCapabilitiesSync()
Get the connections NetworkCapabilities.

return
NetworkCapabilities or null if an error

        NetworkCapabilities value;
        if (isCallerOnDifferentThread()) {
            Message response = sendMessageSynchronously(REQ_GET_NETWORK_CAPABILITIES);
            if ((response != null) && (response.what == RSP_GET_NETWORK_CAPABILITIES)) {
                value = rspNetworkCapabilities(response);
            } else {
                value = null;
            }
        } else {
            value = mDc.getCopyNetworkCapabilities();
        }
        return value;
    
public java.lang.String[]getPcscfAddr()

        return mDc.mPcscfAddr;
    
private booleanisCallerOnDifferentThread()

        long curThreadId = Thread.currentThread().getId();
        boolean value = mDcThreadId != curThreadId;
        if (DBG) log("isCallerOnDifferentThread: " + value);
        return value;
    
public booleanisInactiveSync()

return
true if the state machine is in the inactive state and can be used for a new connection.

        boolean value;
        if (isCallerOnDifferentThread()) {
            Message response = sendMessageSynchronously(REQ_IS_INACTIVE);
            if ((response != null) && (response.what == RSP_IS_INACTIVE)) {
                value = rspIsInactive(response);
            } else {
                log("rspIsInactive error response=" + response);
                value = false;
            }
        } else {
            value = mDc.getIsInactive();
        }
        return value;
    
private voidlog(java.lang.String s)

        android.telephony.Rlog.d(mLogTag, "DataConnectionAc " + s);
    
public voidreqApnSetting()
Request the connections ApnSetting. Response {@link #rspApnSetting}

        sendMessage(REQ_GET_APNSETTING);
        if (DBG) log("reqApnSetting");
    
public voidreqCid()
Request the Connection ID. Response {@link #rspCid}

        sendMessage(REQ_GET_CID);
        if (DBG) log("reqCid");
    
public voidreqIsInactive()
Request if the state machine is in the inactive state. Response {@link #rspIsInactive}

        sendMessage(REQ_IS_INACTIVE);
        if (DBG) log("reqIsInactive");
    
public voidreqLinkProperties()
Request the connections LinkProperties. Response {@link #rspLinkProperties}

        sendMessage(REQ_GET_LINK_PROPERTIES);
        if (DBG) log("reqLinkProperties");
    
public voidreqNetworkCapabilities()
Request the connections NetworkCapabilities. Response {@link #rspNetworkCapabilities}

        sendMessage(REQ_GET_NETWORK_CAPABILITIES);
        if (DBG) log("reqNetworkCapabilities");
    
public voidreqReset()
Response RSP_RESET when complete

        sendMessage(REQ_RESET);
        if (DBG) log("reqReset");
    
public voidreqSetLinkPropertiesHttpProxy(android.net.ProxyInfo proxy)
Request setting the connections LinkProperties.HttpProxy. Response RSP_SET_LINK_PROPERTIES when complete.

        sendMessage(REQ_SET_LINK_PROPERTIES_HTTP_PROXY, proxy);
        if (DBG) log("reqSetLinkPropertiesHttpProxy proxy=" + proxy);
    
public ApnSettingrspApnSetting(android.os.Message response)
Evaluate a RSP_APN_SETTING message and return the ApnSetting.

param
response Message
return
ApnSetting, maybe null

        ApnSetting retVal = (ApnSetting) response.obj;
        if (DBG) log("rspApnSetting=" + retVal);
        return retVal;
    
public intrspCid(android.os.Message response)
Evaluate a RSP_GET_CID message and return the cid.

param
response Message
return
connection id or -1 if an error

        int retVal = response.arg1;
        if (DBG) log("rspCid=" + retVal);
        return retVal;
    
public booleanrspIsInactive(android.os.Message response)
Evaluate RSP_IS_INACTIVE.

return
true if the state machine is in the inactive state.

        boolean retVal = response.arg1 == 1;
        if (DBG) log("rspIsInactive=" + retVal);
        return retVal;
    
public android.net.LinkPropertiesrspLinkProperties(android.os.Message response)
Evaluate RSP_GET_LINK_PROPERTIES

param
response
return
LinkProperties, maybe null.

        LinkProperties retVal = (LinkProperties) response.obj;
        if (DBG) log("rspLinkProperties=" + retVal);
        return retVal;
    
public android.net.NetworkCapabilitiesrspNetworkCapabilities(android.os.Message response)
Evaluate RSP_GET_NETWORK_CAPABILITIES

param
response
return
NetworkCapabilites, maybe null.

        NetworkCapabilities retVal = (NetworkCapabilities) response.obj;
        if (DBG) log("rspNetworkCapabilities=" + retVal);
        return retVal;
    
public voidsetLinkPropertiesHttpProxySync(android.net.ProxyInfo proxy)
Set the connections LinkProperties.HttpProxy

        if (isCallerOnDifferentThread()) {
            Message response =
                sendMessageSynchronously(REQ_SET_LINK_PROPERTIES_HTTP_PROXY, proxy);
            if ((response != null) && (response.what == RSP_SET_LINK_PROPERTIES_HTTP_PROXY)) {
                if (DBG) log("setLinkPropertiesHttpPoxy ok");
            } else {
                log("setLinkPropertiesHttpPoxy error response=" + response);
            }
        } else {
            mDc.setLinkPropertiesHttpProxy(proxy);
        }
    
public voidtearDown(ApnContext apnContext, java.lang.String reason, android.os.Message onCompletedMsg)
Tear down the connection through the apn on the network.

param
onCompletedMsg is sent with its msg.obj as an AsyncResult object. With AsyncResult.userObj set to the original msg.obj.

        if (DBG) {
            log("tearDown: apnContext=" + apnContext
                    + " reason=" + reason + " onCompletedMsg=" + onCompletedMsg);
        }
        sendMessage(DataConnection.EVENT_DISCONNECT,
                        new DisconnectParams(apnContext, reason, onCompletedMsg));
    
public voidtearDownAll(java.lang.String reason, android.os.Message onCompletedMsg)
Tear down the connection through the apn on the network. Ignores refcount and and always tears down.

param
onCompletedMsg is sent with its msg.obj as an AsyncResult object. With AsyncResult.userObj set to the original msg.obj.

        if (DBG) log("tearDownAll: reason=" + reason + " onCompletedMsg=" + onCompletedMsg);
        sendMessage(DataConnection.EVENT_DISCONNECT_ALL,
                new DisconnectParams(null, reason, onCompletedMsg));
    
public java.lang.StringtoString()

        return mDc.getName();