Fields Summary |
---|
private static final boolean | DBG |
private static final boolean | VDBG |
private static final String | DEFAULT_DATA_RETRY_CONFIGRetry configuration: A doubling of retry times from 5secs to 30minutes |
private static final String | SECONDARY_DATA_RETRY_CONFIGRetry configuration for secondary networks: 4 tries in 20 sec |
private static final String | NETWORK_TYPE |
private DcController | mDcController |
private DcTesterFailBringUpAll | mDcTesterFailBringUpAll |
private static AtomicInteger | mInstanceNumber |
private com.android.internal.util.AsyncChannel | mAc |
private DcRetryAlarmController | mDcRetryAlarmController |
private DcTrackerBase | mDct |
protected String[] | mPcscfAddr |
private ApnSetting | mApnSetting |
private ConnectionParams | mConnectionParams |
private DisconnectParams | mDisconnectParams |
private DcFailCause | mDcFailCause |
private com.android.internal.telephony.PhoneBase | mPhone |
private android.net.LinkProperties | mLinkProperties |
private long | mCreateTime |
private long | mLastFailTime |
private DcFailCause | mLastFailCause |
private static final String | NULL_IP |
private Object | mUserData |
private int | mRilRat |
private int | mDataRegState |
private android.net.NetworkInfo | mNetworkInfo |
private android.net.NetworkAgent | mNetworkAgent |
int | mTag |
int | mCid |
List | mApnContexts |
android.app.PendingIntent | mReconnectIntent |
com.android.internal.telephony.RetryManager | mRetryManager |
static final int | BASE |
static final int | EVENT_CONNECT |
static final int | EVENT_SETUP_DATA_CONNECTION_DONE |
static final int | EVENT_GET_LAST_FAIL_DONE |
static final int | EVENT_DEACTIVATE_DONE |
static final int | EVENT_DISCONNECT |
static final int | EVENT_RIL_CONNECTED |
static final int | EVENT_DISCONNECT_ALL |
static final int | EVENT_DATA_STATE_CHANGED |
static final int | EVENT_TEAR_DOWN_NOW |
static final int | EVENT_LOST_CONNECTION |
static final int | EVENT_RETRY_CONNECTION |
static final int | EVENT_DATA_CONNECTION_DRS_OR_RAT_CHANGED |
static final int | EVENT_DATA_CONNECTION_ROAM_ON |
static final int | EVENT_DATA_CONNECTION_ROAM_OFF |
private static final int | CMD_TO_STRING_COUNT |
private static String[] | sCmdToString |
private int | mId |
private static final String | TCP_BUFFER_SIZES_GPRS |
private static final String | TCP_BUFFER_SIZES_EDGE |
private static final String | TCP_BUFFER_SIZES_UMTS |
private static final String | TCP_BUFFER_SIZES_1XRTT |
private static final String | TCP_BUFFER_SIZES_EVDO |
private static final String | TCP_BUFFER_SIZES_EHRPD |
private static final String | TCP_BUFFER_SIZES_HSDPA |
private static final String | TCP_BUFFER_SIZES_HSPA |
private static final String | TCP_BUFFER_SIZES_LTE |
private static final String | TCP_BUFFER_SIZES_HSPAP |
private DcDefaultState | mDefaultState |
private DcInactiveState | mInactiveState |
private DcRetryingState | mRetryingState |
private DcActivatingState | mActivatingState |
private DcActiveState | mActiveState |
private DcDisconnectingState | mDisconnectingState |
private DcDisconnectionErrorCreatingConnection | mDisconnectingErrorCreatingConnection |
Methods Summary |
---|
private void | checkSetMtu(ApnSetting apn, android.net.LinkProperties lp)Read the MTU value from link properties where it can be set from network. In case
not set by the network, set it again using the mtu szie value defined in the APN
database for the connected APN
if (lp == null) return;
if (apn == null || lp == null) return;
if (lp.getMtu() != PhoneConstants.UNSET_MTU) {
if (DBG) log("MTU set by call response to: " + lp.getMtu());
return;
}
if (apn != null && apn.mtu != PhoneConstants.UNSET_MTU) {
lp.setMtu(apn.mtu);
if (DBG) log("MTU set by APN to: " + apn.mtu);
return;
}
int mtu = mPhone.getContext().getResources().getInteger(
com.android.internal.R.integer.config_mobile_mtu);
if (mtu != PhoneConstants.UNSET_MTU) {
lp.setMtu(mtu);
if (DBG) log("MTU set by config resource to: " + mtu);
}
|
private void | clearSettings()Clear all settings called when entering mInactiveState.
if (DBG) log("clearSettings");
mCreateTime = -1;
mLastFailTime = -1;
mLastFailCause = DcFailCause.NONE;
mCid = -1;
mPcscfAddr = new String[5];
mLinkProperties = new LinkProperties();
mApnContexts.clear();
mApnSetting = null;
mDcFailCause = null;
|
static java.lang.String | cmdToString(int cmd)
sCmdToString[EVENT_CONNECT - BASE] = "EVENT_CONNECT";
sCmdToString[EVENT_SETUP_DATA_CONNECTION_DONE - BASE] =
"EVENT_SETUP_DATA_CONNECTION_DONE";
sCmdToString[EVENT_GET_LAST_FAIL_DONE - BASE] = "EVENT_GET_LAST_FAIL_DONE";
sCmdToString[EVENT_DEACTIVATE_DONE - BASE] = "EVENT_DEACTIVATE_DONE";
sCmdToString[EVENT_DISCONNECT - BASE] = "EVENT_DISCONNECT";
sCmdToString[EVENT_RIL_CONNECTED - BASE] = "EVENT_RIL_CONNECTED";
sCmdToString[EVENT_DISCONNECT_ALL - BASE] = "EVENT_DISCONNECT_ALL";
sCmdToString[EVENT_DATA_STATE_CHANGED - BASE] = "EVENT_DATA_STATE_CHANGED";
sCmdToString[EVENT_TEAR_DOWN_NOW - BASE] = "EVENT_TEAR_DOWN_NOW";
sCmdToString[EVENT_LOST_CONNECTION - BASE] = "EVENT_LOST_CONNECTION";
sCmdToString[EVENT_RETRY_CONNECTION - BASE] = "EVENT_RETRY_CONNECTION";
sCmdToString[EVENT_DATA_CONNECTION_DRS_OR_RAT_CHANGED - BASE] =
"EVENT_DATA_CONNECTION_DRS_OR_RAT_CHANGED";
sCmdToString[EVENT_DATA_CONNECTION_ROAM_ON - BASE] = "EVENT_DATA_CONNECTION_ROAM_ON";
sCmdToString[EVENT_DATA_CONNECTION_ROAM_OFF - BASE] = "EVENT_DATA_CONNECTION_ROAM_OFF";
String value;
cmd -= BASE;
if ((cmd >= 0) && (cmd < sCmdToString.length)) {
value = sCmdToString[cmd];
} else {
value = DcAsyncChannel.cmdToString(cmd + BASE);
}
if (value == null) {
value = "0x" + Integer.toHexString(cmd + BASE);
}
return value;
|
private void | configureRetry(boolean forDefault)
String retryConfig = getRetryConfig(forDefault);
if (!mRetryManager.configure(retryConfig)) {
if (forDefault) {
if (!mRetryManager.configure(DEFAULT_DATA_RETRY_CONFIG)) {
// Should never happen, log an error and default to a simple linear sequence.
loge("configureRetry: Could not configure using " +
"DEFAULT_DATA_RETRY_CONFIG=" + DEFAULT_DATA_RETRY_CONFIG);
mRetryManager.configure(5, 2000, 1000);
}
} else {
if (!mRetryManager.configure(SECONDARY_DATA_RETRY_CONFIG)) {
// Should never happen, log an error and default to a simple sequence.
loge("configureRetry: Could note configure using " +
"SECONDARY_DATA_RETRY_CONFIG=" + SECONDARY_DATA_RETRY_CONFIG);
mRetryManager.configure(5, 2000, 1000);
}
}
}
if (DBG) {
log("configureRetry: forDefault=" + forDefault + " mRetryManager=" + mRetryManager);
}
|
void | dispose()
log("dispose: call quiteNow()");
quitNow();
|
public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)Dump the current state.
pw.print("DataConnection ");
super.dump(fd, pw, args);
pw.println(" mApnContexts.size=" + mApnContexts.size());
pw.println(" mApnContexts=" + mApnContexts);
pw.flush();
pw.println(" mDataConnectionTracker=" + mDct);
pw.println(" mApnSetting=" + mApnSetting);
pw.println(" mTag=" + mTag);
pw.println(" mCid=" + mCid);
pw.println(" mRetryManager=" + mRetryManager);
pw.println(" mConnectionParams=" + mConnectionParams);
pw.println(" mDisconnectParams=" + mDisconnectParams);
pw.println(" mDcFailCause=" + mDcFailCause);
pw.flush();
pw.println(" mPhone=" + mPhone);
pw.flush();
pw.println(" mLinkProperties=" + mLinkProperties);
pw.flush();
pw.println(" mDataRegState=" + mDataRegState);
pw.println(" mRilRat=" + mRilRat);
pw.println(" mNetworkCapabilities=" + makeNetworkCapabilities());
pw.println(" mCreateTime=" + TimeUtils.logTimeOfDay(mCreateTime));
pw.println(" mLastFailTime=" + TimeUtils.logTimeOfDay(mLastFailTime));
pw.println(" mLastFailCause=" + mLastFailCause);
pw.flush();
pw.println(" mUserData=" + mUserData);
pw.println(" mInstanceNumber=" + mInstanceNumber);
pw.println(" mAc=" + mAc);
pw.println(" mDcRetryAlarmController=" + mDcRetryAlarmController);
pw.flush();
|
private void | dumpToLog()
dump(null, new PrintWriter(new StringWriter(0)) {
@Override
public void println(String s) {
DataConnection.this.logd(s);
}
@Override
public void flush() {
}
}, null);
|
ApnSetting | getApnSetting()
return mApnSetting;
|
int | getCid()
return mCid;
|
android.net.LinkProperties | getCopyLinkProperties()
return new LinkProperties(mLinkProperties);
|
android.net.NetworkCapabilities | getCopyNetworkCapabilities()
return makeNetworkCapabilities();
|
public int | getDataConnectionId()Get the DataConnection ID
return mId;
|
boolean | getIsInactive()
return getCurrentState() == mInactiveState;
|
private java.lang.String | getRetryConfig(boolean forDefault)
int nt = mPhone.getServiceState().getNetworkType();
if (Build.IS_DEBUGGABLE) {
String config = SystemProperties.get("test.data_retry_config");
if (! TextUtils.isEmpty(config)) {
return config;
}
}
if ((nt == TelephonyManager.NETWORK_TYPE_CDMA) ||
(nt == TelephonyManager.NETWORK_TYPE_1xRTT) ||
(nt == TelephonyManager.NETWORK_TYPE_EVDO_0) ||
(nt == TelephonyManager.NETWORK_TYPE_EVDO_A) ||
(nt == TelephonyManager.NETWORK_TYPE_EVDO_B) ||
(nt == TelephonyManager.NETWORK_TYPE_EHRPD)) {
// CDMA variant
return SystemProperties.get("ro.cdma.data_retry_config");
} else {
// Use GSM variant for all others.
if (forDefault) {
return SystemProperties.get("ro.gsm.data_retry_config");
} else {
return SystemProperties.get("ro.gsm.2nd_data_retry_config");
}
}
|
protected java.lang.String | getWhatToString(int what)
return cmdToString(what);
|
private boolean | initConnection(com.android.internal.telephony.dataconnection.DataConnection$ConnectionParams cp)Initialize connection, this will fail if the
apnSettings are not compatible.
ApnContext apnContext = cp.mApnContext;
if (mApnSetting == null) {
// Only change apn setting if it isn't set, it will
// only NOT be set only if we're in DcInactiveState.
mApnSetting = apnContext.getApnSetting();
}
if (mApnSetting == null || !mApnSetting.canHandleType(apnContext.getApnType())) {
if (DBG) {
log("initConnection: incompatible apnSetting in ConnectionParams cp=" + cp
+ " dc=" + DataConnection.this);
}
return false;
}
mTag += 1;
mConnectionParams = cp;
mConnectionParams.mTag = mTag;
if (!mApnContexts.contains(apnContext)) {
mApnContexts.add(apnContext);
}
configureRetry(mApnSetting.canHandleType(PhoneConstants.APN_TYPE_DEFAULT));
mRetryManager.setRetryCount(0);
mRetryManager.setCurMaxRetryCount(mConnectionParams.mInitialMaxRetry);
mRetryManager.setRetryForever(false);
if (DBG) {
log("initConnection: "
+ " RefCount=" + mApnContexts.size()
+ " mApnList=" + mApnContexts
+ " mConnectionParams=" + mConnectionParams);
}
return true;
|
private boolean | isDnsOk(java.lang.String[] domainNameServers)
if (NULL_IP.equals(domainNameServers[0]) && NULL_IP.equals(domainNameServers[1])
&& !mPhone.isDnsCheckDisabled()) {
// Work around a race condition where QMI does not fill in DNS:
// Deactivate PDP and let DataConnectionTracker retry.
// Do not apply the race condition workaround for MMS APN
// if Proxy is an IP-address.
// Otherwise, the default APN will not be restored anymore.
if (!mApnSetting.types[0].equals(PhoneConstants.APN_TYPE_MMS)
|| !isIpAddress(mApnSetting.mmsProxy)) {
log(String.format(
"isDnsOk: return false apn.types[0]=%s APN_TYPE_MMS=%s isIpAddress(%s)=%s",
mApnSetting.types[0], PhoneConstants.APN_TYPE_MMS, mApnSetting.mmsProxy,
isIpAddress(mApnSetting.mmsProxy)));
return false;
}
}
return true;
|
private boolean | isIpAddress(java.lang.String address)
if (address == null) return false;
return Patterns.IP_ADDRESS.matcher(address).matches();
|
public boolean | isIpv4Connected()
boolean ret = false;
Collection <InetAddress> addresses = mLinkProperties.getAddresses();
for (InetAddress addr: addresses) {
if (addr instanceof java.net.Inet4Address) {
java.net.Inet4Address i4addr = (java.net.Inet4Address) addr;
if (!i4addr.isAnyLocalAddress() && !i4addr.isLinkLocalAddress() &&
!i4addr.isLoopbackAddress() && !i4addr.isMulticastAddress()) {
ret = true;
break;
}
}
}
return ret;
|
public boolean | isIpv6Connected()
boolean ret = false;
Collection <InetAddress> addresses = mLinkProperties.getAddresses();
for (InetAddress addr: addresses) {
if (addr instanceof java.net.Inet6Address) {
java.net.Inet6Address i6addr = (java.net.Inet6Address) addr;
if (!i6addr.isAnyLocalAddress() && !i6addr.isLinkLocalAddress() &&
!i6addr.isLoopbackAddress() && !i6addr.isMulticastAddress()) {
ret = true;
break;
}
}
}
return ret;
|
protected void | log(java.lang.String s)Log with debug
Rlog.d(getName(), s);
|
protected void | logd(java.lang.String s)Log with debug attribute
Rlog.d(getName(), s);
|
protected void | loge(java.lang.String s)Log with error attribute
Rlog.e(getName(), s);
|
protected void | loge(java.lang.String s, java.lang.Throwable e)Log with error attribute
Rlog.e(getName(), s, e);
|
protected void | logi(java.lang.String s)Log with info attribute
Rlog.i(getName(), s);
|
protected void | logv(java.lang.String s)Log with verbose attribute
Rlog.v(getName(), s);
|
protected void | logw(java.lang.String s)Log with warning attribute
Rlog.w(getName(), s);
|
static com.android.internal.telephony.dataconnection.DataConnection | makeDataConnection(com.android.internal.telephony.PhoneBase phone, int id, DcTrackerBase dct, DcTesterFailBringUpAll failBringUpAll, DcController dcc)Create the connection object
DataConnection dc = new DataConnection(phone,
"DC-" + mInstanceNumber.incrementAndGet(), id, dct, failBringUpAll, dcc);
dc.start();
if (DBG) dc.log("Made " + dc.getName());
return dc;
|
private android.net.NetworkCapabilities | makeNetworkCapabilities()
NetworkCapabilities result = new NetworkCapabilities();
result.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
if (mApnSetting != null) {
for (String type : mApnSetting.types) {
switch (type) {
case PhoneConstants.APN_TYPE_ALL: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
result.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
result.addCapability(NetworkCapabilities.NET_CAPABILITY_SUPL);
result.addCapability(NetworkCapabilities.NET_CAPABILITY_FOTA);
result.addCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
result.addCapability(NetworkCapabilities.NET_CAPABILITY_CBS);
result.addCapability(NetworkCapabilities.NET_CAPABILITY_IA);
break;
}
case PhoneConstants.APN_TYPE_DEFAULT: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
break;
}
case PhoneConstants.APN_TYPE_MMS: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
break;
}
case PhoneConstants.APN_TYPE_SUPL: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_SUPL);
break;
}
case PhoneConstants.APN_TYPE_DUN: {
ApnSetting securedDunApn = mDct.fetchDunApn();
if (securedDunApn == null || securedDunApn.equals(mApnSetting)) {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_DUN);
}
break;
}
case PhoneConstants.APN_TYPE_FOTA: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_FOTA);
break;
}
case PhoneConstants.APN_TYPE_IMS: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
break;
}
case PhoneConstants.APN_TYPE_CBS: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_CBS);
break;
}
case PhoneConstants.APN_TYPE_IA: {
result.addCapability(NetworkCapabilities.NET_CAPABILITY_IA);
break;
}
default:
}
}
ConnectivityManager.maybeMarkCapabilitiesRestricted(result);
}
int up = 14;
int down = 14;
switch (mRilRat) {
case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS: up = 80; down = 80; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE: up = 59; down = 236; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS: up = 384; down = 384; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_IS95A: // fall through
case ServiceState.RIL_RADIO_TECHNOLOGY_IS95B: up = 14; down = 14; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0: up = 153; down = 2457; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A: up = 1843; down = 3174; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT: up = 100; down = 100; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA: up = 2048; down = 14336; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA: up = 5898; down = 14336; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA: up = 5898; down = 14336; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B: up = 1843; down = 5017; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_LTE: up = 51200; down = 102400; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD: up = 153; down = 2516; break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP: up = 11264; down = 43008; break;
default:
}
result.setLinkUpstreamBandwidthKbps(up);
result.setLinkDownstreamBandwidthKbps(down);
result.setNetworkSpecifier(Integer.toString(mPhone.getSubId()));
return result;
|
private static java.lang.String | msgToString(android.os.Message msg)
String retVal;
if (msg == null) {
retVal = "null";
} else {
StringBuilder b = new StringBuilder();
b.append("{what=");
b.append(cmdToString(msg.what));
b.append(" when=");
TimeUtils.formatDuration(msg.getWhen() - SystemClock.uptimeMillis(), b);
if (msg.arg1 != 0) {
b.append(" arg1=");
b.append(msg.arg1);
}
if (msg.arg2 != 0) {
b.append(" arg2=");
b.append(msg.arg2);
}
if (msg.obj != null) {
b.append(" obj=");
b.append(msg.obj);
}
b.append(" target=");
b.append(msg.getTarget());
b.append(" replyTo=");
b.append(msg.replyTo);
b.append("}");
retVal = b.toString();
}
return retVal;
|
private void | notifyAllDisconnectCompleted(DcFailCause cause)
notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DONE, cause.toString());
|
private void | notifyAllOfConnected(java.lang.String reason)
notifyAllWithEvent(null, DctConstants.EVENT_DATA_SETUP_COMPLETE, reason);
|
private void | notifyAllOfDisconnectDcRetrying(java.lang.String reason)
notifyAllWithEvent(null, DctConstants.EVENT_DISCONNECT_DC_RETRYING, reason);
|
private void | notifyAllWithEvent(ApnContext alreadySent, int event, java.lang.String reason)
mNetworkInfo.setDetailedState(mNetworkInfo.getDetailedState(), reason,
mNetworkInfo.getExtraInfo());
for (ApnContext apnContext : mApnContexts) {
if (apnContext == alreadySent) continue;
if (reason != null) apnContext.setReason(reason);
Message msg = mDct.obtainMessage(event, apnContext);
AsyncResult.forMessage(msg);
msg.sendToTarget();
}
|
private void | notifyConnectCompleted(com.android.internal.telephony.dataconnection.DataConnection$ConnectionParams cp, DcFailCause cause, boolean sendAll)Send the connectionCompletedMsg.
ApnContext alreadySent = null;
if (cp != null && cp.mOnCompletedMsg != null) {
// Get the completed message but only use it once
Message connectionCompletedMsg = cp.mOnCompletedMsg;
cp.mOnCompletedMsg = null;
if (connectionCompletedMsg.obj instanceof ApnContext) {
alreadySent = (ApnContext)connectionCompletedMsg.obj;
}
long timeStamp = System.currentTimeMillis();
connectionCompletedMsg.arg1 = mCid;
if (cause == DcFailCause.NONE) {
mCreateTime = timeStamp;
AsyncResult.forMessage(connectionCompletedMsg);
} else {
mLastFailCause = cause;
mLastFailTime = timeStamp;
// Return message with a Throwable exception to signify an error.
if (cause == null) cause = DcFailCause.UNKNOWN;
AsyncResult.forMessage(connectionCompletedMsg, cause,
new Throwable(cause.toString()));
}
if (DBG) {
log("notifyConnectCompleted at " + timeStamp + " cause=" + cause
+ " connectionCompletedMsg=" + msgToString(connectionCompletedMsg));
}
connectionCompletedMsg.sendToTarget();
}
if (sendAll) {
notifyAllWithEvent(alreadySent, DctConstants.EVENT_DATA_SETUP_COMPLETE_ERROR,
cause.toString());
}
|
private void | notifyDisconnectCompleted(com.android.internal.telephony.dataconnection.DataConnection$DisconnectParams dp, boolean sendAll)Send ar.userObj if its a message, which is should be back to originator.
if (VDBG) log("NotifyDisconnectCompleted");
ApnContext alreadySent = null;
String reason = null;
if (dp != null && dp.mOnCompletedMsg != null) {
// Get the completed message but only use it once
Message msg = dp.mOnCompletedMsg;
dp.mOnCompletedMsg = null;
if (msg.obj instanceof ApnContext) {
alreadySent = (ApnContext)msg.obj;
}
reason = dp.mReason;
if (VDBG) {
log(String.format("msg=%s msg.obj=%s", msg.toString(),
((msg.obj instanceof String) ? (String) msg.obj : "<no-reason>")));
}
AsyncResult.forMessage(msg);
msg.sendToTarget();
}
if (sendAll) {
if (reason == null) {
reason = DcFailCause.UNKNOWN.toString();
}
notifyAllWithEvent(alreadySent, DctConstants.EVENT_DISCONNECT_DONE, reason);
}
if (DBG) log("NotifyDisconnectCompleted DisconnectParams=" + dp);
|
private void | onConnect(com.android.internal.telephony.dataconnection.DataConnection$ConnectionParams cp)Begin setting up a data connection, calls setupDataCall
and the ConnectionParams will be returned with the
EVENT_SETUP_DATA_CONNECTION_DONE AsyncResul.userObj.
if (DBG) log("onConnect: carrier='" + mApnSetting.carrier
+ "' APN='" + mApnSetting.apn
+ "' proxy='" + mApnSetting.proxy + "' port='" + mApnSetting.port + "'");
// Check if we should fake an error.
if (mDcTesterFailBringUpAll.getDcFailBringUp().mCounter > 0) {
DataCallResponse response = new DataCallResponse();
response.version = mPhone.mCi.getRilVersion();
response.status = mDcTesterFailBringUpAll.getDcFailBringUp().mFailCause.getErrorCode();
response.cid = 0;
response.active = 0;
response.type = "";
response.ifname = "";
response.addresses = new String[0];
response.dnses = new String[0];
response.gateways = new String[0];
response.suggestedRetryTime =
mDcTesterFailBringUpAll.getDcFailBringUp().mSuggestedRetryTime;
response.pcscf = new String[0];
response.mtu = PhoneConstants.UNSET_MTU;
Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
AsyncResult.forMessage(msg, response, null);
sendMessage(msg);
if (DBG) {
log("onConnect: FailBringUpAll=" + mDcTesterFailBringUpAll.getDcFailBringUp()
+ " send error response=" + response);
}
mDcTesterFailBringUpAll.getDcFailBringUp().mCounter -= 1;
return;
}
mCreateTime = -1;
mLastFailTime = -1;
mLastFailCause = DcFailCause.NONE;
// msg.obj will be returned in AsyncResult.userObj;
Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
msg.obj = cp;
int authType = mApnSetting.authType;
if (authType == -1) {
authType = TextUtils.isEmpty(mApnSetting.user) ? RILConstants.SETUP_DATA_AUTH_NONE
: RILConstants.SETUP_DATA_AUTH_PAP_CHAP;
}
String protocol;
if (mPhone.getServiceState().getDataRoaming()) {
protocol = mApnSetting.roamingProtocol;
} else {
protocol = mApnSetting.protocol;
}
mPhone.mCi.setupDataCall(
Integer.toString(cp.mRilRat + 2),
Integer.toString(cp.mProfileId),
mApnSetting.apn, mApnSetting.user, mApnSetting.password,
Integer.toString(authType),
protocol, msg);
|
private DataCallResponse.SetupResult | onSetupConnectionCompleted(android.os.AsyncResult ar)Process setup completion.
DataCallResponse response = (DataCallResponse) ar.result;
ConnectionParams cp = (ConnectionParams) ar.userObj;
DataCallResponse.SetupResult result;
if (cp.mTag != mTag) {
if (DBG) {
log("onSetupConnectionCompleted stale cp.tag=" + cp.mTag + ", mtag=" + mTag);
}
result = DataCallResponse.SetupResult.ERR_Stale;
} else if (ar.exception != null) {
if (DBG) {
log("onSetupConnectionCompleted failed, ar.exception=" + ar.exception +
" response=" + response);
}
if (ar.exception instanceof CommandException
&& ((CommandException) (ar.exception)).getCommandError()
== CommandException.Error.RADIO_NOT_AVAILABLE) {
result = DataCallResponse.SetupResult.ERR_BadCommand;
result.mFailCause = DcFailCause.RADIO_NOT_AVAILABLE;
} else if ((response == null) || (response.version < 4)) {
result = DataCallResponse.SetupResult.ERR_GetLastErrorFromRil;
} else {
result = DataCallResponse.SetupResult.ERR_RilError;
result.mFailCause = DcFailCause.fromInt(response.status);
}
} else if (response.status != 0) {
result = DataCallResponse.SetupResult.ERR_RilError;
result.mFailCause = DcFailCause.fromInt(response.status);
} else {
if (DBG) log("onSetupConnectionCompleted received DataCallResponse: " + response);
mCid = response.cid;
mPcscfAddr = response.pcscf;
result = updateLinkProperty(response).setupResult;
}
return result;
|
private DataCallResponse.SetupResult | setLinkProperties(DataCallResponse response, android.net.LinkProperties lp)
// Check if system property dns usable
boolean okToUseSystemPropertyDns = false;
String propertyPrefix = "net." + response.ifname + ".";
String dnsServers[] = new String[2];
dnsServers[0] = SystemProperties.get(propertyPrefix + "dns1");
dnsServers[1] = SystemProperties.get(propertyPrefix + "dns2");
okToUseSystemPropertyDns = isDnsOk(dnsServers);
// set link properties based on data call response
return response.setLinkProperties(lp, okToUseSystemPropertyDns);
|
void | setLinkPropertiesHttpProxy(android.net.ProxyInfo proxy)
mLinkProperties.setHttpProxy(proxy);
|
static void | slog(java.lang.String s)
Rlog.d("DC", s);
|
private void | tearDownData(java.lang.Object o)TearDown the data connection when the deactivation is complete a Message with
msg.what == EVENT_DEACTIVATE_DONE and msg.obj == AsyncResult with AsyncResult.obj
containing the parameter o.
int discReason = RILConstants.DEACTIVATE_REASON_NONE;
if ((o != null) && (o instanceof DisconnectParams)) {
DisconnectParams dp = (DisconnectParams)o;
if (TextUtils.equals(dp.mReason, Phone.REASON_RADIO_TURNED_OFF)) {
discReason = RILConstants.DEACTIVATE_REASON_RADIO_OFF;
} else if (TextUtils.equals(dp.mReason, Phone.REASON_PDP_RESET)) {
discReason = RILConstants.DEACTIVATE_REASON_PDP_RESET;
}
}
if (mPhone.mCi.getRadioState().isOn()) {
if (DBG) log("tearDownData radio is on, call deactivateDataCall");
mPhone.mCi.deactivateDataCall(mCid, discReason,
obtainMessage(EVENT_DEACTIVATE_DONE, mTag, 0, o));
} else {
if (DBG) log("tearDownData radio is off sendMessage EVENT_DEACTIVATE_DONE immediately");
AsyncResult ar = new AsyncResult(o, null, null);
sendMessage(obtainMessage(EVENT_DEACTIVATE_DONE, mTag, 0, ar));
}
|
void | tearDownNow()Used for testing purposes.
if (DBG) log("tearDownNow()");
sendMessage(obtainMessage(EVENT_TEAR_DOWN_NOW));
|
public java.lang.String | toString()
return "{" + toStringSimple() + " mApnContexts=" + mApnContexts + "}";
|
public java.lang.String | toStringSimple()Doesn't print mApnList of ApnContext's which would be recursive
return getName() + ": State=" + getCurrentState().getName()
+ " mApnSetting=" + mApnSetting + " RefCount=" + mApnContexts.size()
+ " mCid=" + mCid + " mCreateTime=" + mCreateTime
+ " mLastastFailTime=" + mLastFailTime
+ " mLastFailCause=" + mLastFailCause
+ " mTag=" + mTag
+ " mRetryManager=" + mRetryManager
+ " mLinkProperties=" + mLinkProperties
+ " linkCapabilities=" + makeNetworkCapabilities();
|
com.android.internal.telephony.dataconnection.DataConnection$UpdateLinkPropertyResult | updateLinkProperty(DataCallResponse newState)
UpdateLinkPropertyResult result = new UpdateLinkPropertyResult(mLinkProperties);
if (newState == null) return result;
DataCallResponse.SetupResult setupResult;
result.newLp = new LinkProperties();
// set link properties based on data call response
result.setupResult = setLinkProperties(newState, result.newLp);
if (result.setupResult != DataCallResponse.SetupResult.SUCCESS) {
if (DBG) log("updateLinkProperty failed : " + result.setupResult);
return result;
}
// copy HTTP proxy as it is not part DataCallResponse.
result.newLp.setHttpProxy(mLinkProperties.getHttpProxy());
checkSetMtu(mApnSetting, result.newLp);
mLinkProperties = result.newLp;
updateTcpBufferSizes(mRilRat);
if (DBG && (! result.oldLp.equals(result.newLp))) {
log("updateLinkProperty old LP=" + result.oldLp);
log("updateLinkProperty new LP=" + result.newLp);
}
if (result.newLp.equals(result.oldLp) == false &&
mNetworkAgent != null) {
mNetworkAgent.sendLinkProperties(mLinkProperties);
}
return result;
|
private void | updateTcpBufferSizes(int rilRat)
String sizes = null;
String ratName = ServiceState.rilRadioTechnologyToString(rilRat).toLowerCase(Locale.ROOT);
// ServiceState gives slightly different names for EVDO tech ("evdo-rev.0" for ex)
// - patch it up:
if (rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0 ||
rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A ||
rilRat == ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B) {
ratName = "evdo";
}
// in the form: "ratname:rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max"
String[] configOverride = mPhone.getContext().getResources().getStringArray(
com.android.internal.R.array.config_mobile_tcp_buffers);
for (int i = 0; i < configOverride.length; i++) {
String[] split = configOverride[i].split(":");
if (ratName.equals(split[0]) && split.length == 2) {
sizes = split[1];
break;
}
}
if (sizes == null) {
// no override - use telephony defaults
// doing it this way allows device or carrier to just override the types they
// care about and inherit the defaults for the others.
switch (rilRat) {
case ServiceState.RIL_RADIO_TECHNOLOGY_GPRS:
sizes = TCP_BUFFER_SIZES_GPRS;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EDGE:
sizes = TCP_BUFFER_SIZES_EDGE;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_UMTS:
sizes = TCP_BUFFER_SIZES_UMTS;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT:
sizes = TCP_BUFFER_SIZES_1XRTT;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0:
case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A:
case ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B:
sizes = TCP_BUFFER_SIZES_EVDO;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD:
sizes = TCP_BUFFER_SIZES_EHRPD;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA:
sizes = TCP_BUFFER_SIZES_HSDPA;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSPA:
case ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA:
sizes = TCP_BUFFER_SIZES_HSPA;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_LTE:
sizes = TCP_BUFFER_SIZES_LTE;
break;
case ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP:
sizes = TCP_BUFFER_SIZES_HSPAP;
break;
default:
// Leave empty - this will let ConnectivityService use the system default.
break;
}
}
mLinkProperties.setTcpBufferSizes(sizes);
|