boolean unavailable = intent.getBooleanExtra(Phone.NETWORK_UNAVAILABLE_KEY,
false);
if (DBG) Log.d(TAG, mApnType + " Received " + intent.getAction() +
- " broadcast - state = " + state + ", unavailable = " + unavailable +
- ", reason = " + (reason == null ? "(unspecified)" : reason));
+ " broadcast - state = " + state + ", oldstate = " + mMobileDataState +
+ ", unavailable = " + unavailable + ", reason = " +
+ (reason == null ? "(unspecified)" : reason));
if (isApnTypeIncluded(apnTypeList)) {
if (mEnabled == false) {
// we should record the interface name if one's provided. If the user
// turns on this network we will need the interfacename but won't get
// a fresh connected message - TODO fix this..
- if (mInterfaceName == null && state == Phone.DataState.CONNECTED) {
+ if (state == Phone.DataState.CONNECTED) {
+ if (DBG) Log.d(TAG, "replacing old mInterfaceName (" +
+ mInterfaceName + ") with " +
+ intent.getStringExtra(Phone.DATA_IFACE_NAME_KEY) +
+ " for " + mApnType);
mInterfaceName = intent.getStringExtra(Phone.DATA_IFACE_NAME_KEY);
- } else if (state == Phone.DataState.DISCONNECTED) {
- mInterfaceName = null;
}
if (DBG) Log.d(TAG, " dropped - mEnabled = false");
return;
if (mInterfaceName != null) {
NetworkUtils.resetConnections(mInterfaceName);
}
+ if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
+ " as it DISCONNECTED");
mInterfaceName = null;
mDefaultGatewayAddr = 0;
break;
switch (setEnableApn(mApnType, true)) {
case Phone.APN_ALREADY_ACTIVE:
mEnabled = true;
+ // need to set self to CONNECTING so the below message is handled.
+ mMobileDataState = Phone.DataState.CONNECTING;
//send out a connected message
Intent intent = new Intent(TelephonyIntents.
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
*/
@Override
public boolean requestRouteToHost(int hostAddress) {
+ if (DBG) {
+ Log.d(TAG, "Requested host route to " + Integer.toHexString(hostAddress) +
+ " for " + mApnType + "(" + mInterfaceName + ")");
+ }
if (mInterfaceName != null && hostAddress != -1) {
- if (DBG) {
- Log.d(TAG, "Requested host route to " + Integer.toHexString(hostAddress));
- }
return NetworkUtils.addHostRoute(mInterfaceName, hostAddress) == 0;
} else {
return false;
mNetRequestersPids[usedNetworkType].add(currentPid);
}
- if (ni.isConnectedOrConnecting() == true) {
+ if ((ni.isConnectedOrConnecting() == true) &&
+ !network.isTeardownRequested()) {
if (ni.isConnected() == true) {
// add the pid-specific dns
handleDnsConfigurationChange();
++numConnectedNets;
}
}
+ if (DBG) Log.d(TAG, "numConnectedNets returning "+numConnectedNets);
return numConnectedNets;
}
if (newNet.isAvailable()) {
NetworkInfo switchTo = newNet.getNetworkInfo();
switchTo.setFailover(true);
- if (!switchTo.isConnectedOrConnecting()) {
+ if (!switchTo.isConnectedOrConnecting() ||
+ newNet.isTeardownRequested()) {
newNet.reconnect();
}
if (DBG) {
if (dataEnabled[id] != enable) {
dataEnabled[id] = enable;
+ // count the total number of enabled APN's
+ // if we just enabled the first APN, start our Data connection,
+ // if we disabled the last, stop our data connection
if (enable) {
enabledCount++;
+ if (enabledCount == 1) {
+ setPrivateDataEnabled(true);
+ }
} else {
enabledCount--;
- }
-
- if (enabledCount == 0) {
- setPrivateDataEnabled(false);
- } else if (enabledCount == 1) {
- setPrivateDataEnabled(true);
+ if (enabledCount == 0) {
+ setPrivateDataEnabled(false);
+ }
}
}
}