Remove unused onResetDone.
Refactor things a bit. Promoting GsmDataConnection's apn (ApnSetting) to DataConnection. Use DataConnection's resetSynchronously rather than tampering with it from another thread. bug:3486066 Change-Id: I2a7f7368f73c7d5c81e821976efafd56aca7aa69
This commit is contained in:
@@ -219,6 +219,7 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
protected static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;
|
||||
|
||||
//***** Member Variables
|
||||
protected ApnSetting mApn;
|
||||
protected int mTag;
|
||||
protected PhoneBase phone;
|
||||
protected int cid;
|
||||
@@ -429,11 +430,12 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
protected void clearSettings() {
|
||||
if (DBG) log("clearSettings");
|
||||
|
||||
this.createTime = -1;
|
||||
this.lastFailTime = -1;
|
||||
this.lastFailCause = FailCause.NONE;
|
||||
createTime = -1;
|
||||
lastFailTime = -1;
|
||||
lastFailCause = FailCause.NONE;
|
||||
|
||||
mLinkProperties = new LinkProperties();
|
||||
mApn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1087,4 +1089,11 @@ public abstract class DataConnection extends HierarchicalStateMachine {
|
||||
public FailCause getLastFailCause() {
|
||||
return lastFailCause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current ApnSetting
|
||||
*/
|
||||
public ApnSetting getApn() {
|
||||
return mApn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,6 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected abstract void onRadioOffOrNotAvailable();
|
||||
protected abstract void onDataSetupComplete(AsyncResult ar);
|
||||
protected abstract void onDisconnectDone(int connId, AsyncResult ar);
|
||||
protected abstract void onResetDone(AsyncResult ar);
|
||||
protected abstract void onVoiceCallStarted();
|
||||
protected abstract void onVoiceCallEnded();
|
||||
protected abstract void onCleanUpConnection(boolean tearDown, int apnId, String reason);
|
||||
@@ -514,9 +513,10 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
onSetInternalDataEnabled(enabled);
|
||||
break;
|
||||
}
|
||||
case EVENT_RESET_DONE:
|
||||
case EVENT_RESET_DONE: {
|
||||
onResetDone((AsyncResult) msg.obj);
|
||||
break;
|
||||
}
|
||||
case CMD_SET_DATA_ENABLE: {
|
||||
log("CMD_SET_DATA_ENABLE msg=" + msg);
|
||||
boolean enabled = (msg.arg1 == ENABLED) ? true : false;
|
||||
@@ -602,6 +602,8 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
|
||||
protected abstract void setState(State s);
|
||||
|
||||
protected abstract void gotoIdleAndNotifyDataConnection(String reason);
|
||||
|
||||
protected LinkProperties getLinkProperties(String apnType) {
|
||||
int id = apnTypeToId(apnType);
|
||||
if (isApnIdEnabled(id)) {
|
||||
@@ -872,6 +874,22 @@ public abstract class DataConnectionTracker extends Handler {
|
||||
protected void onEnableNewApn() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when EVENT_RESET_DONE is received so goto
|
||||
* IDLE state and send notifications to those interested.
|
||||
*
|
||||
* TODO - currently unused. Needs to be hooked into DataConnection cleanup
|
||||
* TODO - needs to pass some notion of which connection is reset..
|
||||
*/
|
||||
protected void onResetDone(AsyncResult ar) {
|
||||
if (DBG) log("EVENT_RESET_DONE");
|
||||
String reason = null;
|
||||
if (ar.userObj instanceof String) {
|
||||
reason = (String) ar.userObj;
|
||||
}
|
||||
gotoIdleAndNotifyDataConnection(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent mobile data connections from being established, or once again
|
||||
* allow mobile data connections. If the state toggles, then either tear
|
||||
|
||||
@@ -67,6 +67,7 @@ public class CdmaDataConnection extends DataConnection {
|
||||
protected void onConnect(ConnectionParams cp) {
|
||||
if (DBG) log("CdmaDataConnection Connecting...");
|
||||
|
||||
mApn = cp.apn;
|
||||
createTime = -1;
|
||||
lastFailTime = -1;
|
||||
lastFailCause = FailCause.NONE;
|
||||
|
||||
@@ -508,7 +508,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
notifyDataAvailability(null);
|
||||
}
|
||||
|
||||
private void gotoIdleAndNotifyDataConnection(String reason) {
|
||||
protected void gotoIdleAndNotifyDataConnection(String reason) {
|
||||
if (DBG) log("gotoIdleAndNotifyDataConnection: reason=" + reason);
|
||||
setState(State.IDLE);
|
||||
notifyDataConnection(reason);
|
||||
@@ -667,20 +667,6 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when EVENT_RESET_DONE is received so goto
|
||||
* IDLE state and send notifications to those interested.
|
||||
*/
|
||||
@Override
|
||||
protected void onResetDone(AsyncResult ar) {
|
||||
if (DBG) log("EVENT_RESET_DONE");
|
||||
String reason = null;
|
||||
if (ar.userObj instanceof String) {
|
||||
reason = (String) ar.userObj;
|
||||
}
|
||||
gotoIdleAndNotifyDataConnection(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override com.android.internal.telephony.DataConnectionTracker
|
||||
*/
|
||||
|
||||
@@ -36,8 +36,6 @@ public class GsmDataConnection extends DataConnection {
|
||||
private static final String LOG_TAG = "GSM";
|
||||
|
||||
//***** Instance Variables
|
||||
private ApnSetting apn;
|
||||
|
||||
protected int mProfileId = RILConstants.DATA_PROFILE_DEFAULT;
|
||||
protected String mActiveApnType = Phone.APN_TYPE_DEFAULT;
|
||||
//***** Constructor
|
||||
@@ -74,13 +72,13 @@ public class GsmDataConnection extends DataConnection {
|
||||
@Override
|
||||
protected
|
||||
void onConnect(ConnectionParams cp) {
|
||||
apn = cp.apn;
|
||||
mApn = cp.apn;
|
||||
|
||||
if (DBG) log("Connecting to carrier: '" + apn.carrier
|
||||
+ "' APN: '" + apn.apn
|
||||
+ "' proxy: '" + apn.proxy + "' port: '" + apn.port);
|
||||
if (DBG) log("Connecting to carrier: '" + mApn.carrier
|
||||
+ "' APN: '" + mApn.apn
|
||||
+ "' proxy: '" + mApn.proxy + "' port: '" + mApn.port);
|
||||
|
||||
setHttpProxy (apn.proxy, apn.port);
|
||||
setHttpProxy (mApn.proxy, mApn.port);
|
||||
|
||||
createTime = -1;
|
||||
lastFailTime = -1;
|
||||
@@ -90,23 +88,23 @@ public class GsmDataConnection extends DataConnection {
|
||||
Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
|
||||
msg.obj = cp;
|
||||
|
||||
int authType = apn.authType;
|
||||
int authType = mApn.authType;
|
||||
if (authType == -1) {
|
||||
authType = (apn.user != null) ? RILConstants.SETUP_DATA_AUTH_PAP_CHAP :
|
||||
authType = (mApn.user != null) ? RILConstants.SETUP_DATA_AUTH_PAP_CHAP :
|
||||
RILConstants.SETUP_DATA_AUTH_NONE;
|
||||
}
|
||||
|
||||
String protocol;
|
||||
if (phone.getServiceState().getRoaming()) {
|
||||
protocol = apn.roamingProtocol;
|
||||
protocol = mApn.roamingProtocol;
|
||||
} else {
|
||||
protocol = apn.protocol;
|
||||
protocol = mApn.protocol;
|
||||
}
|
||||
|
||||
phone.mCM.setupDataCall(
|
||||
Integer.toString(RILConstants.SETUP_DATA_TECH_GSM),
|
||||
Integer.toString(mProfileId),
|
||||
apn.apn, apn.user, apn.password,
|
||||
mApn.apn, mApn.user, mApn.password,
|
||||
Integer.toString(authType),
|
||||
protocol, msg);
|
||||
}
|
||||
@@ -128,15 +126,9 @@ public class GsmDataConnection extends DataConnection {
|
||||
mActiveApnType = apnType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void clearSettings() {
|
||||
super.clearSettings();
|
||||
apn = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "State=" + getCurrentState().getName() + " Apn=" + apn +
|
||||
return "State=" + getCurrentState().getName() + " Apn=" + mApn +
|
||||
" create=" + createTime + " lastFail=" + lastFailTime +
|
||||
" lastFailCause=" + lastFailCause;
|
||||
}
|
||||
@@ -150,11 +142,12 @@ public class GsmDataConnection extends DataConnection {
|
||||
// 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 (!apn.types[0].equals(Phone.APN_TYPE_MMS)
|
||||
|| !isIpAddress(apn.mmsProxy)) {
|
||||
if (!mApn.types[0].equals(Phone.APN_TYPE_MMS)
|
||||
|| !isIpAddress(mApn.mmsProxy)) {
|
||||
log(String.format(
|
||||
"isDnsOk: return false apn.types[0]=%s APN_TYPE_MMS=%s isIpAddress(%s)=%s",
|
||||
apn.types[0], Phone.APN_TYPE_MMS, apn.mmsProxy, isIpAddress(apn.mmsProxy)));
|
||||
mApn.types[0], Phone.APN_TYPE_MMS, mApn.mmsProxy,
|
||||
isIpAddress(mApn.mmsProxy)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -166,15 +159,11 @@ public class GsmDataConnection extends DataConnection {
|
||||
Log.d(LOG_TAG, "[" + getName() + "] " + s);
|
||||
}
|
||||
|
||||
public ApnSetting getApn() {
|
||||
return this.apn;
|
||||
}
|
||||
|
||||
private void setHttpProxy(String httpProxy, String httpPort) {
|
||||
|
||||
if (DBG) log("set http proxy for"
|
||||
+ "' APN: '" + mActiveApnType
|
||||
+ "' proxy: '" + apn.proxy + "' port: '" + apn.port);
|
||||
+ "' proxy: '" + mApn.proxy + "' port: '" + mApn.port);
|
||||
if(TextUtils.equals(mActiveApnType, Phone.APN_TYPE_DEFAULT)) {
|
||||
if (httpProxy == null || httpProxy.length() == 0) {
|
||||
phone.setSystemProperty("net.gprs.http-proxy", null);
|
||||
@@ -205,6 +194,6 @@ public class GsmDataConnection extends DataConnection {
|
||||
private boolean isIpAddress(String address) {
|
||||
if (address == null) return false;
|
||||
|
||||
return Patterns.IP_ADDRESS.matcher(apn.mmsProxy).matches();
|
||||
return Patterns.IP_ADDRESS.matcher(address).matches();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,20 +757,19 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
return;
|
||||
}
|
||||
|
||||
GsmDataConnection pdp = apnContext.getDataConnection();
|
||||
if (tearDown && pdp!=null) {
|
||||
GsmDataConnection conn = apnContext.getDataConnection();
|
||||
if (conn != null) {
|
||||
apnContext.setState(State.DISCONNECTING);
|
||||
Message msg = obtainMessage(EVENT_DISCONNECT_DONE, apnContext);
|
||||
pdp.disconnect(msg);
|
||||
return;
|
||||
} else if (pdp != null) {
|
||||
pdp.clearSettings();
|
||||
if (tearDown ) {
|
||||
Message msg = obtainMessage(EVENT_DISCONNECT_DONE, apnContext);
|
||||
conn.disconnect(msg);
|
||||
} else {
|
||||
conn.resetSynchronously();
|
||||
apnContext.setState(State.IDLE);
|
||||
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
|
||||
}
|
||||
}
|
||||
|
||||
if (!tearDown) {
|
||||
apnContext.setState(State.IDLE);
|
||||
mPhone.notifyDataConnection(apnContext.getReason(), apnContext.getApnType());
|
||||
}
|
||||
if (apnContext.getPendingAction() == ApnContext.PENDING_ACTION_APN_DISABLE) {
|
||||
mApnContexts.remove(apnContext.getApnType());
|
||||
}
|
||||
@@ -1036,7 +1035,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
|
||||
// TODO: For multiple Active APNs not exactly sure how to do this.
|
||||
private void gotoIdleAndNotifyDataConnection(String reason) {
|
||||
protected void gotoIdleAndNotifyDataConnection(String reason) {
|
||||
if (DBG) log("gotoIdleAndNotifyDataConnection: reason=" + reason);
|
||||
notifyDataConnection(reason);
|
||||
mActiveApn = null;
|
||||
@@ -1528,19 +1527,6 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when EVENT_RESET_DONE is received.
|
||||
*/
|
||||
@Override
|
||||
protected void onResetDone(AsyncResult ar) {
|
||||
if (DBG) log("EVENT_RESET_DONE");
|
||||
String reason = null;
|
||||
if (ar.userObj instanceof String) {
|
||||
reason = (String) ar.userObj;
|
||||
}
|
||||
gotoIdleAndNotifyDataConnection(reason);
|
||||
}
|
||||
|
||||
protected void onPollPdp() {
|
||||
if (getOverallState() == State.CONNECTED) {
|
||||
// only poll when connected
|
||||
|
||||
Reference in New Issue
Block a user